summaryrefslogtreecommitdiff
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
parentaa89de282b092a6ffd5995add48ee366a1ead119 (diff)
downloadpcsxr-5676534ec1452864f8fac1de2f494195ebe5908b.tar.gz
Attempt to make gdb server to exit gracefully
-rw-r--r--gdbstub/gdbstub_sys.c11
-rw-r--r--gui/LnxMain.c3
-rw-r--r--win32/gui/WndMain.c3
3 files changed, 13 insertions, 4 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);
diff --git a/gui/LnxMain.c b/gui/LnxMain.c
index 2e087ee3..4af1100d 100644
--- a/gui/LnxMain.c
+++ b/gui/LnxMain.c
@@ -466,8 +466,6 @@ int main(int argc, char *argv[]) {
psxCpu->Execute();
}
- if (Config.GdbServer) dbg_stop();
-
return 0;
}
@@ -515,6 +513,7 @@ void SysClose() {
ReleasePlugins();
StopDebugger();
+ if (Config.GdbServer) dbg_stop();
if (emuLog != NULL) fclose(emuLog);
}
diff --git a/win32/gui/WndMain.c b/win32/gui/WndMain.c
index 6f7d0749..5602f41a 100644
--- a/win32/gui/WndMain.c
+++ b/win32/gui/WndMain.c
@@ -244,8 +244,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
RunGui();
- if (Config.GdbServer) dbg_stop();
-
return 0;
}
@@ -2018,6 +2016,7 @@ void SysClose() {
ReleasePlugins();
StopDebugger();
+ if (Config.GdbServer) dbg_stop();
if (Config.PsxOut) CloseConsole();