Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 2bcbaf6

Browse files
committed
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
1 parent 860b9ea commit 2bcbaf6

12 files changed

+55
-32
lines changed

include/lldb/Target/Thread.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,8 @@ class Thread :
587587

588588
private:
589589
bool
590-
PlanIsBasePlan (ThreadPlan *plan_ptr)
591-
{
592-
if (m_plan_stack.size() == 0)
593-
return false;
594-
return m_plan_stack[0].get() == plan_ptr;
595-
}
590+
PlanIsBasePlan (ThreadPlan *plan_ptr);
591+
596592
public:
597593

598594
//------------------------------------------------------------------

include/lldb/Target/ThreadPlan.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,18 @@ class ThreadPlan :
334334
virtual bool
335335
WillStop () = 0;
336336

337-
virtual bool
337+
bool
338338
IsMasterPlan()
339339
{
340-
return false;
340+
return m_is_master_plan;
341+
}
342+
343+
bool
344+
SetIsMasterPlan (bool value)
345+
{
346+
bool old_value = m_is_master_plan;
347+
m_is_master_plan = value;
348+
return old_value;
341349
}
342350

343351
virtual bool
@@ -390,6 +398,12 @@ class ThreadPlan :
390398
void
391399
SetPlanComplete ();
392400

401+
virtual bool
402+
IsBasePlan()
403+
{
404+
return false;
405+
}
406+
393407
lldb::ThreadPlanTracerSP &
394408
GetThreadPlanTracer()
395409
{
@@ -474,6 +488,7 @@ class ThreadPlan :
474488
bool m_plan_complete;
475489
bool m_plan_private;
476490
bool m_okay_to_discard;
491+
bool m_is_master_plan;
477492

478493
lldb::ThreadPlanTracerSP m_tracer_sp;
479494

include/lldb/Target/ThreadPlanBase.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// C++ Includes
1515
// Other libraries and framework includes
1616
// Project includes
17+
#include "lldb/Target/Process.h"
1718
#include "lldb/Target/Thread.h"
1819
#include "lldb/Target/ThreadPlan.h"
1920

@@ -28,6 +29,7 @@ namespace lldb_private {
2829

2930
class ThreadPlanBase : public ThreadPlan
3031
{
32+
friend class Process; // RunThreadPlan manages "stopper" base plans.
3133
public:
3234
virtual ~ThreadPlanBase ();
3335

@@ -41,16 +43,17 @@ class ThreadPlanBase : public ThreadPlan
4143
virtual bool MischiefManaged ();
4244
virtual bool WillResume (lldb::StateType resume_state, bool current_plan);
4345

44-
virtual bool IsMasterPlan()
45-
{
46-
return true;
47-
}
48-
4946
virtual bool OkayToDiscard()
5047
{
5148
return false;
5249
}
5350

51+
virtual bool
52+
IsBasePlan()
53+
{
54+
return true;
55+
}
56+
5457
protected:
5558
ThreadPlanBase (Thread &thread);
5659

include/lldb/Target/ThreadPlanCallFunction.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ class ThreadPlanCallFunction : public ThreadPlan
8080
virtual bool
8181
MischiefManaged ();
8282

83-
virtual bool
84-
IsMasterPlan()
85-
{
86-
return true;
87-
}
88-
8983
// To get the return value from a function call you must create a
9084
// lldb::ValueSP that contains a valid clang type in its context and call
9185
// RequestReturnValue. The ValueSP will be stored and when the function is

include/lldb/Target/ThreadPlanStepOverRange.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ class ThreadPlanStepOverRange : public ThreadPlanStepRange
3535

3636
virtual void GetDescription (Stream *s, lldb::DescriptionLevel level);
3737
virtual bool ShouldStop (Event *event_ptr);
38-
virtual bool
39-
IsMasterPlan()
40-
{
41-
return true;
42-
}
4338

4439
protected:
4540

include/lldb/Target/ThreadPlanStepUntil.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ class ThreadPlanStepUntil : public ThreadPlan
3535
virtual bool WillStop ();
3636
virtual bool MischiefManaged ();
3737

38-
virtual bool
39-
IsMasterPlan()
40-
{
41-
return true;
42-
}
43-
4438
protected:
4539
ThreadPlanStepUntil (Thread &thread,
4640
lldb::addr_t *address_list,

source/Target/Thread.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ Thread::ShouldStop (Event* event_ptr)
349349
}
350350
else
351351
{
352-
// If the current plan doesn't explain the stop, then, find one that
352+
// If the current plan doesn't explain the stop, then find one that
353353
// does and let it handle the situation.
354354
ThreadPlan *plan_ptr = current_plan;
355355
while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL)
@@ -839,6 +839,17 @@ Thread::DiscardThreadPlans(bool force)
839839
}
840840
}
841841

842+
bool
843+
Thread::PlanIsBasePlan (ThreadPlan *plan_ptr)
844+
{
845+
if (plan_ptr->IsBasePlan())
846+
return true;
847+
else if (m_plan_stack.size() == 0)
848+
return false;
849+
else
850+
return m_plan_stack[0].get() == plan_ptr;
851+
}
852+
842853
ThreadPlan *
843854
Thread::QueueFundamentalPlan (bool abort_other_plans)
844855
{

source/Target/ThreadPlan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vo
3636
m_plan_complete_mutex (Mutex::eMutexTypeRecursive),
3737
m_plan_complete (false),
3838
m_plan_private (false),
39-
m_okay_to_discard (false)
39+
m_okay_to_discard (false),
40+
m_is_master_plan (false)
4041
{
4142
SetID (GetNextID());
4243
}

source/Target/ThreadPlanBase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ ThreadPlanBase::ThreadPlanBase (Thread &thread) :
4747
#endif
4848
new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState());
4949
SetThreadPlanTracer(new_tracer_sp);
50+
SetIsMasterPlan (true);
5051
}
5152

