Thread.h revision a7d3dc75ec4f46033c3f991f11fb58a058091a85
1//===-- Thread.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_Thread_h_ 11#define liblldb_Thread_h_ 12 13#include "lldb/lldb-private.h" 14#include "lldb/Host/Mutex.h" 15#include "lldb/Core/UserID.h" 16#include "lldb/Core/UserSettingsController.h" 17#include "lldb/Target/ExecutionContextScope.h" 18#include "lldb/Target/StackFrameList.h" 19 20#define LLDB_THREAD_MAX_STOP_EXC_DATA 8 21 22namespace lldb_private { 23 24class ThreadInstanceSettings : public InstanceSettings 25{ 26public: 27 28 ThreadInstanceSettings (const lldb::UserSettingsControllerSP &owner_sp, bool live_instance = true, const char *name = NULL); 29 30 ThreadInstanceSettings (const ThreadInstanceSettings &rhs); 31 32 virtual 33 ~ThreadInstanceSettings (); 34 35 ThreadInstanceSettings& 36 operator= (const ThreadInstanceSettings &rhs); 37 38 39 void 40 UpdateInstanceSettingsVariable (const ConstString &var_name, 41 const char *index_value, 42 const char *value, 43 const ConstString &instance_name, 44 const SettingEntry &entry, 45 VarSetOperationType op, 46 Error &err, 47 bool pending); 48 49 bool 50 GetInstanceSettingsValue (const SettingEntry &entry, 51 const ConstString &var_name, 52 StringList &value, 53 Error *err); 54 55 RegularExpression * 56 GetSymbolsToAvoidRegexp() 57 { 58 return m_avoid_regexp_ap.get(); 59 } 60 61 static const ConstString & 62 StepAvoidRegexpVarName (); 63 64 bool 65 GetTraceEnabledState() 66 { 67 return m_trace_enabled; 68 } 69 static const ConstString & 70 GetTraceThreadVarName (); 71 72protected: 73 74 void 75 CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, 76 bool pending); 77 78 const ConstString 79 CreateInstanceName (); 80 81private: 82 83 std::auto_ptr<RegularExpression> m_avoid_regexp_ap; 84 bool m_trace_enabled; 85}; 86 87class Thread : 88 public STD_ENABLE_SHARED_FROM_THIS(Thread), 89 public UserID, 90 public ExecutionContextScope, 91 public ThreadInstanceSettings 92{ 93public: 94 95 class SettingsController : public UserSettingsController 96 { 97 public: 98 99 SettingsController (); 100 101 virtual 102 ~SettingsController (); 103 104 static SettingEntry global_settings_table[]; 105 static SettingEntry instance_settings_table[]; 106 107 protected: 108 109 lldb::InstanceSettingsSP 110 CreateInstanceSettings (const char *instance_name); 111 112 private: 113 114 // Class-wide settings. 115 116 DISALLOW_COPY_AND_ASSIGN (SettingsController); 117 }; 118 119 // TODO: You shouldn't just checkpoint the register state alone, so this should get 120 // moved to protected. To do that ThreadStateCheckpoint needs to be returned as a token... 121 class RegisterCheckpoint 122 { 123 public: 124 125 RegisterCheckpoint() : 126 m_stack_id (), 127 m_data_sp () 128 { 129 } 130 131 RegisterCheckpoint (const StackID &stack_id) : 132 m_stack_id (stack_id), 133 m_data_sp () 134 { 135 } 136 137 ~RegisterCheckpoint() 138 { 139 } 140 141 const RegisterCheckpoint& 142 operator= (const RegisterCheckpoint &rhs) 143 { 144 if (this != &rhs) 145 { 146 this->m_stack_id = rhs.m_stack_id; 147 this->m_data_sp = rhs.m_data_sp; 148 } 149 return *this; 150 } 151 152 RegisterCheckpoint (const RegisterCheckpoint &rhs) : 153 m_stack_id (rhs.m_stack_id), 154 m_data_sp (rhs.m_data_sp) 155 { 156 } 157 158 const StackID & 159 GetStackID() 160 { 161 return m_stack_id; 162 } 163 164 void 165 SetStackID (const StackID &stack_id) 166 { 167 m_stack_id = stack_id; 168 } 169 170 lldb::DataBufferSP & 171 GetData() 172 { 173 return m_data_sp; 174 } 175 176 const lldb::DataBufferSP & 177 GetData() const 178 { 179 return m_data_sp; 180 } 181 182 protected: 183 StackID m_stack_id; 184 lldb::DataBufferSP m_data_sp; 185 }; 186 187 struct ThreadStateCheckpoint 188 { 189 uint32_t orig_stop_id; // Dunno if I need this yet but it is an interesting bit of data. 190 lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you might continue with the wrong signals. 191 RegisterCheckpoint register_backup; // You need to restore the registers, of course... 192 }; 193 194 void 195 UpdateInstanceName (); 196 197 static void 198 SettingsInitialize (); 199 200 static void 201 SettingsTerminate (); 202 203 static lldb::UserSettingsControllerSP & 204 GetSettingsController (); 205 206 Thread (const lldb::ProcessSP &process_sp, lldb::tid_t tid); 207 virtual ~Thread(); 208 209 lldb::ProcessSP 210 GetProcess() const 211 { 212 return m_process_wp.lock(); 213 } 214 215 int 216 GetResumeSignal () const 217 { 218 return m_resume_signal; 219 } 220 221 void 222 SetResumeSignal (int signal) 223 { 224 m_resume_signal = signal; 225 } 226 227 lldb::StateType 228 GetState() const; 229 230 void 231 SetState (lldb::StateType state); 232 233 lldb::StateType 234 GetResumeState () const 235 { 236 return m_resume_state; 237 } 238 239 void 240 SetResumeState (lldb::StateType state) 241 { 242 m_resume_state = state; 243 } 244 245 // This function is called on all the threads before "WillResume" in case 246 // a thread needs to change its state before the ThreadList polls all the 247 // threads to figure out which ones actually will get to run and how. 248 void 249 SetupForResume (); 250 251 // Override this to do platform specific tasks before resume, but always 252 // call the Thread::WillResume at the end of your work. 253 254 virtual bool 255 WillResume (lldb::StateType resume_state); 256 257 // This clears generic thread state after a resume. If you subclass this, 258 // be sure to call it. 259 virtual void 260 DidResume (); 261 262 virtual void 263 RefreshStateAfterStop() = 0; 264 265 void 266 WillStop (); 267 268 bool 269 ShouldStop (Event *event_ptr); 270 271 Vote 272 ShouldReportStop (Event *event_ptr); 273 274 Vote 275 ShouldReportRun (Event *event_ptr); 276 277 void 278 Flush (); 279 280 // Return whether this thread matches the specification in ThreadSpec. This is a virtual 281 // method because at some point we may extend the thread spec with a platform specific 282 // dictionary of attributes, which then only the platform specific Thread implementation 283 // would know how to match. For now, this just calls through to the ThreadSpec's 284 // ThreadPassesBasicTests method. 285 virtual bool 286 MatchesSpec (const ThreadSpec *spec); 287 288 lldb::StopInfoSP 289 GetStopInfo (); 290 291 // This sets the stop reason to a "blank" stop reason, so you can call functions on the thread 292 // without having the called function run with whatever stop reason you stopped with. 293 void 294 SetStopInfoToNothing(); 295 296 bool 297 ThreadStoppedForAReason (); 298 299 static const char * 300 RunModeAsCString (lldb::RunMode mode); 301 302 static const char * 303 StopReasonAsCString (lldb::StopReason reason); 304 305 virtual const char * 306 GetInfo () 307 { 308 return NULL; 309 } 310 311 virtual const char * 312 GetName () 313 { 314 return NULL; 315 } 316 317 virtual const char * 318 GetQueueName () 319 { 320 return NULL; 321 } 322 323 virtual uint32_t 324 GetStackFrameCount() 325 { 326 return GetStackFrameList()->GetNumFrames(); 327 } 328 329 virtual lldb::StackFrameSP 330 GetStackFrameAtIndex (uint32_t idx) 331 { 332 return GetStackFrameList()->GetFrameAtIndex(idx); 333 } 334 335 virtual lldb::StackFrameSP 336 GetFrameWithConcreteFrameIndex (uint32_t unwind_idx); 337 338 virtual lldb::StackFrameSP 339 GetFrameWithStackID (const StackID &stack_id) 340 { 341 return GetStackFrameList()->GetFrameWithStackID (stack_id); 342 } 343 344 uint32_t 345 GetSelectedFrameIndex () 346 { 347 return GetStackFrameList()->GetSelectedFrameIndex(); 348 } 349 350 lldb::StackFrameSP 351 GetSelectedFrame () 352 { 353 lldb::StackFrameListSP stack_frame_list_sp(GetStackFrameList()); 354 return stack_frame_list_sp->GetFrameAtIndex (stack_frame_list_sp->GetSelectedFrameIndex()); 355 } 356 357 uint32_t 358 SetSelectedFrame (lldb_private::StackFrame *frame) 359 { 360 return GetStackFrameList()->SetSelectedFrame(frame); 361 } 362 363 bool 364 SetSelectedFrameByIndex (uint32_t frame_idx) 365 { 366 return GetStackFrameList()->SetSelectedFrameByIndex(frame_idx); 367 } 368 369 void 370 SetDefaultFileAndLineToSelectedFrame() 371 { 372 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame(); 373 } 374 375 virtual lldb::RegisterContextSP 376 GetRegisterContext () = 0; 377 378 virtual lldb::RegisterContextSP 379 CreateRegisterContextForFrame (StackFrame *frame) = 0; 380 381 virtual void 382 ClearStackFrames (); 383 384 void 385 DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx); 386 387 //------------------------------------------------------------------ 388 // Thread Plan Providers: 389 // This section provides the basic thread plans that the Process control 390 // machinery uses to run the target. ThreadPlan.h provides more details on 391 // how this mechanism works. 392 // The thread provides accessors to a set of plans that perform basic operations. 393 // The idea is that particular Platform plugins can override these methods to 394 // provide the implementation of these basic operations appropriate to their 395 // environment. 396 //------------------------------------------------------------------ 397 398 //------------------------------------------------------------------ 399 /// Queues the base plan for a thread. 400 /// The version returned by Process does some things that are useful, 401 /// like handle breakpoints and signals, so if you return a plugin specific 402 /// one you probably want to call through to the Process one for anything 403 /// your plugin doesn't explicitly handle. 404 /// 405 /// @param[in] abort_other_plans 406 /// \b true if we discard the currently queued plans and replace them with this one. 407 /// Otherwise this plan will go on the end of the plan stack. 408 /// 409 /// @return 410 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 411 //------------------------------------------------------------------ 412 virtual ThreadPlan * 413 QueueFundamentalPlan (bool abort_other_plans); 414 415 //------------------------------------------------------------------ 416 /// Queues the plan used to step over a breakpoint at the current PC of \a thread. 417 /// The default version returned by Process handles trap based breakpoints, and 418 /// will disable the breakpoint, single step over it, then re-enable it. 419 /// 420 /// @param[in] abort_other_plans 421 /// \b true if we discard the currently queued plans and replace them with this one. 422 /// Otherwise this plan will go on the end of the plan stack. 423 /// 424 /// @return 425 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 426 //------------------------------------------------------------------ 427 virtual ThreadPlan * 428 QueueThreadPlanForStepOverBreakpointPlan (bool abort_other_plans); 429 430 //------------------------------------------------------------------ 431 /// Queues the plan used to step one instruction from the current PC of \a thread. 432 /// 433 /// @param[in] step_over 434 /// \b true if we step over calls to functions, false if we step in. 435 /// 436 /// @param[in] abort_other_plans 437 /// \b true if we discard the currently queued plans and replace them with this one. 438 /// Otherwise this plan will go on the end of the plan stack. 439 /// 440 /// @param[in] stop_other_threads 441 /// \b true if we will stop other threads while we single step this one. 442 /// 443 /// @return 444 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 445 //------------------------------------------------------------------ 446 virtual ThreadPlan * 447 QueueThreadPlanForStepSingleInstruction (bool step_over, 448 bool abort_other_plans, 449 bool stop_other_threads); 450 451 //------------------------------------------------------------------ 452 /// Queues the plan used to step through an address range, stepping into or over 453 /// function calls depending on the value of StepType. 454 /// 455 /// @param[in] abort_other_plans 456 /// \b true if we discard the currently queued plans and replace them with this one. 457 /// Otherwise this plan will go on the end of the plan stack. 458 /// 459 /// @param[in] type 460 /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan. 461 /// 462 /// @param[in] range 463 /// The address range to step through. 464 /// 465 /// @param[in] addr_context 466 /// When dealing with stepping through inlined functions the current PC is not enough information to know 467 /// what "step" means. For instance a series of nested inline functions might start at the same address. 468 // The \a addr_context provides the current symbol context the step 469 /// is supposed to be out of. 470 // FIXME: Currently unused. 471 /// 472 /// @param[in] stop_other_threads 473 /// \b true if we will stop other threads while we single step this one. 474 /// 475 /// @return 476 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 477 //------------------------------------------------------------------ 478 virtual ThreadPlan * 479 QueueThreadPlanForStepRange (bool abort_other_plans, 480 StepType type, 481 const AddressRange &range, 482 const SymbolContext &addr_context, 483 lldb::RunMode stop_other_threads, 484 bool avoid_code_without_debug_info); 485 486 //------------------------------------------------------------------ 487 /// Queue the plan used to step out of the function at the current PC of 488 /// \a thread. 489 /// 490 /// @param[in] abort_other_plans 491 /// \b true if we discard the currently queued plans and replace them with this one. 492 /// Otherwise this plan will go on the end of the plan stack. 493 /// 494 /// @param[in] addr_context 495 /// When dealing with stepping through inlined functions the current PC is not enough information to know 496 /// what "step" means. For instance a series of nested inline functions might start at the same address. 497 // The \a addr_context provides the current symbol context the step 498 /// is supposed to be out of. 499 // FIXME: Currently unused. 500 /// 501 /// @param[in] first_insn 502 /// \b true if this is the first instruction of a function. 503 /// 504 /// @param[in] stop_other_threads 505 /// \b true if we will stop other threads while we single step this one. 506 /// 507 /// @param[in] stop_vote 508 /// @param[in] run_vote 509 /// See standard meanings for the stop & run votes in ThreadPlan.h. 510 /// 511 /// @return 512 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 513 //------------------------------------------------------------------ 514 virtual ThreadPlan * 515 QueueThreadPlanForStepOut (bool abort_other_plans, 516 SymbolContext *addr_context, 517 bool first_insn, 518 bool stop_other_threads, 519 Vote stop_vote, // = eVoteYes, 520 Vote run_vote, // = eVoteNoOpinion); 521 uint32_t frame_idx); 522 523 //------------------------------------------------------------------ 524 /// Gets the plan used to step through the code that steps from a function 525 /// call site at the current PC into the actual function call. 526 /// 527 /// 528 /// @param[in] return_stack_id 529 /// The stack id that we will return to (by setting backstop breakpoints on the return 530 /// address to that frame) if we fail to step through. 531 /// 532 /// @param[in] abort_other_plans 533 /// \b true if we discard the currently queued plans and replace them with this one. 534 /// Otherwise this plan will go on the end of the plan stack. 535 /// 536 /// @param[in] stop_other_threads 537 /// \b true if we will stop other threads while we single step this one. 538 /// 539 /// @return 540 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 541 //------------------------------------------------------------------ 542 virtual ThreadPlan * 543 QueueThreadPlanForStepThrough (StackID &return_stack_id, 544 bool abort_other_plans, 545 bool stop_other_threads); 546 547 //------------------------------------------------------------------ 548 /// Gets the plan used to continue from the current PC. 549 /// This is a simple plan, mostly useful as a backstop when you are continuing 550 /// for some particular purpose. 551 /// 552 /// @param[in] abort_other_plans 553 /// \b true if we discard the currently queued plans and replace them with this one. 554 /// Otherwise this plan will go on the end of the plan stack. 555 /// 556 /// @param[in] target_addr 557 /// The address to which we're running. 558 /// 559 /// @param[in] stop_other_threads 560 /// \b true if we will stop other threads while we single step this one. 561 /// 562 /// @return 563 /// A pointer to the newly queued thread plan, or NULL if the plan could not be queued. 564 //------------------------------------------------------------------ 565 virtual ThreadPlan * 566 QueueThreadPlanForRunToAddress (bool abort_other_plans, 567 Address &target_addr, 568 bool stop_other_threads); 569 570 virtual ThreadPlan * 571 QueueThreadPlanForStepUntil (bool abort_other_plans, 572 lldb::addr_t *address_list, 573 size_t num_addresses, 574 bool stop_others, 575 uint32_t frame_idx); 576 577 virtual ThreadPlan * 578 QueueThreadPlanForCallFunction (bool abort_other_plans, 579 Address& function, 580 lldb::addr_t arg, 581 bool stop_other_threads, 582 bool discard_on_error = false); 583 584 //------------------------------------------------------------------ 585 // Thread Plan accessors: 586 //------------------------------------------------------------------ 587 588 //------------------------------------------------------------------ 589 /// Gets the plan which will execute next on the plan stack. 590 /// 591 /// @return 592 /// A pointer to the next executed plan. 593 //------------------------------------------------------------------ 594 ThreadPlan * 595 GetCurrentPlan (); 596 597private: 598 bool 599 PlanIsBasePlan (ThreadPlan *plan_ptr); 600 601public: 602 603 //------------------------------------------------------------------ 604 /// Gets the outer-most plan that was popped off the plan stack in the 605 /// most recent stop. Useful for printing the stop reason accurately. 606 /// 607 /// @return 608 /// A pointer to the last completed plan. 609 //------------------------------------------------------------------ 610 lldb::ThreadPlanSP 611 GetCompletedPlan (); 612 613 //------------------------------------------------------------------ 614 /// Gets the outer-most return value from the completed plans 615 /// 616 /// @return 617 /// A ValueObjectSP, either empty if there is no return value, 618 /// or containing the return value. 619 //------------------------------------------------------------------ 620 lldb::ValueObjectSP 621 GetReturnValueObject (); 622 623 //------------------------------------------------------------------ 624 /// Checks whether the given plan is in the completed plans for this 625 /// stop. 626 /// 627 /// @param[in] plan 628 /// Pointer to the plan you're checking. 629 /// 630 /// @return 631 /// Returns true if the input plan is in the completed plan stack, 632 /// false otherwise. 633 //------------------------------------------------------------------ 634 bool 635 IsThreadPlanDone (ThreadPlan *plan); 636 637 //------------------------------------------------------------------ 638 /// Checks whether the given plan is in the discarded plans for this 639 /// stop. 640 /// 641 /// @param[in] plan 642 /// Pointer to the plan you're checking. 643 /// 644 /// @return 645 /// Returns true if the input plan is in the discarded plan stack, 646 /// false otherwise. 647 //------------------------------------------------------------------ 648 bool 649 WasThreadPlanDiscarded (ThreadPlan *plan); 650 651 //------------------------------------------------------------------ 652 /// Queues a generic thread plan. 653 /// 654 /// @param[in] plan_sp 655 /// The plan to queue. 656 /// 657 /// @param[in] abort_other_plans 658 /// \b true if we discard the currently queued plans and replace them with this one. 659 /// Otherwise this plan will go on the end of the plan stack. 660 /// 661 /// @return 662 /// A pointer to the last completed plan. 663 //------------------------------------------------------------------ 664 void 665 QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans); 666 667 668 //------------------------------------------------------------------ 669 /// Discards the plans queued on the plan stack of the current thread. This is 670 /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call. 671 // But if \a force is true, all thread plans are discarded. 672 //------------------------------------------------------------------ 673 void 674 DiscardThreadPlans (bool force); 675 676 //------------------------------------------------------------------ 677 /// Discards the plans queued on the plan stack of the current thread up to and 678 /// including up_to_plan_sp. 679 // 680 // @param[in] up_to_plan_sp 681 // Discard all plans up to and including this one. 682 //------------------------------------------------------------------ 683 void 684 DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp); 685 686 void 687 DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr); 688 689 //------------------------------------------------------------------ 690 /// Prints the current plan stack. 691 /// 692 /// @param[in] s 693 /// The stream to which to dump the plan stack info. 694 /// 695 //------------------------------------------------------------------ 696 void 697 DumpThreadPlans (Stream *s) const; 698 699 virtual bool 700 CheckpointThreadState (ThreadStateCheckpoint &saved_state); 701 702 virtual bool 703 RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state); 704 705 void 706 EnableTracer (bool value, bool single_step); 707 708 void 709 SetTracer (lldb::ThreadPlanTracerSP &tracer_sp); 710 711 //------------------------------------------------------------------ 712 /// The regular expression returned determines symbols that this 713 /// thread won't stop in during "step-in" operations. 714 /// 715 /// @return 716 /// A pointer to a regular expression to compare against symbols, 717 /// or NULL if all symbols are allowed. 718 /// 719 //------------------------------------------------------------------ 720 RegularExpression * 721 GetSymbolsToAvoidRegexp() 722 { 723 return ThreadInstanceSettings::GetSymbolsToAvoidRegexp(); 724 } 725 726 // Get the thread index ID. The index ID that is guaranteed to not be 727 // re-used by a process. They start at 1 and increase with each new thread. 728 // This allows easy command line access by a unique ID that is easier to 729 // type than the actual system thread ID. 730 uint32_t 731 GetIndexID () const; 732 733 //------------------------------------------------------------------ 734 // lldb::ExecutionContextScope pure virtual functions 735 //------------------------------------------------------------------ 736 virtual lldb::TargetSP 737 CalculateTarget (); 738 739 virtual lldb::ProcessSP 740 CalculateProcess (); 741 742 virtual lldb::ThreadSP 743 CalculateThread (); 744 745 virtual lldb::StackFrameSP 746 CalculateStackFrame (); 747 748 virtual void 749 CalculateExecutionContext (ExecutionContext &exe_ctx); 750 751 lldb::StackFrameSP 752 GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); 753 754 size_t 755 GetStatus (Stream &strm, 756 uint32_t start_frame, 757 uint32_t num_frames, 758 uint32_t num_frames_with_source); 759 760 size_t 761 GetStackFrameStatus (Stream& strm, 762 uint32_t first_frame, 763 uint32_t num_frames, 764 bool show_frame_info, 765 uint32_t num_frames_with_source); 766 767 // We need a way to verify that even though we have a thread in a shared 768 // pointer that the object itself is still valid. Currently this won't be 769 // the case if DestroyThread() was called. DestroyThread is called when 770 // a thread has been removed from the Process' thread list. 771 bool 772 IsValid () const 773 { 774 return m_destroy_called; 775 } 776 777 // When you implement this method, make sure you don't overwrite the m_actual_stop_info if it claims to be 778 // valid. The stop info may be a "checkpointed and restored" stop info, so if it is still around it is right 779 // even if you have not calculated this yourself, or if it disagrees with what you might have calculated. 780 virtual lldb::StopInfoSP 781 GetPrivateStopReason () = 0; 782 783protected: 784 785 friend class ThreadPlan; 786 friend class ThreadList; 787 friend class StackFrameList; 788 789 // This is necessary to make sure thread assets get destroyed while the thread is still in good shape 790 // to call virtual thread methods. This must be called by classes that derive from Thread in their destructor. 791 virtual void DestroyThread (); 792 793 void 794 PushPlan (lldb::ThreadPlanSP &plan_sp); 795 796 void 797 PopPlan (); 798 799 void 800 DiscardPlan (); 801 802 ThreadPlan *GetPreviousPlan (ThreadPlan *plan); 803 804 typedef std::vector<lldb::ThreadPlanSP> plan_stack; 805 806 void 807 SetStopInfo (const lldb::StopInfoSP &stop_info_sp); 808 809 virtual bool 810 SaveFrameZeroState (RegisterCheckpoint &checkpoint); 811 812 virtual bool 813 RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); 814 815 virtual lldb_private::Unwind * 816 GetUnwinder (); 817 818 lldb::StackFrameListSP 819 GetStackFrameList (); 820 821 lldb::StateType GetTemporaryResumeState() 822 { 823 return m_temporary_resume_state; 824 } 825 826 lldb::StateType SetTemporaryResumeState(lldb::StateType resume_state) 827 { 828 lldb::StateType old_temp_resume_state = m_temporary_resume_state; 829 m_temporary_resume_state = resume_state; 830 return old_temp_resume_state; 831 } 832 833 struct ThreadState 834 { 835 uint32_t orig_stop_id; 836 lldb::StopInfoSP stop_info_sp; 837 RegisterCheckpoint register_backup; 838 }; 839 840 //------------------------------------------------------------------ 841 // Classes that inherit from Process can see and modify these 842 //------------------------------------------------------------------ 843 lldb::ProcessWP m_process_wp; ///< The process that owns this thread. 844 lldb::StopInfoSP m_actual_stop_info_sp; ///< The private stop reason for this thread 845 const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access. 846 lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state. 847 lldb::StateType m_state; ///< The state of our process. 848 mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state. 849 plan_stack m_plan_stack; ///< The stack of plans this thread is executing. 850 plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes. 851 plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes. 852 mutable Mutex m_frame_mutex; ///< Multithreaded protection for m_state. 853 lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops. 854 lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped. 855 int m_resume_signal; ///< The signal that should be used when continuing this thread. 856 lldb::StateType m_resume_state; ///< This state is used to force a thread to be suspended from outside the ThreadPlan logic. 857 lldb::StateType m_temporary_resume_state; ///< This state records what the thread was told to do by the thread plan logic for the current resume. 858 /// It gets set in Thread::WillResume. 859 std::auto_ptr<lldb_private::Unwind> m_unwinder_ap; 860 bool m_destroy_called; // This is used internally to make sure derived Thread classes call DestroyThread. 861 uint32_t m_thread_stop_reason_stop_id; // This is the stop id for which the StopInfo is valid. Can use this so you know that 862 // the thread's m_actual_stop_info_sp is current and you don't have to fetch it again 863 864private: 865 //------------------------------------------------------------------ 866 // For Thread only 867 //------------------------------------------------------------------ 868 869 DISALLOW_COPY_AND_ASSIGN (Thread); 870 871}; 872 873} // namespace lldb_private 874 875#endif // liblldb_Thread_h_ 876