From 0f84c2e9952c37c752a42133004303035e41e454 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 24 Apr 2018 12:25:41 -0700 Subject: [PATCH] Debugger: Consistently handle invalid addresses. --- Core/Debugger/DisassemblyManager.cpp | 33 ++++++++++++++-------------- Core/MIPS/MIPSAnalyst.cpp | 1 + 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 4631c9e036..77e8c917a5 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -244,29 +244,28 @@ void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLin { analyze(address); it = findDisassemblyEntry(entries,address,false); - - if (it == entries.end()) - { - if (address % 4) - dest.totalSize = ((address+3) & ~3)-address; - else - dest.totalSize = 4; - dest.name = "ERROR"; - dest.params = "Disassembly failure"; - return; - } } - DisassemblyEntry* entry = it->second; - if (entry->disassemble(address,dest,insertSymbols)) - return; - + if (it != entries.end()) { + DisassemblyEntry *entry = it->second; + if (entry->disassemble(address, dest, insertSymbols)) + return; + } + + dest.type = DISTYPE_OTHER; + memset(&dest.info, 0, sizeof(dest.info)); + dest.info.opcodeAddress = address; if (address % 4) dest.totalSize = ((address+3) & ~3)-address; else dest.totalSize = 4; - dest.name = "ERROR"; - dest.params = "Disassembly failure"; + if (Memory::IsValidRange(address, 4)) { + dest.name = "ERROR"; + dest.params = "Disassembly failure"; + } else { + dest.name = "-"; + dest.params = ""; + } } u32 DisassemblyManager::getStartAddress(u32 address) diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 569f49df5a..43e5019a66 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1415,6 +1415,7 @@ skip: memset(&info, 0, sizeof(info)); if (!Memory::IsValidAddress(address)) { + info.opcodeAddress = address; return info; }