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