diff --git a/sysmodules/rosalina/source/gdb/server.c b/sysmodules/rosalina/source/gdb/server.c index 9577b11..6b896ac 100644 --- a/sysmodules/rosalina/source/gdb/server.c +++ b/sysmodules/rosalina/source/gdb/server.c @@ -246,9 +246,6 @@ GDBContext *GDB_GetClient(GDBServer *server, u16 port) return NULL; } - if (ctx->localPort == GDB_PORT_BASE + MAX_DEBUG) - TaskRunner_WaitReady(); // Finish grabbing new process debug, if anything... - ctx->flags |= GDB_FLAG_USED; ctx->state = GDB_STATE_CONNECTED; ctx->parent = server; @@ -273,6 +270,20 @@ GDBContext *GDB_GetClient(GDBServer *server, u16 port) } GDB_UnlockAllContexts(server); + if (port == GDB_PORT_BASE + MAX_DEBUG) + { + // this is not sufficient/foolproof and is buggy: TaskRunner_WaitReady(); // Finish grabbing new process debug, if anything... + bool ok = false; + do + { + svcSleepThread(5 * 1000 * 1000LL); + RecursiveLock_Lock(&ctx->lock); + ok = ctx->debug != 0; + RecursiveLock_Unlock(&ctx->lock); + } + while (!ok); + } + return ctx; }