Skip to content

Commit

Permalink
Debugger: Improve call stack/profiler behavior when dealing with some…
Browse files Browse the repository at this point in the history
… types of stack manipulation
  • Loading branch information
SourMesen committed Dec 17, 2024
1 parent 1e3422b commit c447eaf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Core/Debugger/CallstackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ void CallstackManager::Pop(AddressInfo& dest, uint32_t destAddress, uint32_t sta
}

if(!foundMatch) {
//Couldn't find a matching frame, replace the current one
Push(prevFrame.AbsReturn, returnAddr, dest, destAddress, prevFrame.AbsReturn, returnAddr, stackPointer, StackFrameFlags::None);
//Couldn't find a matching frame
//If the new stack pointer doesn't match the last frame, push a new frame for it
//Otherwise, presume that the code has returned to the last function on the stack
//This can happen in some patterns, e.g if putting call parameters after the JSR
//call, and manipulating the stack upon return to return to the code after the
//parameters.
if(_callstack.back().ReturnStackPointer != stackPointer) {
Push(prevFrame.AbsReturn, returnAddr, dest, destAddress, prevFrame.AbsReturn, returnAddr, stackPointer, StackFrameFlags::None);
}
}
}
}
Expand Down

0 comments on commit c447eaf

Please sign in to comment.