diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index dc7a12cb30..7abbad7aad 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -28,6 +28,10 @@ std::map DisassemblyManager::entries; DebugInterface* DisassemblyManager::cpu; +bool isInInterval(u32 start, u32 size, u32 value) +{ + return start <= value && value < start+size; +} void parseDisasm(const char* disasm, char* opcode, char* arguments, bool insertSymbols) { @@ -170,6 +174,21 @@ DisassemblyLineInfo DisassemblyManager::getLine(u32 address, bool insertSymbols) return result; } +u32 DisassemblyManager::getStartAddress(u32 address) +{ + auto it = findDisassemblyEntry(entries,address,false); + if (it == entries.end()) + { + analyze(address,1); + it = findDisassemblyEntry(entries,address,false); + if (it == entries.end()) + return address; + } + + DisassemblyEntry* entry = it->second; + int line = entry->getLineNum(address,true); + return entry->getLineAddress(line); +} u32 DisassemblyManager::getNthPreviousAddress(u32 address, int n) { @@ -510,7 +529,7 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest) case MACRO_LI: case MACRO_MEMORYIMM: dest.name = name; - sprintf(buffer,"%s,%08X",DisassemblyManager::getCpu()->GetRegName(0,rt),immediate); + sprintf(buffer,"%s,0x%08X",DisassemblyManager::getCpu()->GetRegName(0,rt),immediate); dest.params = buffer; break; default: diff --git a/Core/Debugger/DisassemblyManager.h b/Core/Debugger/DisassemblyManager.h index 0655966dfd..ff7aa15d5f 100644 --- a/Core/Debugger/DisassemblyManager.h +++ b/Core/Debugger/DisassemblyManager.h @@ -143,4 +143,6 @@ private: DisassemblyEntry* getEntry(u32 address); static std::map entries; static DebugInterface* cpu; -}; \ No newline at end of file +}; + +bool isInInterval(u32 start, u32 size, u32 value); \ No newline at end of file diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index bdbf4f4850..02d32b0b3b 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -503,7 +503,7 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) COLORREF backgroundColor = whiteBackground ? 0xFFFFFF : debugger->getColor(address); COLORREF textColor = 0x000000; - if (address == debugger->getPC()) + if (isInInterval(address,line.totalSize,debugger->getPC())) { backgroundColor = scaleColor(backgroundColor,1.05f); } @@ -545,8 +545,8 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) char addressText[64]; getDisasmAddressText(address,addressText,true); TextOutA(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText)); - - if (address == debugger->getPC()) + + if (isInInterval(address,line.totalSize,debugger->getPC())) { TextOut(hdc,pixelPositions.opcodeStart-8,rowY1,L"■",1); } diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h index edfe640d9c..3f9c969f82 100644 --- a/Windows/Debugger/CtrlDisAsmView.h +++ b/Windows/Debugger/CtrlDisAsmView.h @@ -133,6 +133,7 @@ public: u32 getWindowEnd() { return windowStart+visibleRows*instructionSize; }; void gotoAddr(unsigned int addr) { + addr = manager.getStartAddress(addr); u32 windowEnd = windowStart+visibleRows*instructionSize; u32 newAddress = addr&(~(instructionSize-1)); @@ -175,6 +176,7 @@ public: void setCurAddress(u32 newAddress, bool extend = false) { + newAddress = manager.getStartAddress(newAddress); u32 after = manager.getNthNextAddress(newAddress,1); curAddress = newAddress; selectRangeStart = extend ? std::min(selectRangeStart, newAddress) : newAddress; diff --git a/Windows/Debugger/DumpMemoryWindow.cpp b/Windows/Debugger/DumpMemoryWindow.cpp index 6a77a0e2fa..c5b1035a05 100644 --- a/Windows/Debugger/DumpMemoryWindow.cpp +++ b/Windows/Debugger/DumpMemoryWindow.cpp @@ -100,7 +100,7 @@ INT_PTR CALLBACK DumpMemoryWindow::dlgFunc(HWND hwnd, UINT iMsg, WPARAM wParam, return FALSE; } -bool isInInterval(u32 start, u32 end, u32 value) +static bool isInInterval(u32 start, u32 end, u32 value) { return start <= value && value < end; }