all repos — mgba @ 9cdc93eeedb8e5b462a48274160ebe752b6a2532

mGBA Game Boy Advance Emulator

Add watchpoints to gdb stub
Jeffrey Pfau jeffrey@endrift.com
Mon, 01 Sep 2014 02:24:00 -0700
commit

9cdc93eeedb8e5b462a48274160ebe752b6a2532

parent

21437e91f6d73c58f7980a12f1bc381be4f9471b

1 files changed, 22 insertions(+), 17 deletions(-)

jump to
M src/debugger/gdb-stub.csrc/debugger/gdb-stub.c

@@ -279,23 +279,27 @@ _sendMessage(stub);

} static void _setBreakpoint(struct GDBStub* stub, const char* message) { + const char* readAddress = &message[2]; + unsigned i = 0; + uint32_t address = _readHex(readAddress, &i); + readAddress += i + 1; + uint32_t kind = _readHex(readAddress, &i); // We don't use this in hardware watchpoints + UNUSED(kind); + switch (message[0]) { case '0': // Memory breakpoints are not currently supported - case '1': { - const char* readAddress = &message[2]; - unsigned i = 0; - uint32_t address = _readHex(readAddress, &i); - readAddress += i + 1; - uint32_t kind = _readHex(readAddress, &i); // We don't use this in hardware watchpoints - UNUSED(kind); + case '1': ARMDebuggerSetBreakpoint(&stub->d, address); strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4); _sendMessage(stub); break; - } case '2': case '3': - // TODO: Watchpoints + case '4': + ARMDebuggerSetWatchpoint(&stub->d, address); + strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4); + _sendMessage(stub); + break; default: stub->outgoing[0] = '\0'; _sendMessage(stub);

@@ -304,23 +308,24 @@ }

} static void _clearBreakpoint(struct GDBStub* stub, const char* message) { + const char* readAddress = &message[2]; + unsigned i = 0; + uint32_t address = _readHex(readAddress, &i); switch (message[0]) { case '0': // Memory breakpoints are not currently supported - case '1': { - const char* readAddress = &message[2]; - unsigned i = 0; - uint32_t address = _readHex(readAddress, &i); + case '1': ARMDebuggerClearBreakpoint(&stub->d, address); - strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4); - _sendMessage(stub); break; - } case '2': case '3': - // TODO: Watchpoints + case '4': + ARMDebuggerClearWatchpoint(&stub->d, address); + break; default: break; } + strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4); + _sendMessage(stub); } size_t _parseGDBMessage(struct GDBStub* stub, const char* message) {