From 7ccf093a7e94bb42b7e1df26886b528e146b7e09 Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 25 Feb 2018 10:38:45 -0500 Subject: [PATCH] Debugger: Fixed callstack displaying incorrect data when breaking on a RTS instruction --- Core/Debugger.cpp | 9 ++++++--- Core/Debugger.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index 6b06960e..345f13b1 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -365,9 +365,10 @@ void Debugger::RemoveExcessCallstackEntries() } } -void Debugger::UpdateCallstack(uint32_t addr) +void Debugger::UpdateCallstack(uint8_t currentInstruction, uint32_t addr) { _hideTopOfCallstack = false; + if((_lastInstruction == 0x60 || _lastInstruction == 0x40) && !_callstackRelative.empty()) { //RTS & RTI _callstackRelative.pop_back(); @@ -376,7 +377,9 @@ void Debugger::UpdateCallstack(uint32_t addr) _callstackAbsolute.pop_back(); _profiler->UnstackFunction(); - } else if(_lastInstruction == 0x20) { + } + + if(currentInstruction == 0x20) { //JSR RemoveExcessCallstackEntries(); @@ -591,8 +594,8 @@ bool Debugger::PrivateProcessRamOperation(MemoryOperationType type, uint16_t &ad } } + UpdateCallstack(value, addr); _lastInstruction = value; - UpdateCallstack(addr); breakDone = SleepUntilResume(); diff --git a/Core/Debugger.h b/Core/Debugger.h index 3b01be2e..090d0d33 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -129,7 +129,7 @@ private: void PrivateProcessVramWriteOperation(uint16_t addr, uint8_t &value); void ProcessBreakpoints(BreakpointType type, OperationInfo &operationInfo, bool allowBreak = true); - void UpdateCallstack(uint32_t addr); + void UpdateCallstack(uint8_t currentInstruction, uint32_t addr); void PrivateProcessInterrupt(uint16_t cpuAddr, uint16_t destCpuAddr, bool forNmi); void ProcessStepConditions(uint32_t addr);