1 //===-- Thread.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Thread_h_
11 #define liblldb_Thread_h_
13 #include "lldb/lldb-private.h"
14 #include "lldb/Host/Mutex.h"
15 #include "lldb/Core/Broadcaster.h"
16 #include "lldb/Core/Event.h"
17 #include "lldb/Core/UserID.h"
18 #include "lldb/Core/UserSettingsController.h"
19 #include "lldb/Target/ExecutionContextScope.h"
20 #include "lldb/Target/StackFrameList.h"
22 #define LLDB_THREAD_MAX_STOP_EXC_DATA 8
24 namespace lldb_private {
26 class ThreadProperties : public Properties
29 ThreadProperties(bool is_global);
34 //------------------------------------------------------------------
35 /// The regular expression returned determines symbols that this
36 /// thread won't stop in during "step-in" operations.
39 /// A pointer to a regular expression to compare against symbols,
40 /// or NULL if all symbols are allowed.
42 //------------------------------------------------------------------
43 const RegularExpression *
44 GetSymbolsToAvoidRegexp();
47 GetTraceEnabledState() const;
50 typedef std::shared_ptr<ThreadProperties> ThreadPropertiesSP;
53 public std::enable_shared_from_this<Thread>,
54 public ThreadProperties,
56 public ExecutionContextScope,
60 //------------------------------------------------------------------
61 /// Broadcaster event bits definitions.
62 //------------------------------------------------------------------
65 eBroadcastBitStackChanged = (1 << 0),
66 eBroadcastBitThreadSuspended = (1 << 1),
67 eBroadcastBitThreadResumed = (1 << 2),
68 eBroadcastBitSelectedFrameChanged = (1 << 3),
69 eBroadcastBitThreadSelected = (1 << 4)
72 static ConstString &GetStaticBroadcasterClass ();
74 virtual ConstString &GetBroadcasterClass() const
76 return GetStaticBroadcasterClass();
79 class ThreadEventData :
83 ThreadEventData (const lldb::ThreadSP thread_sp);
85 ThreadEventData (const lldb::ThreadSP thread_sp, const StackID &stack_id);
89 virtual ~ThreadEventData();
91 static const ConstString &
94 virtual const ConstString &
97 return ThreadEventData::GetFlavorString ();
101 Dump (Stream *s) const;
103 static const ThreadEventData *
104 GetEventDataFromEvent (const Event *event_ptr);
106 static lldb::ThreadSP
107 GetThreadFromEvent (const Event *event_ptr);
110 GetStackIDFromEvent (const Event *event_ptr);
112 static lldb::StackFrameSP
113 GetStackFrameFromEvent (const Event *event_ptr);
128 lldb::ThreadSP m_thread_sp;
130 DISALLOW_COPY_AND_ASSIGN (ThreadEventData);
133 // TODO: You shouldn't just checkpoint the register state alone, so this should get
134 // moved to protected. To do that ThreadStateCheckpoint needs to be returned as a token...
135 class RegisterCheckpoint
139 RegisterCheckpoint() :
145 RegisterCheckpoint (const StackID &stack_id) :
146 m_stack_id (stack_id),
151 ~RegisterCheckpoint()
155 const RegisterCheckpoint&
156 operator= (const RegisterCheckpoint &rhs)
160 this->m_stack_id = rhs.m_stack_id;
161 this->m_data_sp = rhs.m_data_sp;
166 RegisterCheckpoint (const RegisterCheckpoint &rhs) :
167 m_stack_id (rhs.m_stack_id),
168 m_data_sp (rhs.m_data_sp)
179 SetStackID (const StackID &stack_id)
181 m_stack_id = stack_id;
190 const lldb::DataBufferSP &
198 lldb::DataBufferSP m_data_sp;
201 struct ThreadStateCheckpoint
203 uint32_t orig_stop_id; // Dunno if I need this yet but it is an interesting bit of data.
204 lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you might continue with the wrong signals.
205 RegisterCheckpoint register_backup; // You need to restore the registers, of course...
206 uint32_t current_inlined_depth;
207 lldb::addr_t current_inlined_pc;
211 SettingsInitialize ();
214 SettingsTerminate ();
216 static const ThreadPropertiesSP &
217 GetGlobalProperties();
219 Thread (Process &process, lldb::tid_t tid);
225 return m_process_wp.lock();
229 GetResumeSignal () const
231 return m_resume_signal;
235 SetResumeSignal (int signal)
237 m_resume_signal = signal;
244 SetState (lldb::StateType state);
247 GetResumeState () const
249 return m_resume_state;
253 SetResumeState (lldb::StateType state)
255 m_resume_state = state;
258 // This function is called on all the threads before "ShouldResume" and
259 // "WillResume" in case a thread needs to change its state before the
260 // ThreadList polls all the threads to figure out which ones actually
261 // will get to run and how.
265 // Do not override this function, it is for thread plan logic only
267 ShouldResume (lldb::StateType resume_state);
269 // Override this to do platform specific tasks before resume.
271 WillResume (lldb::StateType resume_state)
275 // This clears generic thread state after a resume. If you subclass this,
276 // be sure to call it.
280 // This notifies the thread when a private stop occurs.
285 RefreshStateAfterStop() = 0;
291 ShouldStop (Event *event_ptr);
294 ShouldReportStop (Event *event_ptr);
297 ShouldReportRun (Event *event_ptr);
302 // Return whether this thread matches the specification in ThreadSpec. This is a virtual
303 // method because at some point we may extend the thread spec with a platform specific
304 // dictionary of attributes, which then only the platform specific Thread implementation
305 // would know how to match. For now, this just calls through to the ThreadSpec's
306 // ThreadPassesBasicTests method.
308 MatchesSpec (const ThreadSpec *spec);
316 // This sets the stop reason to a "blank" stop reason, so you can call functions on the thread
317 // without having the called function run with whatever stop reason you stopped with.
319 SetStopInfoToNothing();
322 ThreadStoppedForAReason ();
325 RunModeAsCString (lldb::RunMode mode);
328 StopReasonAsCString (lldb::StopReason reason);
351 return GetStackFrameList()->GetNumFrames();
354 virtual lldb::StackFrameSP
355 GetStackFrameAtIndex (uint32_t idx)
357 return GetStackFrameList()->GetFrameAtIndex(idx);
360 virtual lldb::StackFrameSP
361 GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
364 DecrementCurrentInlinedDepth()
366 return GetStackFrameList()->DecrementCurrentInlinedDepth();
370 GetCurrentInlinedDepth()
372 return GetStackFrameList()->GetCurrentInlinedDepth();
376 ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
379 ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
381 virtual lldb::StackFrameSP
382 GetFrameWithStackID (const StackID &stack_id)
384 if (stack_id.IsValid())
385 return GetStackFrameList()->GetFrameWithStackID (stack_id);
386 return lldb::StackFrameSP();
390 GetSelectedFrameIndex ()
392 return GetStackFrameList()->GetSelectedFrameIndex();
398 lldb::StackFrameListSP stack_frame_list_sp(GetStackFrameList());
399 return stack_frame_list_sp->GetFrameAtIndex (stack_frame_list_sp->GetSelectedFrameIndex());
403 SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast = false);
407 SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast = false);
410 SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_stream);
413 SetDefaultFileAndLineToSelectedFrame()
415 GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
418 virtual lldb::RegisterContextSP
419 GetRegisterContext () = 0;
421 virtual lldb::RegisterContextSP
422 CreateRegisterContextForFrame (StackFrame *frame) = 0;
428 SetBackingThread (const lldb::ThreadSP &thread_sp)
433 virtual lldb::ThreadSP
434 GetBackingThread () const
436 return lldb::ThreadSP();
440 ClearBackingThread ()
442 // Subclasses can use this function if a thread is actually backed by
443 // another thread. This is currently used for the OperatingSystem plug-ins
444 // where they might have a thread that is in memory, yet its registers
445 // are available through the lldb_private::Thread subclass for the current
446 // lldb_private::Process class. Since each time the process stops the backing
447 // threads for memory threads can change, we need a way to clear the backing
448 // thread for all memory threads each time we stop.
452 DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
454 //------------------------------------------------------------------
455 // Thread Plan Providers:
456 // This section provides the basic thread plans that the Process control
457 // machinery uses to run the target. ThreadPlan.h provides more details on
458 // how this mechanism works.
459 // The thread provides accessors to a set of plans that perform basic operations.
460 // The idea is that particular Platform plugins can override these methods to
461 // provide the implementation of these basic operations appropriate to their
464 // NB: All the QueueThreadPlanXXX providers return Shared Pointers to
465 // Thread plans. This is useful so that you can modify the plans after
466 // creation in ways specific to that plan type. Also, it is often necessary for
467 // ThreadPlans that utilize other ThreadPlans to implement their task to keep a shared
468 // pointer to the sub-plan.
469 // But besides that, the shared pointers should only be held onto by entities who live no longer
470 // than the thread containing the ThreadPlan.
471 // FIXME: If this becomes a problem, we can make a version that just returns a pointer,
472 // which it is clearly unsafe to hold onto, and a shared pointer version, and only allow
473 // ThreadPlan and Co. to use the latter. That is made more annoying to do because there's
474 // no elegant way to friend a method to all sub-classes of a given class.
476 //------------------------------------------------------------------
478 //------------------------------------------------------------------
479 /// Queues the base plan for a thread.
480 /// The version returned by Process does some things that are useful,
481 /// like handle breakpoints and signals, so if you return a plugin specific
482 /// one you probably want to call through to the Process one for anything
483 /// your plugin doesn't explicitly handle.
485 /// @param[in] abort_other_plans
486 /// \b true if we discard the currently queued plans and replace them with this one.
487 /// Otherwise this plan will go on the end of the plan stack.
490 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
491 //------------------------------------------------------------------
492 virtual lldb::ThreadPlanSP
493 QueueFundamentalPlan (bool abort_other_plans);
495 //------------------------------------------------------------------
496 /// Queues the plan used to step over a breakpoint at the current PC of \a thread.
497 /// The default version returned by Process handles trap based breakpoints, and
498 /// will disable the breakpoint, single step over it, then re-enable it.
500 /// @param[in] abort_other_plans
501 /// \b true if we discard the currently queued plans and replace them with this one.
502 /// Otherwise this plan will go on the end of the plan stack.
505 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
506 //------------------------------------------------------------------
507 virtual lldb::ThreadPlanSP
508 QueueThreadPlanForStepOverBreakpointPlan (bool abort_other_plans);
510 //------------------------------------------------------------------
511 /// Queues the plan used to step one instruction from the current PC of \a thread.
513 /// @param[in] step_over
514 /// \b true if we step over calls to functions, false if we step in.
516 /// @param[in] abort_other_plans
517 /// \b true if we discard the currently queued plans and replace them with this one.
518 /// Otherwise this plan will go on the end of the plan stack.
520 /// @param[in] stop_other_threads
521 /// \b true if we will stop other threads while we single step this one.
524 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
525 //------------------------------------------------------------------
526 virtual lldb::ThreadPlanSP
527 QueueThreadPlanForStepSingleInstruction (bool step_over,
528 bool abort_other_plans,
529 bool stop_other_threads);
531 //------------------------------------------------------------------
532 /// Queues the plan used to step through an address range, stepping over
535 /// @param[in] abort_other_plans
536 /// \b true if we discard the currently queued plans and replace them with this one.
537 /// Otherwise this plan will go on the end of the plan stack.
540 /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
543 /// The address range to step through.
545 /// @param[in] addr_context
546 /// When dealing with stepping through inlined functions the current PC is not enough information to know
547 /// what "step" means. For instance a series of nested inline functions might start at the same address.
548 // The \a addr_context provides the current symbol context the step
549 /// is supposed to be out of.
550 // FIXME: Currently unused.
552 /// @param[in] stop_other_threads
553 /// \b true if we will stop other threads while we single step this one.
556 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
557 //------------------------------------------------------------------
558 virtual lldb::ThreadPlanSP
559 QueueThreadPlanForStepOverRange (bool abort_other_plans,
560 const AddressRange &range,
561 const SymbolContext &addr_context,
562 lldb::RunMode stop_other_threads);
564 //------------------------------------------------------------------
565 /// Queues the plan used to step through an address range, stepping into functions.
567 /// @param[in] abort_other_plans
568 /// \b true if we discard the currently queued plans and replace them with this one.
569 /// Otherwise this plan will go on the end of the plan stack.
572 /// Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
575 /// The address range to step through.
577 /// @param[in] addr_context
578 /// When dealing with stepping through inlined functions the current PC is not enough information to know
579 /// what "step" means. For instance a series of nested inline functions might start at the same address.
580 // The \a addr_context provides the current symbol context the step
581 /// is supposed to be out of.
582 // FIXME: Currently unused.
584 /// @param[in] step_in_target
585 /// Name if function we are trying to step into. We will step out if we don't land in that function.
587 /// @param[in] stop_other_threads
588 /// \b true if we will stop other threads while we single step this one.
590 /// @param[in] avoid_code_without_debug_info
591 /// If \b true we will step out if we step into code with no debug info.
594 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
595 //------------------------------------------------------------------
596 virtual lldb::ThreadPlanSP
597 QueueThreadPlanForStepInRange (bool abort_other_plans,
598 const AddressRange &range,
599 const SymbolContext &addr_context,
600 const char *step_in_target,
601 lldb::RunMode stop_other_threads,
602 bool avoid_code_without_debug_info);
604 //------------------------------------------------------------------
605 /// Queue the plan used to step out of the function at the current PC of
608 /// @param[in] abort_other_plans
609 /// \b true if we discard the currently queued plans and replace them with this one.
610 /// Otherwise this plan will go on the end of the plan stack.
612 /// @param[in] addr_context
613 /// When dealing with stepping through inlined functions the current PC is not enough information to know
614 /// what "step" means. For instance a series of nested inline functions might start at the same address.
615 // The \a addr_context provides the current symbol context the step
616 /// is supposed to be out of.
617 // FIXME: Currently unused.
619 /// @param[in] first_insn
620 /// \b true if this is the first instruction of a function.
622 /// @param[in] stop_other_threads
623 /// \b true if we will stop other threads while we single step this one.
625 /// @param[in] stop_vote
626 /// @param[in] run_vote
627 /// See standard meanings for the stop & run votes in ThreadPlan.h.
630 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
631 //------------------------------------------------------------------
632 virtual lldb::ThreadPlanSP
633 QueueThreadPlanForStepOut (bool abort_other_plans,
634 SymbolContext *addr_context,
636 bool stop_other_threads,
637 Vote stop_vote, // = eVoteYes,
638 Vote run_vote, // = eVoteNoOpinion);
641 //------------------------------------------------------------------
642 /// Gets the plan used to step through the code that steps from a function
643 /// call site at the current PC into the actual function call.
646 /// @param[in] return_stack_id
647 /// The stack id that we will return to (by setting backstop breakpoints on the return
648 /// address to that frame) if we fail to step through.
650 /// @param[in] abort_other_plans
651 /// \b true if we discard the currently queued plans and replace them with this one.
652 /// Otherwise this plan will go on the end of the plan stack.
654 /// @param[in] stop_other_threads
655 /// \b true if we will stop other threads while we single step this one.
658 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
659 //------------------------------------------------------------------
660 virtual lldb::ThreadPlanSP
661 QueueThreadPlanForStepThrough (StackID &return_stack_id,
662 bool abort_other_plans,
663 bool stop_other_threads);
665 //------------------------------------------------------------------
666 /// Gets the plan used to continue from the current PC.
667 /// This is a simple plan, mostly useful as a backstop when you are continuing
668 /// for some particular purpose.
670 /// @param[in] abort_other_plans
671 /// \b true if we discard the currently queued plans and replace them with this one.
672 /// Otherwise this plan will go on the end of the plan stack.
674 /// @param[in] target_addr
675 /// The address to which we're running.
677 /// @param[in] stop_other_threads
678 /// \b true if we will stop other threads while we single step this one.
681 /// A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
682 //------------------------------------------------------------------
683 virtual lldb::ThreadPlanSP
684 QueueThreadPlanForRunToAddress (bool abort_other_plans,
685 Address &target_addr,
686 bool stop_other_threads);
688 virtual lldb::ThreadPlanSP
689 QueueThreadPlanForStepUntil (bool abort_other_plans,
690 lldb::addr_t *address_list,
691 size_t num_addresses,
695 virtual lldb::ThreadPlanSP
696 QueueThreadPlanForCallFunction (bool abort_other_plans,
699 bool stop_other_threads,
700 bool unwind_on_error = false,
701 bool ignore_breakpoints = true);
703 //------------------------------------------------------------------
704 // Thread Plan accessors:
705 //------------------------------------------------------------------
707 //------------------------------------------------------------------
708 /// Gets the plan which will execute next on the plan stack.
711 /// A pointer to the next executed plan.
712 //------------------------------------------------------------------
716 //------------------------------------------------------------------
717 /// Unwinds the thread stack for the innermost expression plan currently
718 /// on the thread plan stack.
721 /// An error if the thread plan could not be unwound.
722 //------------------------------------------------------------------
725 UnwindInnermostExpression();
729 PlanIsBasePlan (ThreadPlan *plan_ptr);
732 BroadcastSelectedFrameChange(StackID &new_frame_id);
736 //------------------------------------------------------------------
737 /// Gets the outer-most plan that was popped off the plan stack in the
738 /// most recent stop. Useful for printing the stop reason accurately.
741 /// A pointer to the last completed plan.
742 //------------------------------------------------------------------
746 //------------------------------------------------------------------
747 /// Gets the outer-most return value from the completed plans
750 /// A ValueObjectSP, either empty if there is no return value,
751 /// or containing the return value.
752 //------------------------------------------------------------------
754 GetReturnValueObject ();
756 //------------------------------------------------------------------
757 /// Checks whether the given plan is in the completed plans for this
761 /// Pointer to the plan you're checking.
764 /// Returns true if the input plan is in the completed plan stack,
766 //------------------------------------------------------------------
768 IsThreadPlanDone (ThreadPlan *plan);
770 //------------------------------------------------------------------
771 /// Checks whether the given plan is in the discarded plans for this
775 /// Pointer to the plan you're checking.
778 /// Returns true if the input plan is in the discarded plan stack,
780 //------------------------------------------------------------------
782 WasThreadPlanDiscarded (ThreadPlan *plan);
784 //------------------------------------------------------------------
785 /// Queues a generic thread plan.
787 /// @param[in] plan_sp
788 /// The plan to queue.
790 /// @param[in] abort_other_plans
791 /// \b true if we discard the currently queued plans and replace them with this one.
792 /// Otherwise this plan will go on the end of the plan stack.
795 /// A pointer to the last completed plan.
796 //------------------------------------------------------------------
798 QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
801 //------------------------------------------------------------------
802 /// Discards the plans queued on the plan stack of the current thread. This is
803 /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
804 // But if \a force is true, all thread plans are discarded.
805 //------------------------------------------------------------------
807 DiscardThreadPlans (bool force);
809 //------------------------------------------------------------------
810 /// Discards the plans queued on the plan stack of the current thread up to and
811 /// including up_to_plan_sp.
813 // @param[in] up_to_plan_sp
814 // Discard all plans up to and including this one.
815 //------------------------------------------------------------------
817 DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp);
820 DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr);
822 //------------------------------------------------------------------
823 /// Prints the current plan stack.
826 /// The stream to which to dump the plan stack info.
828 //------------------------------------------------------------------
830 DumpThreadPlans (Stream *s) const;
833 CheckpointThreadState (ThreadStateCheckpoint &saved_state);
836 RestoreRegisterStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
839 RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
842 EnableTracer (bool value, bool single_step);
845 SetTracer (lldb::ThreadPlanTracerSP &tracer_sp);
847 //------------------------------------------------------------------
848 // Get the thread index ID. The index ID that is guaranteed to not
849 // be re-used by a process. They start at 1 and increase with each
850 // new thread. This allows easy command line access by a unique ID
851 // that is easier to type than the actual system thread ID.
852 //------------------------------------------------------------------
857 //------------------------------------------------------------------
858 // The API ID is often the same as the Thread::GetID(), but not in
859 // all cases. Thread::GetID() is the user visible thread ID that
860 // clients would want to see. The API thread ID is the thread ID
861 // that is used when sending data to/from the debugging protocol.
862 //------------------------------------------------------------------
863 virtual lldb::user_id_t
864 GetProtocolID () const
869 //------------------------------------------------------------------
870 // lldb::ExecutionContextScope pure virtual functions
871 //------------------------------------------------------------------
872 virtual lldb::TargetSP
875 virtual lldb::ProcessSP
878 virtual lldb::ThreadSP
881 virtual lldb::StackFrameSP
882 CalculateStackFrame ();
885 CalculateExecutionContext (ExecutionContext &exe_ctx);
888 GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
891 GetStatus (Stream &strm,
892 uint32_t start_frame,
894 uint32_t num_frames_with_source);
897 GetStackFrameStatus (Stream& strm,
898 uint32_t first_frame,
900 bool show_frame_info,
901 uint32_t num_frames_with_source);
903 // We need a way to verify that even though we have a thread in a shared
904 // pointer that the object itself is still valid. Currently this won't be
905 // the case if DestroyThread() was called. DestroyThread is called when
906 // a thread has been removed from the Process' thread list.
910 return !m_destroy_called;
913 // Sets and returns a valid stop info based on the process stop ID and the
914 // current thread plan. If the thread stop ID does not match the process'
915 // stop ID, the private stop reason is not set and an invalid StopInfoSP may
918 // NOTE: This function must be called before the current thread plan is
919 // moved to the completed plan stack (in Thread::ShouldStop()).
921 // NOTE: If subclasses override this function, ensure they do not overwrite
922 // the m_actual_stop_info if it is valid. The stop info may be a
923 // "checkpointed and restored" stop info, so if it is still around it is
924 // right even if you have not calculated this yourself, or if it disagrees
925 // with what you might have calculated.
926 virtual lldb::StopInfoSP
927 GetPrivateStopInfo ();
929 //----------------------------------------------------------------------
930 // Ask the thread subclass to set its stop info.
932 // Thread subclasses should call Thread::SetStopInfo(...) with the
933 // reason the thread stopped.
936 // True if Thread::SetStopInfo(...) was called, false otherwise.
937 //----------------------------------------------------------------------
939 CalculateStopInfo () = 0;
941 //----------------------------------------------------------------------
942 // Gets the temporary resume state for a thread.
944 // This value gets set in each thread by complex debugger logic in
945 // Thread::ShouldResume() and an appropriate thread resume state will get
946 // set in each thread every time the process is resumed prior to calling
947 // Process::DoResume(). The lldb_private::Process subclass should adhere
948 // to the thread resume state request which will be one of:
950 // eStateRunning - thread will resume when process is resumed
951 // eStateStepping - thread should step 1 instruction and stop when process
953 // eStateSuspended - thread should not execute any instructions when
954 // process is resumed
955 //----------------------------------------------------------------------
957 GetTemporaryResumeState() const
959 return m_temporary_resume_state;
963 SetStopInfo (const lldb::StopInfoSP &stop_info_sp);
966 SetShouldReportStop (Vote vote);
970 friend class ThreadPlan;
971 friend class ThreadList;
972 friend class ThreadEventData;
973 friend class StackFrameList;
974 friend class StackFrame;
975 friend class OperatingSystem;
977 // This is necessary to make sure thread assets get destroyed while the thread is still in good shape
978 // to call virtual thread methods. This must be called by classes that derive from Thread in their destructor.
979 virtual void DestroyThread ();
982 PushPlan (lldb::ThreadPlanSP &plan_sp);
990 ThreadPlan *GetPreviousPlan (ThreadPlan *plan);
992 typedef std::vector<lldb::ThreadPlanSP> plan_stack;
995 SaveFrameZeroState (RegisterCheckpoint &checkpoint);
998 RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
1000 // register_data_sp must be a DataSP passed to ReadAllRegisterValues.
1002 ResetFrameZeroRegisters (lldb::DataBufferSP register_data_sp);
1004 virtual lldb_private::Unwind *
1007 // Check to see whether the thread is still at the last breakpoint hit that stopped it.
1009 IsStillAtLastBreakpointHit();
1011 // Some threads are threads that are made up by OperatingSystem plugins that
1012 // are threads that exist and are context switched out into memory. The
1013 // OperatingSystem plug-in need a ways to know if a thread is "real" or made
1016 IsOperatingSystemPluginThread () const
1022 lldb::StackFrameListSP
1023 GetStackFrameList ();
1027 uint32_t orig_stop_id;
1028 lldb::StopInfoSP stop_info_sp;
1029 RegisterCheckpoint register_backup;
1032 //------------------------------------------------------------------
1033 // Classes that inherit from Process can see and modify these
1034 //------------------------------------------------------------------
1035 lldb::ProcessWP m_process_wp; ///< The process that owns this thread.
1036 lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread
1037 uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is valid. Can use this so you know that
1038 // the thread's m_stop_info_sp is current and you don't have to fetch it again
1039 const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access.
1040 lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state.
1041 lldb::StateType m_state; ///< The state of our process.
1042 mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state.
1043 plan_stack m_plan_stack; ///< The stack of plans this thread is executing.
1044 plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes.
1045 plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes.
1046 mutable Mutex m_frame_mutex; ///< Multithreaded protection for m_state.
1047 lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops.
1048 lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped.
1049 int m_resume_signal; ///< The signal that should be used when continuing this thread.
1050 lldb::StateType m_resume_state; ///< This state is used to force a thread to be suspended from outside the ThreadPlan logic.
1051 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.
1052 /// It gets set in Thread::ShoudResume.
1053 std::unique_ptr<lldb_private::Unwind> m_unwinder_ap;
1054 bool m_destroy_called; // This is used internally to make sure derived Thread classes call DestroyThread.
1055 LazyBool m_override_should_notify;
1057 //------------------------------------------------------------------
1059 //------------------------------------------------------------------
1061 DISALLOW_COPY_AND_ASSIGN (Thread);
1065 } // namespace lldb_private
1067 #endif // liblldb_Thread_h_