ThreadPlan.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. //===-- ThreadPlan.h --------------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLDB_TARGET_THREADPLAN_H
  9. #define LLDB_TARGET_THREADPLAN_H
  10. #include <mutex>
  11. #include <string>
  12. #include "lldb/Target/Process.h"
  13. #include "lldb/Target/StopInfo.h"
  14. #include "lldb/Target/Target.h"
  15. #include "lldb/Target/Thread.h"
  16. #include "lldb/Target/ThreadPlanTracer.h"
  17. #include "lldb/Utility/UserID.h"
  18. #include "lldb/lldb-private.h"
  19. namespace lldb_private {
  20. // ThreadPlan:
  21. //
  22. // This is the pure virtual base class for thread plans.
  23. //
  24. // The thread plans provide the "atoms" of behavior that all the logical
  25. // process control, either directly from commands or through more complex
  26. // composite plans will rely on.
  27. //
  28. // Plan Stack:
  29. //
  30. // The thread maintaining a thread plan stack, and you program the actions of
  31. // a particular thread by pushing plans onto the plan stack. There is always
  32. // a "Current" plan, which is the top of the plan stack, though in some cases
  33. // a plan may defer to plans higher in the stack for some piece of information
  34. // (let us define that the plan stack grows downwards).
  35. //
  36. // The plan stack is never empty, there is always a Base Plan which persists
  37. // through the life of the running process.
  38. //
  39. //
  40. // Creating Plans:
  41. //
  42. // The thread plan is generally created and added to the plan stack through
  43. // the QueueThreadPlanFor... API in lldb::Thread. Those API's will return the
  44. // plan that performs the named operation in a manner appropriate for the
  45. // current process. The plans in lldb/source/Target are generic
  46. // implementations, but a Process plugin can override them.
  47. //
  48. // ValidatePlan is then called. If it returns false, the plan is unshipped.
  49. // This is a little convenience which keeps us from having to error out of the
  50. // constructor.
  51. //
  52. // Then the plan is added to the plan stack. When the plan is added to the
  53. // plan stack its DidPush will get called. This is useful if a plan wants to
  54. // push any additional plans as it is constructed, since you need to make sure
  55. // you're already on the stack before you push additional plans.
  56. //
  57. // Completed Plans:
  58. //
  59. // When the target process stops the plans are queried, among other things,
  60. // for whether their job is done. If it is they are moved from the plan stack
  61. // to the Completed Plan stack in reverse order from their position on the
  62. // plan stack (since multiple plans may be done at a given stop.) This is
  63. // used primarily so that the lldb::Thread::StopInfo for the thread can be set
  64. // properly. If one plan pushes another to achieve part of its job, but it
  65. // doesn't want that sub-plan to be the one that sets the StopInfo, then call
  66. // SetPrivate on the sub-plan when you create it, and the Thread will pass
  67. // over that plan in reporting the reason for the stop.
  68. //
  69. // Discarded plans:
  70. //
  71. // Your plan may also get discarded, i.e. moved from the plan stack to the
  72. // "discarded plan stack". This can happen, for instance, if the plan is
  73. // calling a function and the function call crashes and you want to unwind the
  74. // attempt to call. So don't assume that your plan will always successfully
  75. // stop. Which leads to:
  76. //
  77. // Cleaning up after your plans:
  78. //
  79. // When the plan is moved from the plan stack its WillPop method is always
  80. // called, no matter why. Once it is moved off the plan stack it is done, and
  81. // won't get a chance to run again. So you should undo anything that affects
  82. // target state in this method. But be sure to leave the plan able to
  83. // correctly fill the StopInfo, however. N.B. Don't wait to do clean up
  84. // target state till the destructor, since that will usually get called when
  85. // the target resumes, and you want to leave the target state correct for new
  86. // plans in the time between when your plan gets unshipped and the next
  87. // resume.
  88. //
  89. // Thread State Checkpoint:
  90. //
  91. // Note that calling functions on target process (ThreadPlanCallFunction)
  92. // changes current thread state. The function can be called either by direct
  93. // user demand or internally, for example lldb allocates memory on device to
  94. // calculate breakpoint condition expression - on Linux it is performed by
  95. // calling mmap on device. ThreadStateCheckpoint saves Thread state (stop
  96. // info and completed plan stack) to restore it after completing function
  97. // call.
  98. //
  99. // Over the lifetime of the plan, various methods of the ThreadPlan are then
  100. // called in response to changes of state in the process we are debugging as
  101. // follows:
  102. //
  103. // Resuming:
  104. //
  105. // When the target process is about to be restarted, the plan's WillResume
  106. // method is called, giving the plan a chance to prepare for the run. If
  107. // WillResume returns false, then the process is not restarted. Be sure to
  108. // set an appropriate error value in the Process if you have to do this.
  109. // Note, ThreadPlans actually implement DoWillResume, WillResume wraps that
  110. // call.
  111. //
  112. // Next the "StopOthers" method of all the threads are polled, and if one
  113. // thread's Current plan returns "true" then only that thread gets to run. If
  114. // more than one returns "true" the threads that want to run solo get run one
  115. // by one round robin fashion. Otherwise all are let to run.
  116. //
  117. // Note, the way StopOthers is implemented, the base class implementation just
  118. // asks the previous plan. So if your plan has no opinion about whether it
  119. // should run stopping others or not, just don't implement StopOthers, and the
  120. // parent will be asked.
  121. //
  122. // Finally, for each thread that is running, it run state is set to the return
  123. // of RunState from the thread's Current plan.
  124. //
  125. // Responding to a stop:
  126. //
  127. // When the target process stops, the plan is called in the following stages:
  128. //
  129. // First the thread asks the Current Plan if it can handle this stop by
  130. // calling PlanExplainsStop. If the Current plan answers "true" then it is
  131. // asked if the stop should percolate all the way to the user by calling the
  132. // ShouldStop method. If the current plan doesn't explain the stop, then we
  133. // query up the plan stack for a plan that does explain the stop. The plan
  134. // that does explain the stop then needs to figure out what to do about the
  135. // plans below it in the stack. If the stop is recoverable, then the plan
  136. // that understands it can just do what it needs to set up to restart, and
  137. // then continue. Otherwise, the plan that understood the stop should call
  138. // DiscardPlanStack to clean up the stack below it. Note, plans actually
  139. // implement DoPlanExplainsStop, the result is cached in PlanExplainsStop so
  140. // the DoPlanExplainsStop itself will only get called once per stop.
  141. //
  142. // Master plans:
  143. //
  144. // In the normal case, when we decide to stop, we will collapse the plan
  145. // stack up to the point of the plan that understood the stop reason.
  146. // However, if a plan wishes to stay on the stack after an event it didn't
  147. // directly handle it can designate itself a "Master" plan by responding true
  148. // to IsMasterPlan, and then if it wants not to be discarded, it can return
  149. // false to OkayToDiscard, and it and all its dependent plans will be
  150. // preserved when we resume execution.
  151. //
  152. // The other effect of being a master plan is that when the Master plan is
  153. // done , if it has set "OkayToDiscard" to false, then it will be popped &
  154. // execution will stop and return to the user. Remember that if OkayToDiscard
  155. // is false, the plan will be popped and control will be given to the next
  156. // plan above it on the stack So setting OkayToDiscard to false means the
  157. // user will regain control when the MasterPlan is completed.
  158. //
  159. // Between these two controls this allows things like: a
  160. // MasterPlan/DontDiscard Step Over to hit a breakpoint, stop and return
  161. // control to the user, but then when the user continues, the step out
  162. // succeeds. Even more tricky, when the breakpoint is hit, the user can
  163. // continue to step in/step over/etc, and finally when they continue, they
  164. // will finish up the Step Over.
  165. //
  166. // FIXME: MasterPlan & OkayToDiscard aren't really orthogonal. MasterPlan
  167. // designation means that this plan controls it's fate and the fate of plans
  168. // below it. OkayToDiscard tells whether the MasterPlan wants to stay on the
  169. // stack. I originally thought "MasterPlan-ness" would need to be a fixed
  170. // characteristic of a ThreadPlan, in which case you needed the extra control.
  171. // But that doesn't seem to be true. So we should be able to convert to only
  172. // MasterPlan status to mean the current "MasterPlan/DontDiscard". Then no
  173. // plans would be MasterPlans by default, and you would set the ones you
  174. // wanted to be "user level" in this way.
  175. //
  176. //
  177. // Actually Stopping:
  178. //
  179. // If a plan says responds "true" to ShouldStop, then it is asked if it's job
  180. // is complete by calling MischiefManaged. If that returns true, the plan is
  181. // popped from the plan stack and added to the Completed Plan Stack. Then the
  182. // next plan in the stack is asked if it ShouldStop, and it returns "true",
  183. // it is asked if it is done, and if yes popped, and so on till we reach a
  184. // plan that is not done.
  185. //
  186. // Since you often know in the ShouldStop method whether your plan is
  187. // complete, as a convenience you can call SetPlanComplete and the ThreadPlan
  188. // implementation of MischiefManaged will return "true", without your having
  189. // to redo the calculation when your sub-classes MischiefManaged is called.
  190. // If you call SetPlanComplete, you can later use IsPlanComplete to determine
  191. // whether the plan is complete. This is only a convenience for sub-classes,
  192. // the logic in lldb::Thread will only call MischiefManaged.
  193. //
  194. // One slightly tricky point is you have to be careful using SetPlanComplete
  195. // in PlanExplainsStop because you are not guaranteed that PlanExplainsStop
  196. // for a plan will get called before ShouldStop gets called. If your sub-plan
  197. // explained the stop and then popped itself, only your ShouldStop will get
  198. // called.
  199. //
  200. // If ShouldStop for any thread returns "true", then the WillStop method of
  201. // the Current plan of all threads will be called, the stop event is placed on
  202. // the Process's public broadcaster, and control returns to the upper layers
  203. // of the debugger.
  204. //
  205. // Reporting the stop:
  206. //
  207. // When the process stops, the thread is given a StopReason, in the form of a
  208. // StopInfo object. If there is a completed plan corresponding to the stop,
  209. // then the "actual" stop reason can be suppressed, and instead a
  210. // StopInfoThreadPlan object will be cons'ed up from the top completed plan in
  211. // the stack. However, if the plan doesn't want to be the stop reason, then
  212. // it can call SetPlanComplete and pass in "false" for the "success"
  213. // parameter. In that case, the real stop reason will be used instead. One
  214. // example of this is the "StepRangeStepIn" thread plan. If it stops because
  215. // of a crash or breakpoint hit, it wants to unship itself, because it isn't
  216. // so useful to have step in keep going after a breakpoint hit. But it can't
  217. // be the reason for the stop or no-one would see that they had hit a
  218. // breakpoint.
  219. //
  220. // Cleaning up the plan stack:
  221. //
  222. // One of the complications of MasterPlans is that you may get past the limits
  223. // of a plan without triggering it to clean itself up. For instance, if you
  224. // are doing a MasterPlan StepOver, and hit a breakpoint in a called function,
  225. // then step over enough times to step out of the initial StepOver range, each
  226. // of the step overs will explain the stop & take themselves off the stack,
  227. // but control would never be returned to the original StepOver. Eventually,
  228. // the user will continue, and when that continue stops, the old stale
  229. // StepOver plan that was left on the stack will get woken up and notice it is
  230. // done. But that can leave junk on the stack for a while. To avoid that, the
  231. // plans implement a "IsPlanStale" method, that can check whether it is
  232. // relevant anymore. On stop, after the regular plan negotiation, the
  233. // remaining plan stack is consulted and if any plan says it is stale, it and
  234. // the plans below it are discarded from the stack.
  235. //
  236. // Automatically Resuming:
  237. //
  238. // If ShouldStop for all threads returns "false", then the target process will
  239. // resume. This then cycles back to Resuming above.
  240. //
  241. // Reporting eStateStopped events when the target is restarted:
  242. //
  243. // If a plan decides to auto-continue the target by returning "false" from
  244. // ShouldStop, then it will be asked whether the Stopped event should still be
  245. // reported. For instance, if you hit a breakpoint that is a User set
  246. // breakpoint, but the breakpoint callback said to continue the target
  247. // process, you might still want to inform the upper layers of lldb that the
  248. // stop had happened. The way this works is every thread gets to vote on
  249. // whether to report the stop. If all votes are eVoteNoOpinion, then the
  250. // thread list will decide what to do (at present it will pretty much always
  251. // suppress these stopped events.) If there is an eVoteYes, then the event
  252. // will be reported regardless of the other votes. If there is an eVoteNo and
  253. // no eVoteYes's, then the event won't be reported.
  254. //
  255. // One other little detail here, sometimes a plan will push another plan onto
  256. // the plan stack to do some part of the first plan's job, and it would be
  257. // convenient to tell that plan how it should respond to ShouldReportStop.
  258. // You can do that by setting the report_stop_vote in the child plan when you
  259. // create it.
  260. //
  261. // Suppressing the initial eStateRunning event:
  262. //
  263. // The private process running thread will take care of ensuring that only one
  264. // "eStateRunning" event will be delivered to the public Process broadcaster
  265. // per public eStateStopped event. However there are some cases where the
  266. // public state of this process is eStateStopped, but a thread plan needs to
  267. // restart the target, but doesn't want the running event to be publicly
  268. // broadcast. The obvious example of this is running functions by hand as
  269. // part of expression evaluation. To suppress the running event return
  270. // eVoteNo from ShouldReportStop, to force a running event to be reported
  271. // return eVoteYes, in general though you should return eVoteNoOpinion which
  272. // will allow the ThreadList to figure out the right thing to do. The
  273. // report_run_vote argument to the constructor works like report_stop_vote, and
  274. // is a way for a plan to instruct a sub-plan on how to respond to
  275. // ShouldReportStop.
  276. class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
  277. public UserID {
  278. public:
  279. // We use these enums so that we can cast a base thread plan to it's real
  280. // type without having to resort to dynamic casting.
  281. enum ThreadPlanKind {
  282. eKindGeneric,
  283. eKindNull,
  284. eKindBase,
  285. eKindCallFunction,
  286. eKindPython,
  287. eKindStepInstruction,
  288. eKindStepOut,
  289. eKindStepOverBreakpoint,
  290. eKindStepOverRange,
  291. eKindStepInRange,
  292. eKindRunToAddress,
  293. eKindStepThrough,
  294. eKindStepUntil
  295. };
  296. virtual ~ThreadPlan();
  297. /// Returns the name of this thread plan.
  298. ///
  299. /// \return
  300. /// A const char * pointer to the thread plan's name.
  301. const char *GetName() const { return m_name.c_str(); }
  302. /// Returns the Thread that is using this thread plan.
  303. ///
  304. /// \return
  305. /// A pointer to the thread plan's owning thread.
  306. Thread &GetThread();
  307. Target &GetTarget();
  308. const Target &GetTarget() const;
  309. /// Clear the Thread* cache.
  310. ///
  311. /// This is useful in situations like when a new Thread list is being
  312. /// generated.
  313. void ClearThreadCache();
  314. /// Print a description of this thread to the stream \a s.
  315. /// \a thread. Don't expect that the result of GetThread is valid in
  316. /// the description method. This might get called when the underlying
  317. /// Thread has not been reported, so we only know the TID and not the thread.
  318. ///
  319. /// \param[in] s
  320. /// The stream to which to print the description.
  321. ///
  322. /// \param[in] level
  323. /// The level of description desired. Note that eDescriptionLevelBrief
  324. /// will be used in the stop message printed when the plan is complete.
  325. virtual void GetDescription(Stream *s, lldb::DescriptionLevel level) = 0;
  326. /// Returns whether this plan could be successfully created.
  327. ///
  328. /// \param[in] error
  329. /// A stream to which to print some reason why the plan could not be
  330. /// created.
  331. /// Can be NULL.
  332. ///
  333. /// \return
  334. /// \b true if the plan should be queued, \b false otherwise.
  335. virtual bool ValidatePlan(Stream *error) = 0;
  336. bool TracerExplainsStop() {
  337. if (!m_tracer_sp)
  338. return false;
  339. else
  340. return m_tracer_sp->TracerExplainsStop();
  341. }
  342. lldb::StateType RunState();
  343. bool PlanExplainsStop(Event *event_ptr);
  344. virtual bool ShouldStop(Event *event_ptr) = 0;
  345. /// Returns whether this thread plan overrides the `ShouldStop` of
  346. /// subsequently processed plans.
  347. ///
  348. /// When processing the thread plan stack, this function gives plans the
  349. /// ability to continue - even when subsequent plans return true from
  350. /// `ShouldStop`. \see Thread::ShouldStop
  351. virtual bool ShouldAutoContinue(Event *event_ptr) { return false; }
  352. // Whether a "stop class" event should be reported to the "outside world".
  353. // In general if a thread plan is active, events should not be reported.
  354. virtual Vote ShouldReportStop(Event *event_ptr);
  355. Vote ShouldReportRun(Event *event_ptr);
  356. virtual void SetStopOthers(bool new_value);
  357. virtual bool StopOthers();
  358. // This is the wrapper for DoWillResume that does generic ThreadPlan logic,
  359. // then calls DoWillResume.
  360. bool WillResume(lldb::StateType resume_state, bool current_plan);
  361. virtual bool WillStop() = 0;
  362. bool IsMasterPlan() { return m_is_master_plan; }
  363. bool SetIsMasterPlan(bool value) {
  364. bool old_value = m_is_master_plan;
  365. m_is_master_plan = value;
  366. return old_value;
  367. }
  368. virtual bool OkayToDiscard();
  369. void SetOkayToDiscard(bool value) { m_okay_to_discard = value; }
  370. // The base class MischiefManaged does some cleanup - so you have to call it
  371. // in your MischiefManaged derived class.
  372. virtual bool MischiefManaged();
  373. virtual void ThreadDestroyed() {
  374. // Any cleanup that a plan might want to do in case the thread goes away in
  375. // the middle of the plan being queued on a thread can be done here.
  376. }
  377. bool GetPrivate() { return m_plan_private; }
  378. void SetPrivate(bool input) { m_plan_private = input; }
  379. virtual void DidPush();
  380. virtual void WillPop();
  381. ThreadPlanKind GetKind() const { return m_kind; }
  382. bool IsPlanComplete();
  383. void SetPlanComplete(bool success = true);
  384. virtual bool IsPlanStale() { return false; }
  385. bool PlanSucceeded() { return m_plan_succeeded; }
  386. virtual bool IsBasePlan() { return false; }
  387. lldb::ThreadPlanTracerSP &GetThreadPlanTracer() { return m_tracer_sp; }
  388. void SetThreadPlanTracer(lldb::ThreadPlanTracerSP new_tracer_sp) {
  389. m_tracer_sp = new_tracer_sp;
  390. }
  391. void DoTraceLog() {
  392. if (m_tracer_sp && m_tracer_sp->TracingEnabled())
  393. m_tracer_sp->Log();
  394. }
  395. // If the completion of the thread plan stepped out of a function, the return
  396. // value of the function might have been captured by the thread plan
  397. // (currently only ThreadPlanStepOut does this.) If so, the ReturnValueObject
  398. // can be retrieved from here.
  399. virtual lldb::ValueObjectSP GetReturnValueObject() {
  400. return lldb::ValueObjectSP();
  401. }
  402. // If the thread plan managing the evaluation of a user expression lives
  403. // longer than the command that instigated the expression (generally because
  404. // the expression evaluation hit a breakpoint, and the user regained control
  405. // at that point) a subsequent process control command step/continue/etc.
  406. // might complete the expression evaluations. If so, the result of the
  407. // expression evaluation will show up here.
  408. virtual lldb::ExpressionVariableSP GetExpressionVariable() {
  409. return lldb::ExpressionVariableSP();
  410. }
  411. // If a thread plan stores the state before it was run, then you might want
  412. // to restore the state when it is done. This will do that job. This is
  413. // mostly useful for artificial plans like CallFunction plans.
  414. virtual void RestoreThreadState() {}
  415. virtual bool IsVirtualStep() { return false; }
  416. bool SetIterationCount(size_t count) {
  417. if (m_takes_iteration_count) {
  418. // Don't tell me to do something 0 times...
  419. if (count == 0)
  420. return false;
  421. m_iteration_count = count;
  422. }
  423. return m_takes_iteration_count;
  424. }
  425. protected:
  426. // Constructors and Destructors
  427. ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
  428. Vote report_stop_vote, Vote report_run_vote);
  429. // Classes that inherit from ThreadPlan can see and modify these
  430. virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) {
  431. return true;
  432. }
  433. virtual bool DoPlanExplainsStop(Event *event_ptr) = 0;
  434. // This pushes a plan onto the plan stack of the current plan's thread.
  435. // Also sets the plans to private and not master plans. A plan pushed by
  436. // another thread plan is never either of the above.
  437. void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) {
  438. GetThread().PushPlan(thread_plan_sp);
  439. thread_plan_sp->SetPrivate(true);
  440. thread_plan_sp->SetIsMasterPlan(false);
  441. }
  442. // This gets the previous plan to the current plan (for forwarding requests).
  443. // This is mostly a formal requirement, it allows us to make the Thread's
  444. // GetPreviousPlan protected, but only friend ThreadPlan to thread.
  445. ThreadPlan *GetPreviousPlan() { return GetThread().GetPreviousPlan(this); }
  446. // This forwards the private Thread::GetPrivateStopInfo which is generally
  447. // what ThreadPlan's need to know.
  448. lldb::StopInfoSP GetPrivateStopInfo() {
  449. return GetThread().GetPrivateStopInfo();
  450. }
  451. void SetStopInfo(lldb::StopInfoSP stop_reason_sp) {
  452. GetThread().SetStopInfo(stop_reason_sp);
  453. }
  454. virtual lldb::StateType GetPlanRunState() = 0;
  455. bool IsUsuallyUnexplainedStopReason(lldb::StopReason);
  456. Status m_status;
  457. Process &m_process;
  458. lldb::tid_t m_tid;
  459. Vote m_report_stop_vote;
  460. Vote m_report_run_vote;
  461. bool m_takes_iteration_count;
  462. bool m_could_not_resolve_hw_bp;
  463. int32_t m_iteration_count = 1;
  464. private:
  465. void CachePlanExplainsStop(bool does_explain) {
  466. m_cached_plan_explains_stop = does_explain ? eLazyBoolYes : eLazyBoolNo;
  467. }
  468. // For ThreadPlan only
  469. static lldb::user_id_t GetNextID();
  470. Thread *m_thread; // Stores a cached value of the thread, which is set to
  471. // nullptr when the thread resumes. Don't use this anywhere
  472. // but ThreadPlan::GetThread().
  473. ThreadPlanKind m_kind;
  474. std::string m_name;
  475. std::recursive_mutex m_plan_complete_mutex;
  476. LazyBool m_cached_plan_explains_stop;
  477. bool m_plan_complete;
  478. bool m_plan_private;
  479. bool m_okay_to_discard;
  480. bool m_is_master_plan;
  481. bool m_plan_succeeded;
  482. lldb::ThreadPlanTracerSP m_tracer_sp;
  483. ThreadPlan(const ThreadPlan &) = delete;
  484. const ThreadPlan &operator=(const ThreadPlan &) = delete;
  485. };
  486. // ThreadPlanNull:
  487. // Threads are assumed to always have at least one plan on the plan stack. This
  488. // is put on the plan stack when a thread is destroyed so that if you
  489. // accidentally access a thread after it is destroyed you won't crash. But
  490. // asking questions of the ThreadPlanNull is definitely an error.
  491. class ThreadPlanNull : public ThreadPlan {
  492. public:
  493. ThreadPlanNull(Thread &thread);
  494. ~ThreadPlanNull() override;
  495. void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
  496. bool ValidatePlan(Stream *error) override;
  497. bool ShouldStop(Event *event_ptr) override;
  498. bool MischiefManaged() override;
  499. bool WillStop() override;
  500. bool IsBasePlan() override { return true; }
  501. bool OkayToDiscard() override { return false; }
  502. const Status &GetStatus() { return m_status; }
  503. protected:
  504. bool DoPlanExplainsStop(Event *event_ptr) override;
  505. lldb::StateType GetPlanRunState() override;
  506. ThreadPlanNull(const ThreadPlanNull &) = delete;
  507. const ThreadPlanNull &operator=(const ThreadPlanNull &) = delete;
  508. };
  509. } // namespace lldb_private
  510. #endif // LLDB_TARGET_THREADPLAN_H