Attempt to make gdb server to exit gracefully

This commit is contained in:
Xavier Del Campo Romero 2020-06-08 00:21:35 +02:00
parent aa89de282b
commit 5676534ec1
3 changed files with 13 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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();