summaryrefslogtreecommitdiffstats
path: root/misplays.c
diff options
context:
space:
mode:
Diffstat (limited to 'misplays.c')
-rw-r--r--misplays.c115
1 files changed, 59 insertions, 56 deletions
diff --git a/misplays.c b/misplays.c
index cda2abb..1ccf3d3 100644
--- a/misplays.c
+++ b/misplays.c
@@ -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;