[Lldb-commits] [lldb] r219263 - Fix stepping over the inserted breakpoint trap when the NEXT instruction
Jim Ingham
jingham at apple.com
Tue Oct 7 18:03:54 PDT 2014
Author: jingham
Date: Tue Oct 7 20:03:54 2014
New Revision: 219263
URL: http://llvm.org/viewvc/llvm-project?rev=219263&view=rev
Log:
Fix stepping over the inserted breakpoint trap when the NEXT instruction
also contains a breakpoint.
<rdar://problem/18519712>
Modified:
lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp
Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h?rev=219263&r1=219262&r2=219263&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h Tue Oct 7 20:03:54 2014
@@ -35,6 +35,7 @@ public:
virtual void ThreadDestroyed ();
void SetAutoContinue (bool do_it);
virtual bool ShouldAutoContinue(Event *event_ptr);
+ virtual bool IsPlanStale();
protected:
virtual bool DoPlanExplainsStop (Event *event_ptr);
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=219263&r1=219262&r2=219263&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Oct 7 20:03:54 2014
@@ -943,30 +943,30 @@ Thread::ShouldStop (Event* event_ptr)
if (over_ride_stop)
should_stop = false;
- // One other potential problem is that we set up a master plan, then stop in before it is complete - for instance
- // by hitting a breakpoint during a step-over - then do some step/finish/etc operations that wind up
- // past the end point condition of the initial plan. We don't want to strand the original plan on the stack,
- // This code clears stale plans off the stack.
+ }
+
+ // One other potential problem is that we set up a master plan, then stop in before it is complete - for instance
+ // by hitting a breakpoint during a step-over - then do some step/finish/etc operations that wind up
+ // past the end point condition of the initial plan. We don't want to strand the original plan on the stack,
+ // This code clears stale plans off the stack.
- if (should_stop)
+ if (should_stop)
+ {
+ ThreadPlan *plan_ptr = GetCurrentPlan();
+ while (!PlanIsBasePlan(plan_ptr))
{
- ThreadPlan *plan_ptr = GetCurrentPlan();
- while (!PlanIsBasePlan(plan_ptr))
- {
- bool stale = plan_ptr->IsPlanStale ();
- ThreadPlan *examined_plan = plan_ptr;
- plan_ptr = GetPreviousPlan (examined_plan);
+ bool stale = plan_ptr->IsPlanStale ();
+ ThreadPlan *examined_plan = plan_ptr;
+ plan_ptr = GetPreviousPlan (examined_plan);
- if (stale)
- {
- if (log)
- log->Printf("Plan %s being discarded in cleanup, it says it is already done.",
- examined_plan->GetName());
- DiscardThreadPlansUpToPlan(examined_plan);
- }
+ if (stale)
+ {
+ if (log)
+ log->Printf("Plan %s being discarded in cleanup, it says it is already done.",
+ examined_plan->GetName());
+ DiscardThreadPlansUpToPlan(examined_plan);
}
}
-
}
if (log)
Modified: lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp?rev=219263&r1=219262&r2=219263&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp Tue Oct 7 20:03:54 2014
@@ -64,11 +64,33 @@ ThreadPlanStepOverBreakpoint::DoPlanExpl
StopInfoSP stop_info_sp = GetPrivateStopInfo ();
if (stop_info_sp)
{
+ // It's a little surprising that we stop here for a breakpoint hit. However, when you single step ONTO a breakpoint
+ // we still want to call that a breakpoint hit, and trigger the actions, etc. Otherwise you would see the
+ // PC at the breakpoint without having triggered the actions, then you'd continue, the PC wouldn't change,
+ // and you'd see the breakpoint hit, which would be odd.
+ // So the lower levels fake "step onto breakpoint address" and return that as a breakpoint. So our trace
+ // step COULD appear as a breakpoint hit if the next instruction also contained a breakpoint.
StopReason reason = stop_info_sp->GetStopReason();
- if (reason == eStopReasonTrace || reason == eStopReasonNone)
+
+ switch (reason)
+ {
+ case eStopReasonTrace:
+ case eStopReasonNone:
return true;
- else
+ case eStopReasonBreakpoint:
+ // It's a little surprising that we stop here for a breakpoint hit. However, when you single step ONTO a
+ // breakpoint we still want to call that a breakpoint hit, and trigger the actions, etc. Otherwise you
+ // would see the PC at the breakpoint without having triggered the actions, then you'd continue, the PC
+ // wouldn't change, and you'd see the breakpoint hit, which would be odd.
+ // So the lower levels fake "step onto breakpoint address" and return that as a breakpoint hit. So our trace
+ // step COULD appear as a breakpoint hit if the next instruction also contained a breakpoint. We don't want
+ // to handle that, since we really don't know what to do with breakpoint hits. But make sure we don't set
+ // ourselves to auto-continue or we'll wrench control away from the plans that can deal with this.
+ SetAutoContinue(false);
+ return false;
+ default:
return false;
+ }
}
return false;
}
@@ -76,7 +98,7 @@ ThreadPlanStepOverBreakpoint::DoPlanExpl
bool
ThreadPlanStepOverBreakpoint::ShouldStop (Event *event_ptr)
{
- return false;
+ return !ShouldAutoContinue(event_ptr);
}
bool
@@ -163,3 +185,10 @@ ThreadPlanStepOverBreakpoint::ShouldAuto
{
return m_auto_continue;
}
+
+bool
+ThreadPlanStepOverBreakpoint::IsPlanStale()
+{
+ return m_thread.GetRegisterContext()->GetPC() != m_breakpoint_addr;
+}
+
More information about the lldb-commits
mailing list