Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:56

0001 //===-- ThreadPlan.h --------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_TARGET_THREADPLAN_H
0010 #define LLDB_TARGET_THREADPLAN_H
0011 
0012 #include <mutex>
0013 #include <string>
0014 
0015 #include "lldb/Target/Process.h"
0016 #include "lldb/Target/StopInfo.h"
0017 #include "lldb/Target/Target.h"
0018 #include "lldb/Target/Thread.h"
0019 #include "lldb/Target/ThreadPlanTracer.h"
0020 #include "lldb/Utility/UserID.h"
0021 #include "lldb/lldb-private.h"
0022 
0023 namespace lldb_private {
0024 
0025 //  ThreadPlan:
0026 //
0027 //  This is the pure virtual base class for thread plans.
0028 //
0029 //  The thread plans provide the "atoms" of behavior that all the logical
0030 //  process control, either directly from commands or through more complex
0031 //  composite plans will rely on.
0032 //
0033 //  Plan Stack:
0034 //
0035 //  The thread maintaining a thread plan stack, and you program the actions of
0036 //  a particular thread by pushing plans onto the plan stack.  There is always
0037 //  a "Current" plan, which is the top of the plan stack, though in some cases
0038 //  a plan may defer to plans higher in the stack for some piece of information
0039 //  (let us define that the plan stack grows downwards).
0040 //
0041 //  The plan stack is never empty, there is always a Base Plan which persists
0042 //  through the life of the running process.
0043 //
0044 //
0045 //  Creating Plans:
0046 //
0047 //  The thread plan is generally created and added to the plan stack through
0048 //  the QueueThreadPlanFor... API in lldb::Thread.  Those API's will return the
0049 //  plan that performs the named operation in a manner appropriate for the
0050 //  current process.  The plans in lldb/source/Target are generic
0051 //  implementations, but a Process plugin can override them.
0052 //
0053 //  ValidatePlan is then called.  If it returns false, the plan is unshipped.
0054 //  This is a little convenience which keeps us from having to error out of the
0055 //  constructor.
0056 //
0057 //  Then the plan is added to the plan stack.  When the plan is added to the
0058 //  plan stack its DidPush will get called.  This is useful if a plan wants to
0059 //  push any additional plans as it is constructed, since you need to make sure
0060 //  you're already on the stack before you push additional plans.
0061 //
0062 //  Completed Plans:
0063 //
0064 //  When the target process stops the plans are queried, among other things,
0065 //  for whether their job is done.  If it is they are moved from the plan stack
0066 //  to the Completed Plan stack in reverse order from their position on the
0067 //  plan stack (since multiple plans may be done at a given stop.)  This is
0068 //  used primarily so that the lldb::Thread::StopInfo for the thread can be set
0069 //  properly.  If one plan pushes another to achieve part of its job, but it
0070 //  doesn't want that sub-plan to be the one that sets the StopInfo, then call
0071 //  SetPrivate on the sub-plan when you create it, and the Thread will pass
0072 //  over that plan in reporting the reason for the stop.
0073 //
0074 //  Discarded plans:
0075 //
0076 //  Your plan may also get discarded, i.e. moved from the plan stack to the
0077 //  "discarded plan stack".  This can happen, for instance, if the plan is
0078 //  calling a function and the function call crashes and you want to unwind the
0079 //  attempt to call.  So don't assume that your plan will always successfully
0080 //  stop.  Which leads to:
0081 //
0082 //  Cleaning up after your plans:
0083 //
0084 //  When the plan is moved from the plan stack its DidPop method is always
0085 //  called, no matter why.  Once it is moved off the plan stack it is done, and
0086 //  won't get a chance to run again.  So you should undo anything that affects
0087 //  target state in this method.  But be sure to leave the plan able to
0088 //  correctly fill the StopInfo, however.  N.B. Don't wait to do clean up
0089 //  target state till the destructor, since that will usually get called when
0090 //  the target resumes, and you want to leave the target state correct for new
0091 //  plans in the time between when your plan gets unshipped and the next
0092 //  resume.
0093 //
0094 //  Thread State Checkpoint:
0095 //
0096 //  Note that calling functions on target process (ThreadPlanCallFunction)
0097 //  changes current thread state. The function can be called either by direct
0098 //  user demand or internally, for example lldb allocates memory on device to
0099 //  calculate breakpoint condition expression - on Linux it is performed by
0100 //  calling mmap on device.  ThreadStateCheckpoint saves Thread state (stop
0101 //  info and completed plan stack) to restore it after completing function
0102 //  call.
0103 //
0104 //  Over the lifetime of the plan, various methods of the ThreadPlan are then
0105 //  called in response to changes of state in the process we are debugging as
0106 //  follows:
0107 //
0108 //  Resuming:
0109 //
0110 //  When the target process is about to be restarted, the plan's WillResume
0111 //  method is called, giving the plan a chance to prepare for the run.  If
0112 //  WillResume returns false, then the process is not restarted.  Be sure to
0113 //  set an appropriate error value in the Process if you have to do this.
0114 //  Note, ThreadPlans actually implement DoWillResume, WillResume wraps that
0115 //  call.
0116 //
0117 //  Next the "StopOthers" method of all the threads are polled, and if one
0118 //  thread's Current plan returns "true" then only that thread gets to run.  If
0119 //  more than one returns "true" the threads that want to run solo get run one
0120 //  by one round robin fashion.  Otherwise all are let to run.
0121 //
0122 //  Note, the way StopOthers is implemented, the base class implementation just
0123 //  asks the previous plan.  So if your plan has no opinion about whether it
0124 //  should run stopping others or not, just don't implement StopOthers, and the
0125 //  parent will be asked.
0126 //
0127 //  Finally, for each thread that is running, it run state is set to the return
0128 //  of RunState from the thread's Current plan.
0129 //
0130 //  Responding to a stop:
0131 //
0132 //  When the target process stops, the plan is called in the following stages:
0133 //
0134 //  First the thread asks the Current Plan if it can handle this stop by
0135 //  calling PlanExplainsStop.  If the Current plan answers "true" then it is
0136 //  asked if the stop should percolate all the way to the user by calling the
0137 //  ShouldStop method.  If the current plan doesn't explain the stop, then we
0138 //  query up the plan stack for a plan that does explain the stop.  The plan
0139 //  that does explain the stop then needs to figure out what to do about the
0140 //  plans below it in the stack.  If the stop is recoverable, then the plan
0141 //  that understands it can just do what it needs to set up to restart, and
0142 //  then continue.  Otherwise, the plan that understood the stop should call
0143 //  DiscardPlanStack to clean up the stack below it.  Note, plans actually
0144 //  implement DoPlanExplainsStop, the result is cached in PlanExplainsStop so
0145 //  the DoPlanExplainsStop itself will only get called once per stop.
0146 //
0147 //  Controlling plans:
0148 //
0149 //  In the normal case, when we decide to stop, we will  collapse the plan
0150 //  stack up to the point of the plan that understood the stop reason.
0151 //  However, if a plan wishes to stay on the stack after an event it didn't
0152 //  directly handle it can designate itself a "Controlling" plan by responding
0153 //  true to IsControllingPlan, and then if it wants not to be discarded, it can
0154 //  return false to OkayToDiscard, and it and all its dependent plans will be
0155 //  preserved when we resume execution.
0156 //
0157 //  The other effect of being a controlling plan is that when the Controlling
0158 //  plan is
0159 //  done , if it has set "OkayToDiscard" to false, then it will be popped &
0160 //  execution will stop and return to the user.  Remember that if OkayToDiscard
0161 //  is false, the plan will be popped and control will be given to the next
0162 //  plan above it on the stack  So setting OkayToDiscard to false means the
0163 //  user will regain control when the ControllingPlan is completed.
0164 //
0165 //  Between these two controls this allows things like: a
0166 //  ControllingPlan/DontDiscard Step Over to hit a breakpoint, stop and return
0167 //  control to the user, but then when the user continues, the step out
0168 //  succeeds.  Even more tricky, when the breakpoint is hit, the user can
0169 //  continue to step in/step over/etc, and finally when they continue, they
0170 //  will finish up the Step Over.
0171 //
0172 //  FIXME: ControllingPlan & OkayToDiscard aren't really orthogonal.
0173 //  ControllingPlan
0174 //  designation means that this plan controls it's fate and the fate of plans
0175 //  below it.  OkayToDiscard tells whether the ControllingPlan wants to stay on
0176 //  the stack.  I originally thought "ControllingPlan-ness" would need to be a
0177 //  fixed
0178 //  characteristic of a ThreadPlan, in which case you needed the extra control.
0179 //  But that doesn't seem to be true.  So we should be able to convert to only
0180 //  ControllingPlan status to mean the current "ControllingPlan/DontDiscard".
0181 //  Then no plans would be ControllingPlans by default, and you would set the
0182 //  ones you wanted to be "user level" in this way.
0183 //
0184 //
0185 //  Actually Stopping:
0186 //
0187 //  If a plan says responds "true" to ShouldStop, then it is asked if it's job
0188 //  is complete by calling MischiefManaged.  If that returns true, the plan is
0189 //  popped from the plan stack and added to the Completed Plan Stack.  Then the
0190 //  next plan in the stack is asked if it ShouldStop, and  it returns "true",
0191 //  it is asked if it is done, and if yes popped, and so on till we reach a
0192 //  plan that is not done.
0193 //
0194 //  Since you often know in the ShouldStop method whether your plan is
0195 //  complete, as a convenience you can call SetPlanComplete and the ThreadPlan
0196 //  implementation of MischiefManaged will return "true", without your having
0197 //  to redo the calculation when your sub-classes MischiefManaged is called.
0198 //  If you call SetPlanComplete, you can later use IsPlanComplete to determine
0199 //  whether the plan is complete.  This is only a convenience for sub-classes,
0200 //  the logic in lldb::Thread will only call MischiefManaged.
0201 //
0202 //  One slightly tricky point is you have to be careful using SetPlanComplete
0203 //  in PlanExplainsStop because you are not guaranteed that PlanExplainsStop
0204 //  for a plan will get called before ShouldStop gets called.  If your sub-plan
0205 //  explained the stop and then popped itself, only your ShouldStop will get
0206 //  called.
0207 //
0208 //  If ShouldStop for any thread returns "true", then the WillStop method of
0209 //  the Current plan of all threads will be called, the stop event is placed on
0210 //  the Process's public broadcaster, and control returns to the upper layers
0211 //  of the debugger.
0212 //
0213 //  Reporting the stop:
0214 //
0215 //  When the process stops, the thread is given a StopReason, in the form of a
0216 //  StopInfo object.  If there is a completed plan corresponding to the stop,
0217 //  then the "actual" stop reason can be suppressed, and instead a
0218 //  StopInfoThreadPlan object will be cons'ed up from the top completed plan in
0219 //  the stack.  However, if the plan doesn't want to be the stop reason, then
0220 //  it can call SetPlanComplete and pass in "false" for the "success"
0221 //  parameter.  In that case, the real stop reason will be used instead.  One
0222 //  example of this is the "StepRangeStepIn" thread plan.  If it stops because
0223 //  of a crash or breakpoint hit, it wants to unship itself, because it isn't
0224 //  so useful to have step in keep going after a breakpoint hit.  But it can't
0225 //  be the reason for the stop or no-one would see that they had hit a
0226 //  breakpoint.
0227 //
0228 //  Cleaning up the plan stack:
0229 //
0230 //  One of the complications of ControllingPlans is that you may get past the
0231 //  limits
0232 //  of a plan without triggering it to clean itself up.  For instance, if you
0233 //  are doing a ControllingPlan StepOver, and hit a breakpoint in a called
0234 //  function,
0235 //  then step over enough times to step out of the initial StepOver range, each
0236 //  of the step overs will explain the stop & take themselves off the stack,
0237 //  but control would never be returned to the original StepOver.  Eventually,
0238 //  the user will continue, and when that continue stops, the old stale
0239 //  StepOver plan that was left on the stack will get woken up and notice it is
0240 //  done. But that can leave junk on the stack for a while.  To avoid that, the
0241 //  plans implement a "IsPlanStale" method, that can check whether it is
0242 //  relevant anymore.  On stop, after the regular plan negotiation, the
0243 //  remaining plan stack is consulted and if any plan says it is stale, it and
0244 //  the plans below it are discarded from the stack.
0245 //
0246 //  Automatically Resuming:
0247 //
0248 //  If ShouldStop for all threads returns "false", then the target process will
0249 //  resume.  This then cycles back to Resuming above.
0250 //
0251 //  Reporting eStateStopped events when the target is restarted:
0252 //
0253 //  If a plan decides to auto-continue the target by returning "false" from
0254 //  ShouldStop, then it will be asked whether the Stopped event should still be
0255 //  reported.  For instance, if you hit a breakpoint that is a User set
0256 //  breakpoint, but the breakpoint callback said to continue the target
0257 //  process, you might still want to inform the upper layers of lldb that the
0258 //  stop had happened.  The way this works is every thread gets to vote on
0259 //  whether to report the stop.  If all votes are eVoteNoOpinion, then the
0260 //  thread list will decide what to do (at present it will pretty much always
0261 //  suppress these stopped events.) If there is an eVoteYes, then the event
0262 //  will be reported regardless of the other votes.  If there is an eVoteNo and
0263 //  no eVoteYes's, then the event won't be reported.
0264 //
0265 //  One other little detail here, sometimes a plan will push another plan onto
0266 //  the plan stack to do some part of the first plan's job, and it would be
0267 //  convenient to tell that plan how it should respond to ShouldReportStop.
0268 //  You can do that by setting the report_stop_vote in the child plan when you
0269 //  create it.
0270 //
0271 //  Suppressing the initial eStateRunning event:
0272 //
0273 //  The private process running thread will take care of ensuring that only one
0274 //  "eStateRunning" event will be delivered to the public Process broadcaster
0275 //  per public eStateStopped event.  However there are some cases where the
0276 //  public state of this process is eStateStopped, but a thread plan needs to
0277 //  restart the target, but doesn't want the running event to be publicly
0278 //  broadcast.  The obvious example of this is running functions by hand as
0279 //  part of expression evaluation.  To suppress the running event return
0280 //  eVoteNo from ShouldReportStop, to force a running event to be reported
0281 //  return eVoteYes, in general though you should return eVoteNoOpinion which
0282 //  will allow the ThreadList to figure out the right thing to do.  The
0283 //  report_run_vote argument to the constructor works like report_stop_vote, and
0284 //  is a way for a plan to instruct a sub-plan on how to respond to
0285 //  ShouldReportStop.
0286 
0287 class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
0288                    public UserID {
0289 public:
0290   // We use these enums so that we can cast a base thread plan to it's real
0291   // type without having to resort to dynamic casting.
0292   enum ThreadPlanKind {
0293     eKindGeneric,
0294     eKindNull,
0295     eKindBase,
0296     eKindCallFunction,
0297     eKindPython,
0298     eKindStepInstruction,
0299     eKindStepOut,
0300     eKindStepOverBreakpoint,
0301     eKindStepOverRange,
0302     eKindStepInRange,
0303     eKindRunToAddress,
0304     eKindStepThrough,
0305     eKindStepUntil,
0306     eKindSingleThreadTimeout,
0307   };
0308 
0309   virtual ~ThreadPlan();
0310 
0311   /// Returns the name of this thread plan.
0312   ///
0313   /// \return
0314   ///   A const char * pointer to the thread plan's name.
0315   const char *GetName() const { return m_name.c_str(); }
0316 
0317   /// Returns the Thread that is using this thread plan.
0318   ///
0319   /// \return
0320   ///   A  pointer to the thread plan's owning thread.
0321   Thread &GetThread();
0322 
0323   Target &GetTarget();
0324 
0325   const Target &GetTarget() const;
0326 
0327   /// Clear the Thread* cache.
0328   ///
0329   /// This is useful in situations like when a new Thread list is being
0330   /// generated.
0331   void ClearThreadCache();
0332 
0333   /// Print a description of this thread to the stream \a s.
0334   /// \a thread.  Don't expect that the result of GetThread is valid in
0335   /// the description method.  This might get called when the underlying
0336   /// Thread has not been reported, so we only know the TID and not the thread.
0337   ///
0338   /// \param[in] s
0339   ///    The stream to which to print the description.
0340   ///
0341   /// \param[in] level
0342   ///    The level of description desired.  Note that eDescriptionLevelBrief
0343   ///    will be used in the stop message printed when the plan is complete.
0344   virtual void GetDescription(Stream *s, lldb::DescriptionLevel level) = 0;
0345 
0346   /// Returns whether this plan could be successfully created.
0347   ///
0348   /// \param[in] error
0349   ///    A stream to which to print some reason why the plan could not be
0350   ///    created.
0351   ///    Can be NULL.
0352   ///
0353   /// \return
0354   ///   \b true if the plan should be queued, \b false otherwise.
0355   virtual bool ValidatePlan(Stream *error) = 0;
0356 
0357   bool TracerExplainsStop() {
0358     if (!m_tracer_sp)
0359       return false;
0360     else
0361       return m_tracer_sp->TracerExplainsStop();
0362   }
0363 
0364   lldb::StateType RunState();
0365 
0366   bool PlanExplainsStop(Event *event_ptr);
0367 
0368   virtual bool ShouldStop(Event *event_ptr) = 0;
0369 
0370   /// Returns whether this thread plan overrides the `ShouldStop` of
0371   /// subsequently processed plans.
0372   ///
0373   /// When processing the thread plan stack, this function gives plans the
0374   /// ability to continue - even when subsequent plans return true from
0375   /// `ShouldStop`. \see Thread::ShouldStop
0376   virtual bool ShouldAutoContinue(Event *event_ptr) { return false; }
0377 
0378   // Whether a "stop class" event should be reported to the "outside world".
0379   // In general if a thread plan is active, events should not be reported.
0380 
0381   virtual Vote ShouldReportStop(Event *event_ptr);
0382 
0383   Vote ShouldReportRun(Event *event_ptr);
0384 
0385   virtual void SetStopOthers(bool new_value);
0386 
0387   virtual bool StopOthers();
0388 
0389   // Returns true if the thread plan supports ThreadPlanSingleThreadTimeout to
0390   // resume other threads after timeout. If the thread plan returns false it
0391   // will prevent ThreadPlanSingleThreadTimeout from being created when this
0392   // thread plan is alive.
0393   virtual bool SupportsResumeOthers() { return true; }
0394 
0395   virtual bool ShouldRunBeforePublicStop() { return false; }
0396 
0397   // This is the wrapper for DoWillResume that does generic ThreadPlan logic,
0398   // then calls DoWillResume.
0399   bool WillResume(lldb::StateType resume_state, bool current_plan);
0400 
0401   virtual bool WillStop() = 0;
0402 
0403   bool IsControllingPlan() { return m_is_controlling_plan; }
0404 
0405   // Returns true if this plan is a leaf plan, meaning the plan will be popped
0406   // during each stop if it does not explain the stop and re-pushed before
0407   // resuming to stay at the top of the stack.
0408   virtual bool IsLeafPlan() { return false; }
0409 
0410   bool SetIsControllingPlan(bool value) {
0411     bool old_value = m_is_controlling_plan;
0412     m_is_controlling_plan = value;
0413     return old_value;
0414   }
0415 
0416   virtual bool OkayToDiscard();
0417 
0418   void SetOkayToDiscard(bool value) { m_okay_to_discard = value; }
0419 
0420   // The base class MischiefManaged does some cleanup - so you have to call it
0421   // in your MischiefManaged derived class.
0422   virtual bool MischiefManaged();
0423 
0424   virtual void ThreadDestroyed() {
0425     // Any cleanup that a plan might want to do in case the thread goes away in
0426     // the middle of the plan being queued on a thread can be done here.
0427   }
0428 
0429   bool GetPrivate() { return m_plan_private; }
0430 
0431   void SetPrivate(bool input) { m_plan_private = input; }
0432 
0433   virtual void DidPush();
0434 
0435   virtual void DidPop();
0436 
0437   ThreadPlanKind GetKind() const { return m_kind; }
0438 
0439   bool IsPlanComplete();
0440 
0441   void SetPlanComplete(bool success = true);
0442 
0443   virtual bool IsPlanStale() { return false; }
0444 
0445   bool PlanSucceeded() { return m_plan_succeeded; }
0446 
0447   virtual bool IsBasePlan() { return false; }
0448 
0449   lldb::ThreadPlanTracerSP &GetThreadPlanTracer() { return m_tracer_sp; }
0450 
0451   void SetThreadPlanTracer(lldb::ThreadPlanTracerSP new_tracer_sp) {
0452     m_tracer_sp = new_tracer_sp;
0453   }
0454 
0455   void DoTraceLog() {
0456     if (m_tracer_sp && m_tracer_sp->TracingEnabled())
0457       m_tracer_sp->Log();
0458   }
0459 
0460   // If the completion of the thread plan stepped out of a function, the return
0461   // value of the function might have been captured by the thread plan
0462   // (currently only ThreadPlanStepOut does this.) If so, the ReturnValueObject
0463   // can be retrieved from here.
0464 
0465   virtual lldb::ValueObjectSP GetReturnValueObject() {
0466     return lldb::ValueObjectSP();
0467   }
0468 
0469   // If the thread plan managing the evaluation of a user expression lives
0470   // longer than the command that instigated the expression (generally because
0471   // the expression evaluation hit a breakpoint, and the user regained control
0472   // at that point) a subsequent process control command step/continue/etc.
0473   // might complete the expression evaluations.  If so, the result of the
0474   // expression evaluation will show up here.
0475 
0476   virtual lldb::ExpressionVariableSP GetExpressionVariable() {
0477     return lldb::ExpressionVariableSP();
0478   }
0479 
0480   // If a thread plan stores the state before it was run, then you might want
0481   // to restore the state when it is done.  This will do that job. This is
0482   // mostly useful for artificial plans like CallFunction plans.
0483 
0484   virtual void RestoreThreadState() {}
0485 
0486   virtual bool IsVirtualStep() { return false; }
0487 
0488   bool SetIterationCount(size_t count) {
0489     if (m_takes_iteration_count) {
0490       // Don't tell me to do something 0 times...
0491       if (count == 0)
0492         return false;
0493       m_iteration_count = count;
0494     }
0495     return m_takes_iteration_count;
0496   }
0497 
0498   virtual lldb::StateType GetPlanRunState() = 0;
0499 
0500 protected:
0501   // Constructors and Destructors
0502   ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
0503              Vote report_stop_vote, Vote report_run_vote);
0504 
0505   // Classes that inherit from ThreadPlan can see and modify these
0506 
0507   virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) {
0508     return true;
0509   }
0510 
0511   virtual bool DoPlanExplainsStop(Event *event_ptr) = 0;
0512 
0513   // This pushes a plan onto the plan stack of the current plan's thread.
0514   // Also sets the plans to private and not controlling plans.  A plan pushed by
0515   // another thread plan is never either of the above.
0516   void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) {
0517     GetThread().PushPlan(thread_plan_sp);
0518     thread_plan_sp->SetPrivate(true);
0519     thread_plan_sp->SetIsControllingPlan(false);
0520   }
0521 
0522   // This gets the previous plan to the current plan (for forwarding requests).
0523   // This is mostly a formal requirement, it allows us to make the Thread's
0524   // GetPreviousPlan protected, but only friend ThreadPlan to thread.
0525 
0526   ThreadPlan *GetPreviousPlan() { return GetThread().GetPreviousPlan(this); }
0527 
0528   // This forwards the private Thread::GetPrivateStopInfo which is generally
0529   // what ThreadPlan's need to know.
0530 
0531   lldb::StopInfoSP GetPrivateStopInfo() {
0532     return GetThread().GetPrivateStopInfo();
0533   }
0534 
0535   void SetStopInfo(lldb::StopInfoSP stop_reason_sp) {
0536     GetThread().SetStopInfo(stop_reason_sp);
0537   }
0538 
0539   bool IsUsuallyUnexplainedStopReason(lldb::StopReason);
0540 
0541   Status m_status;
0542   Process &m_process;
0543   lldb::tid_t m_tid;
0544   Vote m_report_stop_vote;
0545   Vote m_report_run_vote;
0546   bool m_takes_iteration_count;
0547   bool m_could_not_resolve_hw_bp;
0548   int32_t m_iteration_count = 1;
0549 
0550 private:
0551   void CachePlanExplainsStop(bool does_explain) {
0552     m_cached_plan_explains_stop = does_explain ? eLazyBoolYes : eLazyBoolNo;
0553   }
0554 
0555   // For ThreadPlan only
0556   static lldb::user_id_t GetNextID();
0557 
0558   Thread *m_thread; // Stores a cached value of the thread, which is set to
0559                     // nullptr when the thread resumes.  Don't use this anywhere
0560                     // but ThreadPlan::GetThread().
0561   ThreadPlanKind m_kind;
0562   std::string m_name;
0563   std::recursive_mutex m_plan_complete_mutex;
0564   LazyBool m_cached_plan_explains_stop;
0565   bool m_plan_complete;
0566   bool m_plan_private;
0567   bool m_okay_to_discard;
0568   bool m_is_controlling_plan;
0569   bool m_plan_succeeded;
0570 
0571   lldb::ThreadPlanTracerSP m_tracer_sp;
0572 
0573   ThreadPlan(const ThreadPlan &) = delete;
0574   const ThreadPlan &operator=(const ThreadPlan &) = delete;
0575 };
0576 
0577 // ThreadPlanNull:
0578 // Threads are assumed to always have at least one plan on the plan stack. This
0579 // is put on the plan stack when a thread is destroyed so that if you
0580 // accidentally access a thread after it is destroyed you won't crash. But
0581 // asking questions of the ThreadPlanNull is definitely an error.
0582 
0583 class ThreadPlanNull : public ThreadPlan {
0584 public:
0585   ThreadPlanNull(Thread &thread);
0586   ~ThreadPlanNull() override;
0587 
0588   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
0589 
0590   bool ValidatePlan(Stream *error) override;
0591 
0592   bool ShouldStop(Event *event_ptr) override;
0593 
0594   bool MischiefManaged() override;
0595 
0596   bool WillStop() override;
0597 
0598   bool IsBasePlan() override { return true; }
0599 
0600   bool OkayToDiscard() override { return false; }
0601 
0602   const Status &GetStatus() { return m_status; }
0603 
0604 protected:
0605   bool DoPlanExplainsStop(Event *event_ptr) override;
0606 
0607   lldb::StateType GetPlanRunState() override;
0608 
0609   ThreadPlanNull(const ThreadPlanNull &) = delete;
0610   const ThreadPlanNull &operator=(const ThreadPlanNull &) = delete;
0611 };
0612 
0613 } // namespace lldb_private
0614 
0615 #endif // LLDB_TARGET_THREADPLAN_H