From ef7edba1594df4648f00de088592a2e014909f68 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Wed, 4 Oct 2023 16:05:40 +0100 Subject: [PATCH] Debugger: Fix interrupt after continue from GDB stub GDB and LLDB will send a ctrl-c character (\x03) to the stub to interrupt it after a continue where it doesn't stop on its own. E.g. ``` void foo() { foo2(); // Continue from here. while (1) {} // Loops here until ctrl-c in the debugger. } ``` mGBA had code to handle the ctrl-c but because in _continue we set the paused status after calling mDebuggerModuleSetNeedsCallback, the callback was never set so nothing was looking for new messages while we were running. We should instead set the paused state then call mDebuggerModuleSetNeedsCallback. mDebuggerModuleSetNeedsCallback calls mDebuggerUpdatePaused, and all other calls to mDebuggerUpdatePaused update the paused state before that call so this matches existing usage of that too. With this fix, after the continue _gdbStubPoll is called periodically and will pick up the ctrl-c as it comes in (_gdbStubWait is used when we are stopped in the debugger). This fixes ctrl-c to interrupt when using lldb and gdb. --- src/debugger/gdb-stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugger/gdb-stub.c b/src/debugger/gdb-stub.c index f16666fa2..1204f908a 100644 --- a/src/debugger/gdb-stub.c +++ b/src/debugger/gdb-stub.c @@ -247,9 +247,9 @@ static void _writeHostInfo(struct GDBStub* stub) { } static void _continue(struct GDBStub* stub, const char* message) { - mDebuggerModuleSetNeedsCallback(&stub->d); stub->untilPoll = GDB_STUB_INTERVAL; stub->d.isPaused = false; + mDebuggerModuleSetNeedsCallback(&stub->d); // TODO: parse message UNUSED(message); }