Debugger: Fix change watchpoints (fixes #1947)

This commit is contained in:
Vicki Pfau 2020-11-24 00:21:37 -08:00
parent 19b77189c8
commit 1a694b0b56
4 changed files with 18 additions and 5 deletions

View File

@ -57,6 +57,7 @@ Other fixes:
- 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

View File

@ -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 {

View File

@ -106,17 +106,24 @@ static bool _checkWatchpoints(struct ARMDebugger* debugger, uint32_t address, st
}
}
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;

View File

@ -55,7 +55,11 @@ static bool _checkWatchpoints(struct SM83Debugger* debugger, uint16_t address, s
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;