diff options
author | Malfurious <m@lfurio.us> | 2023-10-09 16:31:56 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-04-24 13:31:08 -0400 |
commit | 574d5a2c4f07bed91d9682e4f48e655e88e37498 (patch) | |
tree | 0faa0f9c7d5a26b9b9d25557539c5be1abff55d9 /misplays.c | |
parent | ee936125622325a4b33bafe336b44e44a24ce1aa (diff) | |
download | misplays-574d5a2c4f07bed91d9682e4f48e655e88e37498.tar.gz misplays-574d5a2c4f07bed91d9682e4f48e655e88e37498.zip |
Implement support for PTRACE_EVENT_FORK and ui
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'misplays.c')
-rw-r--r-- | misplays.c | 115 |
1 files changed, 59 insertions, 56 deletions
@@ -160,9 +160,17 @@ static void layout(struct list *processes, struct thread *th) { reset_panel(right, LINES-2, COLS-w, 1, w); clear(); - attron(COLOR_PAIR(1)); for (struct process *proc = processes->head; proc != processes->end; proc = proc->next) { + if (th->proc == proc) { + attron(COLOR_PAIR(1)); + printw("{ "); + } else { + attron(COLOR_PAIR(4)); + printw("{ "); + attroff(COLOR_PAIR(4)); + } + struct list *threads = &proc->threads; for (struct thread *t = threads->head; t != threads->end; t = t->next) { if (t == th) { @@ -172,11 +180,22 @@ static void layout(struct list *processes, struct thread *th) { if (t == th) { printw("**"); } - printw(" "); + + if (t->next != threads->end) { + printw(" "); + } } - } - attroff(COLOR_PAIR(1)); + + if (th->proc == proc) { + printw(" } "); + attroff(COLOR_PAIR(1)); + } else { + attron(COLOR_PAIR(4)); + printw(" } "); + attroff(COLOR_PAIR(4)); + } + } } int main(int argc, char **argv) { @@ -276,18 +295,41 @@ int main(int argc, char **argv) { break; case 't': proc = th->proc; - do { - th = th->next; - } while (th == proc->threads.end); + th = th->next; + if (th == proc->threads.end) { + do { + proc = proc->next; + } while (proc == processes.end); + th = proc->threads.head; + } layout(&processes, th); break; case 'T': proc = th->proc; - do { - th = th->prev; - } while (th == proc->threads.end); + th = th->prev; + if (th == proc->threads.end) { + do { + proc = proc->prev; + } while (proc == processes.end); + th = proc->threads.tail; + } layout(&processes, th); - break; /* todo: next/prev process bindings */ + break; + case 'd': + proc = th->proc; + if (proc->child) { + break; + } + if (proc->prev == proc->next) { + break; + } + struct process *del = proc; + do { + proc = proc->next; + } while (proc == processes.end); + th = proc->threads.head; + dbg_detach(del); + break; case ':': mvprintw(LINES-1, 0, ":"); curs_set(TRUE); @@ -338,51 +380,12 @@ int main(int argc, char **argv) { } } - dbg_detach(th->proc); /* todo: detach all procs */ + for (struct process *p = processes.head; p != processes.end; p = p->next) { + struct process *del = p; + p = p->prev; + dbg_detach(del); + } + endwin(); return EXIT_SUCCESS; } - - - - - - - - - - - - - - -//#include <errno.h> -//#include <signal.h> -//#include <string.h> -//#include <sys/ptrace.h> -//#include <sys/wait.h> -//#include <linux/ptrace.h> - -// //case 'd': -// // if (dbg->stopped) { -// // while (dbg->breaks.head != dbg->breaks.end) { -// // struct breakpoint *b = dbg->breaks.head; -// // list_remove(b); -// // free(b); -// // } -// // } -// // break; -// //case 'D': -// // if (dbg->stopped) { -// // if (ptrace(PTRACE_DETACH, dbg->id, NULL, NULL) < 0) { -// // pprintw(right, "PTRACE_DETACH: %s\n", strerror(errno)); -// // } -// // struct tracee *rm = dbg; -// // do { -// // dbg = dbg->next; -// // } while (dbg == tracees.end); -// // list_remove(rm); -// // dbg_free(rm); -// // free(rm); -// // } -// // break; |