m3dev

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 166f335337989ee9ac1c92a5f126c4d0b9d49f70
parent d979098fd07f9d2a78f6c3c120683b1e682d21bc
Author: Brian Swetland <swetland@frotz.net>
Date:   Tue, 23 Jun 2015 21:57:49 -0700

debugger: straighten out locking, fix display corruption

Diffstat:
Mtools/debugger-core.c | 12+++---------
Mtools/gdb-bridge.c | 9+++++++--
2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/tools/debugger-core.c b/tools/debugger-core.c @@ -114,22 +114,14 @@ static pthread_t _listen_master; void *gdb_listener(void *arg) { int fd; if ((fd = socket_listen_tcp(5555)) < 0) { - linenoisePause(); - xprintf("gdb_listener() cannot bind to 5555\n"); - linenoiseResume(); + fprintf(stderr, "gdb_listener() cannot bind to 5555\n"); return NULL; } for (;;) { int s = accept(fd, NULL, NULL); if (s >= 0) { - linenoisePause(); - xprintf("[ gdb connected ]\n"); - linenoiseResume(); gdb_server(s); close(s); - linenoisePause(); - xprintf("[ gdb disconnected ]\n"); - linenoiseResume(); } } return NULL; @@ -430,7 +422,9 @@ static int _debugger_exec(const char *cmd, unsigned argc, param *argv) { if (!strcasecmp(cmd, c->name)) { int n; debugger_lock(); + linenoisePause(); n = c->func(argc, argv); + linenoiseResume(); debugger_unlock(); return n; } diff --git a/tools/gdb-bridge.c b/tools/gdb-bridge.c @@ -284,7 +284,7 @@ static void handle_query(struct gdbcnxn *gc, char *cmd, char *args) { p+=2; } *cmd = 0; - zprintf("GBD: %s\n", p); + zprintf("GDB: %s\n", args); debugger_unlock(); debugger_command(args); debugger_lock(); @@ -580,6 +580,7 @@ void gdb_server(int fd) { if (pipefds[0] == -1) { if (pipe(pipefds)) ; } + zprintf("[ gdb connected ]\n"); debugger_unlock(); // gc.flags |= F_TRACE; @@ -623,7 +624,7 @@ void gdb_server(int fd) { r = read(fd, iobuf, sizeof(iobuf)); if (r <= 0) { if (errno == EINTR) continue; - return; + break; } len = r; ptr = iobuf; @@ -638,4 +639,8 @@ void gdb_server(int fd) { if (read(fds[1].fd, &x, 1) < 0) ; } } + + debugger_lock(); + zprintf("[ gdb connected ]\n"); + debugger_unlock(); }