Skip to content

Commit 485cc4c

Browse files
committed
Change ThreadPlanStepOut::ShouldStop to only stop when we've hit
the breakpoint. Being in the correct stack frame is not sufficient. Fixing the case of hitting a breakpoint on the last instruction of a function and doing `finish`. A ThreadPlanStepOut is pushed, the thread is set to eStateRunning, and then because we're at a breakpoint site that we've hit, a ThreadPlanStepOverBreakpoint is pushed on the thread plan stack. It sets itself to AutoContinue==true because the thread state is eStateRunning. We instruction step past the breakpoint, stop with stop reason `trace`. ThreadPlanStepOverBreakpoint has completed, and it says that we should AutoContinue. ThreadPlanStepOut detects that it is now in the stack frame it wanted to step to -- does not check whether it hit its breakpoint -- and pulls it self off the stack, removes its breakpoint. We resume execution via the ThreadPlanStepOverBreakpoint's AutoContinue, and there is now no breakpoint for ThreadPlanStepOut - we lose control of the process. Instead, until we hit the ThreadPlanStepOut breakpoint, we say that it has not completed. So now in this scenario of a breakpoint hit on the last instruction and "finish", we instruction step, then continue the thread and immediately hit the ThreadPlanStepOut breakpoint that we're sitting at (but have not yet executed). This fixes the llvm-mingw test failure that Martin reported, and I captured in the new API test TestEmptyFuncThreadStepOut.py.
1 parent 55dc83e commit 485cc4c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lldb/source/Target/ThreadPlanStepOut.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,12 @@ bool ThreadPlanStepOut::ShouldStop(Event *event_ptr) {
364364
}
365365

366366
if (!done) {
367-
StackID frame_zero_id = GetThread().GetStackFrameAtIndex(0)->GetStackID();
368-
done = !(frame_zero_id < m_step_out_to_id);
367+
StopInfoSP stop_info_sp = GetPrivateStopInfo();
368+
if (stop_info_sp.get() &&
369+
stop_info_sp->GetStopReason() == eStopReasonBreakpoint) {
370+
StackID frame_zero_id = GetThread().GetStackFrameAtIndex(0)->GetStackID();
371+
done = !(frame_zero_id < m_step_out_to_id);
372+
}
369373
}
370374

371375
// The normal step out computations think we are done, so all we need to do

0 commit comments

Comments
 (0)