From 71df6af839d45c8b947b15d3b80167e68904e864 Mon Sep 17 00:00:00 2001 From: Felix Jones Date: Sun, 22 Jun 2025 17:13:58 +0200 Subject: [PATCH] GDB: Do not stop for jumps into BIOS when debug stepping code --- src/debugger/gdb-stub.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/debugger/gdb-stub.c b/src/debugger/gdb-stub.c index 6d419ac95..1e1fd35a5 100644 --- a/src/debugger/gdb-stub.c +++ b/src/debugger/gdb-stub.c @@ -255,7 +255,25 @@ static void _continue(struct GDBStub* stub, const char* message) { } static void _step(struct GDBStub* stub, const char* message) { + const struct ARMCore* cpu = stub->d.p->core->cpu; + const int32_t pc = cpu->gprs[ARM_PC]; + stub->d.p->core->step(stub->d.p->core); + + if (pc >= GBA_SIZE_BIOS && cpu->gprs[ARM_PC] < GBA_SIZE_BIOS) { + // GDB cannot cope with jumps into BIOS + // skip over them by placing a temporary breakpoint at PC (instruction after the jump) + // and then continue without sending a GDB SIGTRAP + const struct mBreakpoint breakpoint = { + .address = pc, + .type = BREAKPOINT_HARDWARE, + .isTemporary = true + }; + stub->d.p->platform->setBreakpoint(stub->d.p->platform, &stub->d, &breakpoint); + _continue(stub, message); + return; + } + snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGTRAP); _sendMessage(stub); // TODO: parse message