diff options
author | Jim Ingham <jingham@apple.com> | 2012-05-03 21:19:36 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2012-05-03 21:19:36 +0000 |
commit | 64e7ead1d817540a4ba4887da6c8a049788beee7 (patch) | |
tree | 27583d78171eaf9db61b80e658bed00eb5c2c637 /lldb/source/Target/Thread.cpp | |
parent | 60d835fa597c86c88dc2c7bfec399395d4d43f8b (diff) | |
download | bcm5719-llvm-64e7ead1d817540a4ba4887da6c8a049788beee7.tar.gz bcm5719-llvm-64e7ead1d817540a4ba4887da6c8a049788beee7.zip |
Clean up the usage of "MasterPlan" status in ThreadPlans. Only user-initiated plans
should be MasterPlans that want to stay on the plan stack. So make all plans NOT
MasterPlans by default and then have the SB API's and the CommandObjectThread step
commands set this explicitly.
Also added a "clean up" phase to the Thread::ShouldStop so that if plans get stranded
on the stack, we can remove them. This is done by adding an IsPlanStale method to the
thread plans, and if the plan can know that it is no longer relevant, it returns true,
and the plan and its sub-plans will get discarded.
llvm-svn: 156101
Diffstat (limited to 'lldb/source/Target/Thread.cpp')
-rw-r--r-- | lldb/source/Target/Thread.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index aaec66576d2..9429bfdb623 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -455,8 +455,33 @@ 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. + + if (should_stop) + { + ThreadPlan *plan_ptr = GetCurrentPlan(); + while (!PlanIsBasePlan(plan_ptr)) + { + 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 (log) @@ -750,10 +775,16 @@ Thread::SetTracer (lldb::ThreadPlanTracerSP &tracer_sp) void Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp) { + DiscardThreadPlansUpToPlan (up_to_plan_sp.get()); +} + +void +Thread::DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr) +{ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (log) { - log->Printf("Discarding thread plans for thread tid = 0x%4.4llx, up to %p", GetID(), up_to_plan_sp.get()); + log->Printf("Discarding thread plans for thread tid = 0x%4.4llx, up to %p", GetID(), up_to_plan_ptr); } int stack_size = m_plan_stack.size(); @@ -761,7 +792,7 @@ Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp) // If the input plan is NULL, discard all plans. Otherwise make sure this plan is in the // stack, and if so discard up to and including it. - if (up_to_plan_sp.get() == NULL) + if (up_to_plan_ptr == NULL) { for (int i = stack_size - 1; i > 0; i--) DiscardPlan(); @@ -771,7 +802,7 @@ Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp) bool found_it = false; for (int i = stack_size - 1; i > 0; i--) { - if (m_plan_stack[i] == up_to_plan_sp) + if (m_plan_stack[i].get() == up_to_plan_ptr) found_it = true; } if (found_it) @@ -779,7 +810,7 @@ Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp) bool last_one = false; for (int i = stack_size - 1; i > 0 && !last_one ; i--) { - if (GetCurrentPlan() == up_to_plan_sp.get()) + if (GetCurrentPlan() == up_to_plan_ptr) last_one = true; DiscardPlan(); } |