Rework how master plans declare themselves. Also make "PlanIsBasePlan" not rely only on this being the bottom plan in the stack, but allow the plan to declare itself as such.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154351 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h
index 7a11d02..77eb0a8 100644
--- a/include/lldb/Target/Thread.h
+++ b/include/lldb/Target/Thread.h
@@ -587,12 +587,8 @@
private:
bool
- PlanIsBasePlan (ThreadPlan *plan_ptr)
- {
- if (m_plan_stack.size() == 0)
- return false;
- return m_plan_stack[0].get() == plan_ptr;
- }
+ PlanIsBasePlan (ThreadPlan *plan_ptr);
+
public:
//------------------------------------------------------------------
diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h
index a814c46..090c473 100644
--- a/include/lldb/Target/ThreadPlan.h
+++ b/include/lldb/Target/ThreadPlan.h
@@ -334,10 +334,18 @@
virtual bool
WillStop () = 0;
- virtual bool
+ bool
IsMasterPlan()
{
- return false;
+ return m_is_master_plan;
+ }
+
+ bool
+ SetIsMasterPlan (bool value)
+ {
+ bool old_value = m_is_master_plan;
+ m_is_master_plan = value;
+ return old_value;
}
virtual bool
@@ -390,6 +398,12 @@
void
SetPlanComplete ();
+ virtual bool
+ IsBasePlan()
+ {
+ return false;
+ }
+
lldb::ThreadPlanTracerSP &
GetThreadPlanTracer()
{
@@ -474,6 +488,7 @@
bool m_plan_complete;
bool m_plan_private;
bool m_okay_to_discard;
+ bool m_is_master_plan;
lldb::ThreadPlanTracerSP m_tracer_sp;
diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h
index f89d1d6..3e941f3 100644
--- a/include/lldb/Target/ThreadPlanBase.h
+++ b/include/lldb/Target/ThreadPlanBase.h
@@ -14,6 +14,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -28,6 +29,7 @@
class ThreadPlanBase : public ThreadPlan
{
+friend class Process; // RunThreadPlan manages "stopper" base plans.
public:
virtual ~ThreadPlanBase ();
@@ -41,16 +43,17 @@
virtual bool MischiefManaged ();
virtual bool WillResume (lldb::StateType resume_state, bool current_plan);
- virtual bool IsMasterPlan()
- {
- return true;
- }
-
virtual bool OkayToDiscard()
{
return false;
}
+ virtual bool
+ IsBasePlan()
+ {
+ return true;
+ }
+
protected:
ThreadPlanBase (Thread &thread);
diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h
index dde1d67..d4f3d3e 100644
--- a/include/lldb/Target/ThreadPlanCallFunction.h
+++ b/include/lldb/Target/ThreadPlanCallFunction.h
@@ -80,12 +80,6 @@
virtual bool
MischiefManaged ();
- virtual bool
- IsMasterPlan()
- {
- return true;
- }
-
// To get the return value from a function call you must create a
// lldb::ValueSP that contains a valid clang type in its context and call
// RequestReturnValue. The ValueSP will be stored and when the function is
diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h
index 8190b81..39b1414 100644
--- a/include/lldb/Target/ThreadPlanStepOverRange.h
+++ b/include/lldb/Target/ThreadPlanStepOverRange.h
@@ -35,11 +35,6 @@
virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
virtual bool ShouldStop (Event *event_ptr);
- virtual bool
- IsMasterPlan()
- {
- return true;
- }
protected:
diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h
index 17002e4..9f9d6db 100644
--- a/include/lldb/Target/ThreadPlanStepUntil.h
+++ b/include/lldb/Target/ThreadPlanStepUntil.h
@@ -35,12 +35,6 @@
virtual bool WillStop ();
virtual bool MischiefManaged ();
- virtual bool
- IsMasterPlan()
- {
- return true;
- }
-
protected:
ThreadPlanStepUntil (Thread &thread,
lldb::addr_t *address_list,
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 6a86a3b..fe5c429 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -349,7 +349,7 @@
}
else
{
- // If the current plan doesn't explain the stop, then, find one that
+ // If the current plan doesn't explain the stop, then find one that
// does and let it handle the situation.
ThreadPlan *plan_ptr = current_plan;
while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
@@ -839,6 +839,17 @@
}
}
+bool
+Thread::PlanIsBasePlan (ThreadPlan *plan_ptr)
+{
+ if (plan_ptr->IsBasePlan())
+ return true;
+ else if (m_plan_stack.size() == 0)
+ return false;
+ else
+ return m_plan_stack[0].get() == plan_ptr;
+}
+
ThreadPlan *
Thread::QueueFundamentalPlan (bool abort_other_plans)
{
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 8e9cb47..5f396d9 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -36,7 +36,8 @@
m_plan_complete_mutex (Mutex::eMutexTypeRecursive),
m_plan_complete (false),
m_plan_private (false),
- m_okay_to_discard (false)
+ m_okay_to_discard (false),
+ m_is_master_plan (false)
{
SetID (GetNextID());
}
diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp
index ebaa4dc..fcb8683 100644
--- a/source/Target/ThreadPlanBase.cpp
+++ b/source/Target/ThreadPlanBase.cpp
@@ -47,6 +47,7 @@
#endif
new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
SetThreadPlanTracer(new_tracer_sp);
+ SetIsMasterPlan (true);
}
ThreadPlanBase::~ThreadPlanBase ()
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index 09bdd3d..9f6c18e 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -52,6 +52,9 @@
m_takedown_done (false),
m_stop_address (LLDB_INVALID_ADDRESS)
{
+ // Call function thread plans need to be master plans so that they can potentially stay on the stack when
+ // a breakpoint is hit during the function call.
+ SetIsMasterPlan (true);
SetOkayToDiscard (discard_on_error);
ProcessSP process_sp (thread.GetProcess());
@@ -172,6 +175,9 @@
m_return_type (return_type),
m_takedown_done (false)
{
+ // Call function thread plans need to be master plans so that they can potentially stay on the stack when
+ // a breakpoint is hit during the function call.
+ SetIsMasterPlan (true);
SetOkayToDiscard (discard_on_error);
ProcessSP process_sp (thread.GetProcess());
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 54fe8ea..c147e83 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -43,6 +43,9 @@
) :
ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others)
{
+ // Step over range plans can be master plans, since you could hit a breakpoint while stepping over, step around
+ // a bit, then continue to finish up the step over.
+ SetIsMasterPlan (true);
SetOkayToDiscard (okay_to_discard);
}
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index 79c2544..3c418f2 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -52,7 +52,11 @@
m_stop_others (stop_others)
{
+ // Step until plans can be master plans, since you could hit a breakpoint while stepping to the stop point, step around
+ // a bit, then continue to finish up the step until.
+ SetIsMasterPlan (true);
SetOkayToDiscard(true);
+
// Stash away our "until" addresses:
TargetSP target_sp (m_thread.CalculateTarget());