all repos — mgba @ 1a694b0b56ac3ead10ff5dc281ee46985a593223

mGBA Game Boy Advance Emulator

Debugger: Fix change watchpoints (fixes #1947)
Vicki Pfau vi@endrift.com
Tue, 24 Nov 2020 00:21:37 -0800
commit

1a694b0b56ac3ead10ff5dc281ee46985a593223

parent

19b77189c8f2a5d2f9172845836fae1e05263763

M CHANGESCHANGES

@@ -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.hinclude/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.csrc/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.csrc/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;