From f67acc2c72cf11d2f7cd478af67a6493984fd683 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 12 Dec 2011 08:41:45 -0500 Subject: [PATCH] Use architecture to determine correct frame pointer comparison. --- src/apps/debugger/ThreadHandler.cpp | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/apps/debugger/ThreadHandler.cpp b/src/apps/debugger/ThreadHandler.cpp index 9a5715565e..b2262f3411 100644 --- a/src/apps/debugger/ThreadHandler.cpp +++ b/src/apps/debugger/ThreadHandler.cpp @@ -572,21 +572,27 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) return false; case STEP_OUT: - { - // That's the return address, so we're done in theory, - // unless we're a recursive function. Check if we've actually - // exited the previous stack frame or not. - if (cpuState->StackFramePointer() <= fPreviousFrameAddress) { - status_t error = _InstallTemporaryBreakpoint( - cpuState->InstructionPointer()); - if (error != B_OK) - _StepFallback(); - else - _RunThread(cpuState->InstructionPointer()); - return true; - } - fPreviousFrameAddress = 0; + { + // That's the return address, so we're done in theory, + // unless we're a recursive function. Check if we've actually + // exited the previous stack frame or not. + target_addr_t framePointer = cpuState->StackFramePointer(); + bool hasExitedFrame = fDebuggerInterface->GetArchitecture() + ->StackGrowthDirection() == STACK_GROWTH_DIRECTION_POSITIVE + ? framePointer < fPreviousFrameAddress + : framePointer > fPreviousFrameAddress; + + if (!hasExitedFrame) { + status_t error = _InstallTemporaryBreakpoint( + cpuState->InstructionPointer()); + if (error != B_OK) + _StepFallback(); + else + _RunThread(cpuState->InstructionPointer()); + return true; } + fPreviousFrameAddress = 0; + } default: return false;