Debugger: Fix change watchpoints (fixes #1947)
Vicki Pfau vi@endrift.com
Tue, 24 Nov 2020 00:21:37 -0800
4 files changed,
18 insertions(+),
5 deletions(-)
M
CHANGES
→
CHANGES
@@ -57,6 +57,7 @@ - Core: Ensure ELF regions can be written before trying
- Core: Fix threading improperly setting paused state while interrupted - Debugger: Don't skip undefined instructions when debugger attached - Debugger: Close trace log when done tracing + - Debugger: Fix change watchpoints (fixes mgba.io/i/1947) - FFmpeg: Fix some small memory leaks - FFmpeg: Fix encoding of time base - GB Video: Fix SGB video logs
M
include/mgba/debugger/debugger.h
→
include/mgba/debugger/debugger.h
@@ -38,7 +38,8 @@ enum mWatchpointType {
WATCHPOINT_WRITE = 1, WATCHPOINT_READ = 2, WATCHPOINT_RW = 3, - WATCHPOINT_WRITE_CHANGE = 4, + WATCHPOINT_CHANGE = 4, + WATCHPOINT_WRITE_CHANGE = 5, }; enum mBreakpointType {
M
src/arm/debugger/memory-debugger.c
→
src/arm/debugger/memory-debugger.c
@@ -106,17 +106,24 @@ return false;
} } + uint32_t oldValue; switch (width + 1) { case 1: - info->type.wp.oldValue = debugger->originalMemory.load8(debugger->cpu, address, 0); + oldValue = debugger->originalMemory.load8(debugger->cpu, address, 0); break; case 2: - info->type.wp.oldValue = debugger->originalMemory.load16(debugger->cpu, address, 0); + oldValue = debugger->originalMemory.load16(debugger->cpu, address, 0); break; case 4: - info->type.wp.oldValue = debugger->originalMemory.load32(debugger->cpu, address, 0); + oldValue = debugger->originalMemory.load32(debugger->cpu, address, 0); break; + default: + continue; } + if ((watchpoint->type & WATCHPOINT_CHANGE) && newValue == oldValue) { + continue; + } + info->type.wp.oldValue = oldValue; info->type.wp.newValue = newValue; info->address = address; info->type.wp.watchType = watchpoint->type;
M
src/sm83/debugger/memory-debugger.c
→
src/sm83/debugger/memory-debugger.c
@@ -55,7 +55,11 @@ if (!mDebuggerEvaluateParseTree(debugger->d.p, watchpoint->condition, &value, &segment) || !(value || segment >= 0)) {
return false; } } - info->type.wp.oldValue = debugger->originalMemory.load8(debugger->cpu, address); + uint8_t oldValue = debugger->originalMemory.load8(debugger->cpu, address); + if ((watchpoint->type & WATCHPOINT_CHANGE) && newValue == oldValue) { + continue; + } + info->type.wp.oldValue = oldValue; info->type.wp.newValue = newValue; info->address = address; info->type.wp.watchType = watchpoint->type;