From 1e0996c3959b5ed4642c4ec527dfa85b51dfae93 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Tue, 9 Apr 2019 23:59:05 +0200 Subject: [PATCH] gdb: simply gdbstate --- sysmodules/rosalina/include/gdb.h | 8 ++++---- sysmodules/rosalina/source/gdb.c | 1 - sysmodules/rosalina/source/gdb/net.c | 8 ++++---- sysmodules/rosalina/source/gdb/server.c | 3 +++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/sysmodules/rosalina/include/gdb.h b/sysmodules/rosalina/include/gdb.h index 731d175..796af70 100644 --- a/sysmodules/rosalina/include/gdb.h +++ b/sysmodules/rosalina/include/gdb.h @@ -61,9 +61,10 @@ typedef enum GDBFlags { GDB_FLAG_SELECTED = 1, GDB_FLAG_USED = 2, - GDB_FLAG_PROCESS_CONTINUING = 4, - GDB_FLAG_TERMINATE_PROCESS = 8, - GDB_FLAG_ATTACHED_AT_START = 16, + GDB_FLAG_NOACK = 4, + GDB_FLAG_PROCESS_CONTINUING = 8, + GDB_FLAG_TERMINATE_PROCESS = 16, + GDB_FLAG_ATTACHED_AT_START = 32, } GDBFlags; typedef enum GDBState @@ -71,7 +72,6 @@ typedef enum GDBState GDB_STATE_DISCONNECTED, GDB_STATE_CONNECTED, GDB_STATE_NOACK_SENT, - GDB_STATE_NOACK, GDB_STATE_DETACHING } GDBState; diff --git a/sysmodules/rosalina/source/gdb.c b/sysmodules/rosalina/source/gdb.c index 1b75c94..4f0db59 100644 --- a/sysmodules/rosalina/source/gdb.c +++ b/sysmodules/rosalina/source/gdb.c @@ -178,7 +178,6 @@ void GDB_DetachFromProcess(GDBContext *ctx) ctx->nbThreads = 0; ctx->totalNbCreatedThreads = 0; memset(ctx->threadInfos, 0, sizeof(ctx->threadInfos)); - ctx->catchThreadEvents = false; } GDB_DECLARE_HANDLER(Unsupported) diff --git a/sysmodules/rosalina/source/gdb/net.c b/sysmodules/rosalina/source/gdb/net.c index e5a334e..9508347 100644 --- a/sysmodules/rosalina/source/gdb/net.c +++ b/sysmodules/rosalina/source/gdb/net.c @@ -141,7 +141,7 @@ int GDB_ReceivePacket(GDBContext *ctx) return -1; if(ctx->buffer[0] == '+') // GDB sometimes acknowleges TCP acknowledgment packets (yes...). IDA does it properly { - if(ctx->state == GDB_STATE_NOACK) + if(ctx->flags & GDB_FLAG_NOACK) return -1; // Consume it @@ -193,7 +193,7 @@ int GDB_ReceivePacket(GDBContext *ctx) ctx->commandEnd = ctx->buffer; } - if(ctx->state >= GDB_STATE_CONNECTED && ctx->state < GDB_STATE_NOACK) + if(!(ctx->flags & GDB_FLAG_NOACK)) { int r2 = soc_send(ctx->super.sockfd, "+", 1, 0); if(r2 != 1) @@ -201,12 +201,12 @@ int GDB_ReceivePacket(GDBContext *ctx) } if(ctx->state == GDB_STATE_NOACK_SENT) - ctx->state = GDB_STATE_NOACK; + ctx->flags |= GDB_FLAG_NOACK; return r; packet_error: - if(ctx->state >= GDB_STATE_CONNECTED && ctx->state < GDB_STATE_NOACK) + if(!(ctx->flags & GDB_FLAG_NOACK)) { r = soc_send(ctx->super.sockfd, "-", 1, 0); if(r != 1) diff --git a/sysmodules/rosalina/source/gdb/server.c b/sysmodules/rosalina/source/gdb/server.c index f98c0fc..a34e64e 100644 --- a/sysmodules/rosalina/source/gdb/server.c +++ b/sysmodules/rosalina/source/gdb/server.c @@ -205,6 +205,9 @@ void GDB_ReleaseClient(GDBServer *server, GDBContext *ctx) ctx->enableExternalMemoryAccess = false; ctx->flags = (GDBFlags)0; ctx->state = GDB_STATE_DISCONNECTED; + + ctx->catchThreadEvents = false; + RecursiveLock_Unlock(&ctx->lock); }