5253
ThreadPlanBase::~ThreadPlanBase ()

source/Target/ThreadPlanCallFunction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
5252
m_takedown_done (false),
5353
m_stop_address (LLDB_INVALID_ADDRESS)
5454
{
55+
// Call function thread plans need to be master plans so that they can potentially stay on the stack when
56+
// a breakpoint is hit during the function call.
57+
SetIsMasterPlan (true);
5558
SetOkayToDiscard (discard_on_error);
5659

5760
ProcessSP process_sp (thread.GetProcess());
@@ -172,6 +175,9 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
172175
m_return_type (return_type),
173176
m_takedown_done (false)
174177
{
178+
// Call function thread plans need to be master plans so that they can potentially stay on the stack when
179+
// a breakpoint is hit during the function call.
180+
SetIsMasterPlan (true);
175181
SetOkayToDiscard (discard_on_error);
176182

177183
ProcessSP process_sp (thread.GetProcess());

source/Target/ThreadPlanStepOverRange.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ ThreadPlanStepOverRange::ThreadPlanStepOverRange
4343
) :
4444
ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others)
4545
{
46+
// Step over range plans can be master plans, since you could hit a breakpoint while stepping over, step around
47+
// a bit, then continue to finish up the step over.
48+
SetIsMasterPlan (true);
4649
SetOkayToDiscard (okay_to_discard);
4750
}
4851

source/Target/ThreadPlanStepUntil.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ ThreadPlanStepUntil::ThreadPlanStepUntil
5252
m_stop_others (stop_others)
5353
{
5454

55+
// Step until plans can be master plans, since you could hit a breakpoint while stepping to the stop point, step around
56+
// a bit, then continue to finish up the step until.
57+
SetIsMasterPlan (true);
5558
SetOkayToDiscard(true);
59+
5660
// Stash away our "until" addresses:
5761
TargetSP target_sp (m_thread.CalculateTarget());
5862

0 commit comments

Comments
 (0)