Debugger: Auto-refresh disassembly when debugger gains focus

This allows edits done in the hex editor to be shown right away in the debugger
+ Also fixed a potential issue with code in save ram not being disassembled properly after the code is updated by additional writes
This commit is contained in:
Sour 2020-02-01 10:10:57 -05:00
parent 135ffc56a5
commit 19b93dc343
3 changed files with 17 additions and 14 deletions

View file

@ -762,8 +762,6 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
AddressTypeInfo addressInfo;
GetAbsoluteAddressAndType(addr, &addressInfo);
int32_t absoluteAddr = addressInfo.Type == AddressType::PrgRom ? addressInfo.Address : -1;
int32_t absoluteRamAddr = addressInfo.Type == AddressType::WorkRam ? addressInfo.Address : -1;
if(addressInfo.Address >= 0 && type != MemoryOperationType::DummyRead && type != MemoryOperationType::DummyWrite && _runToCycle == -1) {
//Ignore dummy read/writes and do not change counters while using the step back feature
if(type == MemoryOperationType::Write && CheckFlag(DebuggerFlags::IgnoreRedundantWrites)) {
@ -779,21 +777,17 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
}
}
}
}
if(absoluteAddr >= 0) {
if(type == MemoryOperationType::ExecOperand) {
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::Code);
} else if(type == MemoryOperationType::Read) {
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::Data);
if(isDmcRead) {
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::PcmData);
if(addressInfo.Type == AddressType::PrgRom) {
if(type == MemoryOperationType::ExecOperand) {
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::Code);
} else if(type == MemoryOperationType::Read) {
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::Data);
if(isDmcRead) {
_codeDataLogger->SetFlag(absoluteAddr, CdlPrgFlags::PcmData);
}
}
}
} else if(addr < 0x2000 || absoluteRamAddr >= 0) {
if(type == MemoryOperationType::Write) {
_disassembler->InvalidateCache(addressInfo);
}
}
if(type == MemoryOperationType::ExecOpCode) {
@ -910,6 +904,8 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
_currentReadValue = nullptr;
if(type == MemoryOperationType::Write) {
_disassembler->InvalidateCache(addressInfo);
if(addr >= 0x2000 && addr <= 0x3FFF) {
if((addr & 0x07) == 5 || (addr & 0x07) == 6) {
GetState(&_debugState, false);

View file

@ -262,6 +262,10 @@ uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bo
void Disassembler::InvalidateCache(AddressTypeInfo &info)
{
if(info.Address < 0) {
return;
}
int32_t addr;
vector<shared_ptr<DisassemblyInfo>> *cache = nullptr;

View file

@ -338,6 +338,9 @@ namespace Mesen.GUI.Debugger
if(ConfigManager.Config.DebugInfo.BreakOnDebuggerFocus && !InteropEmu.DebugIsExecutionStopped()) {
InteropEmu.DebugStep(1, BreakSource.BreakOnFocus);
}
//Refresh debugger in case memory has been changed by the memory tools, etc
UpdateDebugger(false, false);
}
private void ctrlProfiler_OnFunctionSelected(object sender, EventArgs e)