From 3f3ade62237098ec2ecc288111c0d75463ff9091 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 11 May 2013 19:08:09 -0400 Subject: [PATCH] Fix incorrect return value problem in STEP_OUT. A similar problem to that described in my previous commit afflicted the step out case as well. We now store the current IP when issuing a step out, and use that as the function address once execution returns. --- src/apps/debugger/controllers/ThreadHandler.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/apps/debugger/controllers/ThreadHandler.cpp b/src/apps/debugger/controllers/ThreadHandler.cpp index ebc4247e9d..5b79d148a5 100644 --- a/src/apps/debugger/controllers/ThreadHandler.cpp +++ b/src/apps/debugger/controllers/ThreadHandler.cpp @@ -269,6 +269,7 @@ ThreadHandler::HandleThreadAction(uint32 action) TRACE_CONTROL(" ip: %#" B_PRIx64 "\n", frame->InstructionPointer()); + target_addr_t frameIP = frame->GetCpuState()->InstructionPointer(); // When the thread is in a syscall, do the same for all step kinds: Stop it // when it returns by means of a breakpoint. if (frame->Type() == STACK_FRAME_TYPE_SYSCALL) { @@ -284,15 +285,14 @@ ThreadHandler::HandleThreadAction(uint32 action) // The second issue is that the temporary breakpoint is probably not necessary // anymore, since single-stepping over "syscall" instructions should just work // as expected. - status_t error = _InstallTemporaryBreakpoint( - frame->GetCpuState()->InstructionPointer()); + status_t error = _InstallTemporaryBreakpoint(frameIP); if (error != B_OK) { _StepFallback(); return; } fStepMode = STEP_OUT; - _RunThread(frame->GetCpuState()->InstructionPointer()); + _RunThread(frameIP); return; } @@ -303,9 +303,10 @@ ThreadHandler::HandleThreadAction(uint32 action) _StepFallback(); return; } + fPreviousInstructionPointer = frameIP; fPreviousFrameAddress = frame->FrameAddress(); fStepMode = STEP_OUT; - _RunThread(frame->GetCpuState()->InstructionPointer()); + _RunThread(frameIP); return; } @@ -324,7 +325,7 @@ ThreadHandler::HandleThreadAction(uint32 action) if (action == MSG_THREAD_STEP_INTO) { // step into fStepMode = STEP_INTO; - _SingleStepThread(frame->GetCpuState()->InstructionPointer()); + _SingleStepThread(frameIP); } else { fPreviousFrameAddress = frame->FrameAddress(); // step over @@ -648,7 +649,7 @@ ThreadHandler::_HandleBreakpointHitStep(CpuState* cpuState) " - step out adding return value\n", cpuState ->StackFramePointer(), fPreviousFrameAddress); ReturnValueInfo* info = new(std::nothrow) ReturnValueInfo( - cpuState->InstructionPointer(), cpuState); + fPreviousInstructionPointer, cpuState); if (info == NULL) return false; BReference infoReference(info, true);