Debugger: Add functions for read- or write-only watchpoints
Jeffrey Pfau jeffrey@endrift.com
Fri, 23 Dec 2016 15:40:24 -0800
2 files changed,
32 insertions(+),
1 deletions(-)
M
CHANGES
→
CHANGES
@@ -61,6 +61,7 @@ - 3DS, PSP2, Wii: Last directory loaded is saved
- GB Audio: Simplify envelope code - GB Audio: Improve initial envelope samples - GB Audio: Initialize wave RAM to GBC values + - Debugger: Add functions for read- or write-only watchpoints 0.5.1: (2016-10-05) Bugfixes:
M
src/debugger/cli-debugger.c
→
src/debugger/cli-debugger.c
@@ -40,6 +40,8 @@ static void _readWord(struct CLIDebugger*, struct CLIDebugVector*);
static void _setBreakpoint(struct CLIDebugger*, struct CLIDebugVector*); static void _clearBreakpoint(struct CLIDebugger*, struct CLIDebugVector*); static void _setWatchpoint(struct CLIDebugger*, struct CLIDebugVector*); +static void _setReadWatchpoint(struct CLIDebugger*, struct CLIDebugVector*); +static void _setWriteWatchpoint(struct CLIDebugger*, struct CLIDebugVector*); static void _writeByte(struct CLIDebugger*, struct CLIDebugVector*); static void _writeHalfword(struct CLIDebugger*, struct CLIDebugVector*); static void _writeWord(struct CLIDebugger*, struct CLIDebugVector*);@@ -81,6 +83,8 @@ { "w/1", _writeByte, CLIDVParse, "Write a byte at a specified offset" },
{ "w/2", _writeHalfword, CLIDVParse, "Write a halfword at a specified offset" }, { "w/4", _writeWord, CLIDVParse, "Write a word at a specified offset" }, { "watch", _setWatchpoint, CLIDVParse, "Set a watchpoint" }, + { "watch/r", _setReadWatchpoint, CLIDVParse, "Set a read watchpoint" }, + { "watch/w", _setWriteWatchpoint, CLIDVParse, "Set a write watchpoint" }, { "x/1", _dumpByte, CLIDVParse, "Examine bytes at a specified offset" }, { "x/2", _dumpHalfword, CLIDVParse, "Examine halfwords at a specified offset" }, { "x/4", _dumpWord, CLIDVParse, "Examine words at a specified offset" },@@ -376,7 +380,33 @@ debugger->backend->printf(debugger->backend, "Watchpoints are not supported by this platform.\n");
return; } uint32_t address = dv->intValue; - debugger->d.platform->setWatchpoint(debugger->d.platform, address, WATCHPOINT_RW); // TODO: ro/wo + debugger->d.platform->setWatchpoint(debugger->d.platform, address, WATCHPOINT_RW); +} + +static void _setReadWatchpoint(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { + if (!dv || dv->type != CLIDV_INT_TYPE) { + debugger->backend->printf(debugger->backend, "%s\n", ERROR_MISSING_ARGS); + return; + } + if (!debugger->d.platform->setWatchpoint) { + debugger->backend->printf(debugger->backend, "Watchpoints are not supported by this platform.\n"); + return; + } + uint32_t address = dv->intValue; + debugger->d.platform->setWatchpoint(debugger->d.platform, address, WATCHPOINT_READ); +} + +static void _setWriteWatchpoint(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { + if (!dv || dv->type != CLIDV_INT_TYPE) { + debugger->backend->printf(debugger->backend, "%s\n", ERROR_MISSING_ARGS); + return; + } + if (!debugger->d.platform->setWatchpoint) { + debugger->backend->printf(debugger->backend, "Watchpoints are not supported by this platform.\n"); + return; + } + uint32_t address = dv->intValue; + debugger->d.platform->setWatchpoint(debugger->d.platform, address, WATCHPOINT_WRITE); } static void _clearBreakpoint(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {