summaryrefslogtreecommitdiff
path: root/gdbstub
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-06-08 00:21:35 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2020-06-08 00:21:35 +0200
commit5676534ec1452864f8fac1de2f494195ebe5908b (patch)
treeb3cb0a80556723226d4a0f07d1647460c5f06865 /gdbstub
parentaa89de282b092a6ffd5995add48ee366a1ead119 (diff)
Attempt to make gdb server to exit gracefully
Diffstat (limited to 'gdbstub')
-rw-r--r--gdbstub/gdbstub_sys.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdbstub/gdbstub_sys.c b/gdbstub/gdbstub_sys.c
index 00b78f10..ca8dd2db 100644
--- a/gdbstub/gdbstub_sys.c
+++ b/gdbstub/gdbstub_sys.c
@@ -81,6 +81,11 @@ int dbg_sys_getc(void)
size_t len = sizeof packet;
const enum read_socket_err err = ReadSocket(client_socket, &packet, &len);
+#ifdef _POSIX_VERSION
+ if (exit_loop)
+ pthread_exit(NULL);
+#endif
+
switch (err) {
case READ_SOCKET_OK:
return packet;
@@ -130,6 +135,9 @@ static int wait_hit_or_break(struct msg *msg)
do {
int ret = mq_receive(in_queue, (char *)msg, sizeof *msg, 0);
+ if (exit_loop)
+ return 1;
+
if (ret < 0 && errno == EAGAIN) {
/* Breakpoint has not been hit yet, look for incoming messages from gdb. */
char packet;
@@ -213,6 +221,9 @@ static int wait_ack(struct msg *msg)
int ret;
do {
+ if (exit_loop)
+ return 1;
+
ret = mq_receive(in_queue, (char *)msg, sizeof *msg, 0);
} while (ret < 0 && errno == EAGAIN);