diff options
-rw-r--r-- | console.c | 9 | ||||
-rw-r--r-- | console.h | 2 | ||||
-rw-r--r-- | debugger.c | 4 | ||||
-rw-r--r-- | debugger.h | 2 | ||||
-rw-r--r-- | misplays.c | 29 |
5 files changed, 32 insertions, 14 deletions
@@ -55,11 +55,12 @@ void console_leave(struct console *cons, PANEL *pan) { cbreak(); } -void console_update(struct console *cons, PANEL *pan) { - ssize_t nb; +int console_update(struct console *cons, PANEL *pan) { char c; + int did_read = 0; - while ((nb = read(cons->master, &c, 1)) > 0) { + while (read(cons->master, &c, 1) > 0) { + did_read = 1; if (!cons->isesc) { if (c == 0x1b) { cons->isesc = 1; @@ -72,6 +73,8 @@ void console_update(struct console *cons, PANEL *pan) { } } } + + return did_read; } void console_input(struct console *cons, int ch) { @@ -11,7 +11,7 @@ extern int console_init(struct console *cons); extern int console_deinit(struct console *cons); extern void console_enter(struct console *cons, PANEL *pan); extern void console_leave(struct console *cons, PANEL *pan); -extern void console_update(struct console *cons, PANEL *pan); +extern int console_update(struct console *cons, PANEL *pan); extern void console_input(struct console *cons, int ch); extern int console_configslave(struct console *cons); @@ -546,7 +546,7 @@ int dbg_free(struct thread *th) { return -1; } -void dbg_sync(struct process *proc) { +int dbg_sync(struct process *proc) { struct thread *acted = NULL; struct list *threads = &proc->threads; @@ -566,6 +566,8 @@ void dbg_sync(struct process *proc) { capture_state(proc); resume_threads(proc); } + + return acted != NULL; } int dbg_intr(struct thread *th) { @@ -67,7 +67,7 @@ extern struct process *dbg_attach(pid_t pid, int child); extern void dbg_detach(struct process *proc); extern int dbg_free(struct thread *th); -extern void dbg_sync(struct process *proc); +extern int dbg_sync(struct process *proc); extern int dbg_intr(struct thread *th); extern int dbg_cont(struct thread *th); @@ -193,10 +193,12 @@ static void info_update(struct thread *th, PANEL *pan) { disasm(th, pan); } -static void wait_all_threads(struct list *processes) { +static int wait_all_threads(struct list *processes) { + int action = 0; for (struct process *proc = processes->head; proc != processes->end; proc = proc->next) { - dbg_sync(proc); + action |= dbg_sync(proc); } + return action; } static void layout(struct list *processes, struct thread *th) { @@ -286,14 +288,11 @@ int main(int argc, char **argv) { int quit = 0; int mode = 0; + int dirty = 1; + int pressed = 0; while (!quit) { - wait_all_threads(&processes); - layout(&processes, th); - console_update(&cons, right); - info_update(th, left); - cursupdate(); - int ch = getch(); + pressed = 1; if (mode == 0) { switch (ch) { @@ -406,6 +405,9 @@ int main(int argc, char **argv) { b->enabled = en; b->tid = tid; break; + case ERR: + pressed = 0; + break; } } else { switch (ch) { @@ -417,12 +419,23 @@ int main(int argc, char **argv) { console_leave(&cons, right); break; case ERR: + pressed = 0; break; default: console_input(&cons, ch); break; } } + + dirty |= wait_all_threads(&processes); + dirty |= console_update(&cons, right); + + if (dirty || pressed) { + layout(&processes, th); + info_update(th, left); + cursupdate(); + dirty = 0; + } } for (struct process *p = processes.head; p != processes.end; p = p->next) { |