xref: /NextBSD/contrib/llvm/tools/lldb/include/lldb/Target/Thread.h (revision 84d351007654069f9643c8e4b4802a7f5f08ee42)
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/Broadcaster.h"
16 #include "lldb/Core/Event.h"
17 #include "lldb/Core/StructuredData.h"
18 #include "lldb/Core/UserID.h"
19 #include "lldb/Core/UserSettingsController.h"
20 #include "lldb/Target/ExecutionContextScope.h"
21 #include "lldb/Target/RegisterCheckpoint.h"
22 #include "lldb/Target/StackFrameList.h"
23 
24 #define LLDB_THREAD_MAX_STOP_EXC_DATA 8
25 
26 namespace lldb_private {
27 
28 class ThreadProperties : public Properties
29 {
30 public:
31     ThreadProperties(bool is_global);
32 
33     virtual
34     ~ThreadProperties();
35 
36     //------------------------------------------------------------------
37     /// The regular expression returned determines symbols that this
38     /// thread won't stop in during "step-in" operations.
39     ///
40     /// @return
41     ///    A pointer to a regular expression to compare against symbols,
42     ///    or NULL if all symbols are allowed.
43     ///
44     //------------------------------------------------------------------
45     const RegularExpression *
46     GetSymbolsToAvoidRegexp();
47 
48     FileSpecList &
49     GetLibrariesToAvoid() const;
50 
51     bool
52     GetTraceEnabledState() const;
53 
54     bool
55     GetStepInAvoidsNoDebug () const;
56 
57     bool
58     GetStepOutAvoidsNoDebug () const;
59 };
60 
61 typedef std::shared_ptr<ThreadProperties> ThreadPropertiesSP;
62 
63 class Thread :
64     public std::enable_shared_from_this<Thread>,
65     public ThreadProperties,
66     public UserID,
67     public ExecutionContextScope,
68     public Broadcaster
69 {
70 public:
71     //------------------------------------------------------------------
72     /// Broadcaster event bits definitions.
73     //------------------------------------------------------------------
74     enum
75     {
76         eBroadcastBitStackChanged           = (1 << 0),
77         eBroadcastBitThreadSuspended        = (1 << 1),
78         eBroadcastBitThreadResumed          = (1 << 2),
79         eBroadcastBitSelectedFrameChanged   = (1 << 3),
80         eBroadcastBitThreadSelected         = (1 << 4)
81     };
82 
83     static ConstString &GetStaticBroadcasterClass ();
84 
GetBroadcasterClass()85     virtual ConstString &GetBroadcasterClass() const
86     {
87         return GetStaticBroadcasterClass();
88     }
89 
90     class ThreadEventData :
91         public EventData
92     {
93     public:
94         ThreadEventData (const lldb::ThreadSP thread_sp);
95 
96         ThreadEventData (const lldb::ThreadSP thread_sp, const StackID &stack_id);
97 
98         ThreadEventData();
99 
100         virtual ~ThreadEventData();
101 
102         static const ConstString &
103         GetFlavorString ();
104 
105         virtual const ConstString &
GetFlavor()106         GetFlavor () const
107         {
108             return ThreadEventData::GetFlavorString ();
109         }
110 
111         virtual void
112         Dump (Stream *s) const;
113 
114         static const ThreadEventData *
115         GetEventDataFromEvent (const Event *event_ptr);
116 
117         static lldb::ThreadSP
118         GetThreadFromEvent (const Event *event_ptr);
119 
120         static StackID
121         GetStackIDFromEvent (const Event *event_ptr);
122 
123         static lldb::StackFrameSP
124         GetStackFrameFromEvent (const Event *event_ptr);
125 
126         lldb::ThreadSP
GetThread()127         GetThread () const
128         {
129             return m_thread_sp;
130         }
131 
132         StackID
GetStackID()133         GetStackID () const
134         {
135             return m_stack_id;
136         }
137 
138     private:
139         lldb::ThreadSP m_thread_sp;
140         StackID        m_stack_id;
141     DISALLOW_COPY_AND_ASSIGN (ThreadEventData);
142     };
143 
144 
145     struct ThreadStateCheckpoint
146     {
147         uint32_t           orig_stop_id;  // Dunno if I need this yet but it is an interesting bit of data.
148         lldb::StopInfoSP   stop_info_sp;  // You have to restore the stop info or you might continue with the wrong signals.
149         lldb::RegisterCheckpointSP register_backup_sp;  // You need to restore the registers, of course...
150         uint32_t           current_inlined_depth;
151         lldb::addr_t       current_inlined_pc;
152     };
153 
154     static void
155     SettingsInitialize ();
156 
157     static void
158     SettingsTerminate ();
159 
160     static const ThreadPropertiesSP &
161     GetGlobalProperties();
162 
163     //------------------------------------------------------------------
164     /// Constructor
165     ///
166     /// @param [in] process
167     ///
168     /// @param [in] tid
169     ///
170     /// @param [in] use_invalid_index_id
171     ///     Optional parameter, defaults to false.  The only subclass that
172     ///     is likely to set use_invalid_index_id == true is the HistoryThread
173     ///     class.  In that case, the Thread we are constructing represents
174     ///     a thread from earlier in the program execution.  We may have the
175     ///     tid of the original thread that they represent but we don't want
176     ///     to reuse the IndexID of that thread, or create a new one.  If a
177     ///     client wants to know the original thread's IndexID, they should use
178     ///     Thread::GetExtendedBacktraceOriginatingIndexID().
179     //------------------------------------------------------------------
180     Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id = false);
181 
182     virtual ~Thread();
183 
184     lldb::ProcessSP
GetProcess()185     GetProcess() const
186     {
187         return m_process_wp.lock();
188     }
189 
190     int
GetResumeSignal()191     GetResumeSignal () const
192     {
193         return m_resume_signal;
194     }
195 
196     void
SetResumeSignal(int signal)197     SetResumeSignal (int signal)
198     {
199         m_resume_signal = signal;
200     }
201 
202     lldb::StateType
203     GetState() const;
204 
205     void
206     SetState (lldb::StateType state);
207 
208     //------------------------------------------------------------------
209     /// Sets the USER resume state for this thread.  If you set a thread to suspended with
210     /// this API, it won't take part in any of the arbitration for ShouldResume, and will stay
211     /// suspended even when other threads do get to run.
212     ///
213     /// N.B. This is not the state that is used internally by thread plans to implement
214     /// staying on one thread while stepping over a breakpoint, etc.  The is the
215     /// TemporaryResume state, and if you are implementing some bit of strategy in the stepping
216     /// machinery you should be using that state and not the user resume state.
217     ///
218     /// If you are just preparing all threads to run, you should not override the threads that are
219     /// marked as suspended by the debugger.  In that case, pass override_suspend = false.  If you want
220     /// to force the thread to run (e.g. the "thread continue" command, or are resetting the state
221     /// (e.g. in SBThread::Resume()), then pass true to override_suspend.
222     /// @return
223     ///    The User resume state for this thread.
224     //------------------------------------------------------------------
225     void
226     SetResumeState (lldb::StateType state, bool override_suspend = false)
227     {
228         if (m_resume_state == lldb::eStateSuspended && !override_suspend)
229             return;
230         m_resume_state = state;
231     }
232 
233     //------------------------------------------------------------------
234     /// Gets the USER resume state for this thread.  This is not the same as what
235     /// this thread is going to do for any particular step, however if this thread
236     /// returns eStateSuspended, then the process control logic will never allow this
237     /// thread to run.
238     ///
239     /// @return
240     ///    The User resume state for this thread.
241     //------------------------------------------------------------------
242     lldb::StateType
GetResumeState()243     GetResumeState () const
244     {
245         return m_resume_state;
246     }
247 
248     // This function is called on all the threads before "ShouldResume" and
249     // "WillResume" in case a thread needs to change its state before the
250     // ThreadList polls all the threads to figure out which ones actually
251     // will get to run and how.
252     void
253     SetupForResume ();
254 
255     // Do not override this function, it is for thread plan logic only
256     bool
257     ShouldResume (lldb::StateType resume_state);
258 
259     // Override this to do platform specific tasks before resume.
260     virtual void
WillResume(lldb::StateType resume_state)261     WillResume (lldb::StateType resume_state)
262     {
263     }
264 
265     // This clears generic thread state after a resume.  If you subclass this,
266     // be sure to call it.
267     virtual void
268     DidResume ();
269 
270     // This notifies the thread when a private stop occurs.
271     virtual void
272     DidStop ();
273 
274     virtual void
275     RefreshStateAfterStop() = 0;
276 
277     void
278     WillStop ();
279 
280     bool
281     ShouldStop (Event *event_ptr);
282 
283     Vote
284     ShouldReportStop (Event *event_ptr);
285 
286     Vote
287     ShouldReportRun (Event *event_ptr);
288 
289     void
290     Flush ();
291 
292     // Return whether this thread matches the specification in ThreadSpec.  This is a virtual
293     // method because at some point we may extend the thread spec with a platform specific
294     // dictionary of attributes, which then only the platform specific Thread implementation
295     // would know how to match.  For now, this just calls through to the ThreadSpec's
296     // ThreadPassesBasicTests method.
297     virtual bool
298     MatchesSpec (const ThreadSpec *spec);
299 
300     lldb::StopInfoSP
301     GetStopInfo ();
302 
303     lldb::StopReason
304     GetStopReason();
305 
306     // This sets the stop reason to a "blank" stop reason, so you can call functions on the thread
307     // without having the called function run with whatever stop reason you stopped with.
308     void
309     SetStopInfoToNothing();
310 
311     bool
312     ThreadStoppedForAReason ();
313 
314     static const char *
315     RunModeAsCString (lldb::RunMode mode);
316 
317     static const char *
318     StopReasonAsCString (lldb::StopReason reason);
319 
320     virtual const char *
GetInfo()321     GetInfo ()
322     {
323         return NULL;
324     }
325 
326     //------------------------------------------------------------------
327     /// Retrieve a dictionary of information about this thread
328     ///
329     /// On Mac OS X systems there may be voucher information.
330     /// The top level dictionary returned will have an "activity" key and the
331     /// value of the activity is a dictionary.  Keys in that dictionary will
332     /// be "name" and "id", among others.
333     /// There may also be "trace_messages" (an array) with each entry in that array
334     /// being a dictionary (keys include "message" with the text of the trace
335     /// message).
336     //------------------------------------------------------------------
337     StructuredData::ObjectSP
GetExtendedInfo()338     GetExtendedInfo ()
339     {
340         if (m_extended_info_fetched == false)
341         {
342             m_extended_info = FetchThreadExtendedInfo ();
343             m_extended_info_fetched = true;
344         }
345         return m_extended_info;
346     }
347 
348     virtual const char *
GetName()349     GetName ()
350     {
351         return NULL;
352     }
353 
354     virtual void
SetName(const char * name)355     SetName (const char *name)
356     {
357     }
358 
359     //------------------------------------------------------------------
360     /// Retrieve the Queue ID for the queue currently using this Thread
361     ///
362     /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
363     /// retrieve the QueueID.
364     ///
365     /// This is a unique identifier for the libdispatch/GCD queue in a
366     /// process.  Often starting at 1 for the initial system-created
367     /// queues and incrementing, a QueueID will not be reused for a
368     /// different queue during the lifetime of a proces.
369     ///
370     /// @return
371     ///     A QueueID if the Thread subclass implements this, else
372     ///     LLDB_INVALID_QUEUE_ID.
373     //------------------------------------------------------------------
374     virtual lldb::queue_id_t
GetQueueID()375     GetQueueID ()
376     {
377         return LLDB_INVALID_QUEUE_ID;
378     }
379 
380     virtual void
SetQueueID(lldb::queue_id_t new_val)381     SetQueueID (lldb::queue_id_t new_val)
382     {
383     }
384 
385     //------------------------------------------------------------------
386     /// Retrieve the Queue name for the queue currently using this Thread
387     ///
388     /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
389     /// retrieve the Queue name.
390     ///
391     /// @return
392     ///     The Queue name, if the Thread subclass implements this, else
393     ///     NULL.
394     //------------------------------------------------------------------
395     virtual const char *
GetQueueName()396     GetQueueName ()
397     {
398         return NULL;
399     }
400 
401     virtual void
SetQueueName(const char * name)402     SetQueueName (const char *name)
403     {
404     }
405 
406     //------------------------------------------------------------------
407     /// Retrieve the Queue for this thread, if any.
408     ///
409     /// @return
410     ///     A QueueSP for the queue that is currently associated with this
411     ///     thread.
412     ///     An empty shared pointer indicates that this thread is not
413     ///     associated with a queue, or libdispatch queues are not
414     ///     supported on this target.
415     //------------------------------------------------------------------
416     virtual lldb::QueueSP
GetQueue()417     GetQueue ()
418     {
419         return lldb::QueueSP();
420     }
421 
422     //------------------------------------------------------------------
423     /// Retrieve the address of the libdispatch_queue_t struct for queue
424     /// currently using this Thread
425     ///
426     /// If this Thread is doing work on behalf of a libdispatch/GCD queue,
427     /// retrieve the address of the libdispatch_queue_t structure describing
428     /// the queue.
429     ///
430     /// This address may be reused for different queues later in the Process
431     /// lifetime and should not be used to identify a queue uniquely.  Use
432     /// the GetQueueID() call for that.
433     ///
434     /// @return
435     ///     The Queue's libdispatch_queue_t address if the Thread subclass
436     ///     implements this, else LLDB_INVALID_ADDRESS.
437     //------------------------------------------------------------------
438     virtual lldb::addr_t
GetQueueLibdispatchQueueAddress()439     GetQueueLibdispatchQueueAddress ()
440     {
441         return LLDB_INVALID_ADDRESS;
442     }
443 
444     virtual uint32_t
GetStackFrameCount()445     GetStackFrameCount()
446     {
447         return GetStackFrameList()->GetNumFrames();
448     }
449 
450     virtual lldb::StackFrameSP
GetStackFrameAtIndex(uint32_t idx)451     GetStackFrameAtIndex (uint32_t idx)
452     {
453         return GetStackFrameList()->GetFrameAtIndex(idx);
454     }
455 
456     virtual lldb::StackFrameSP
457     GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
458 
459     bool
DecrementCurrentInlinedDepth()460     DecrementCurrentInlinedDepth()
461     {
462         return GetStackFrameList()->DecrementCurrentInlinedDepth();
463     }
464 
465     uint32_t
GetCurrentInlinedDepth()466     GetCurrentInlinedDepth()
467     {
468         return GetStackFrameList()->GetCurrentInlinedDepth();
469     }
470 
471     Error
472     ReturnFromFrameWithIndex (uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
473 
474     Error
475     ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast = false);
476 
477     Error
478     JumpToLine (const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings = NULL);
479 
480     virtual lldb::StackFrameSP
GetFrameWithStackID(const StackID & stack_id)481     GetFrameWithStackID (const StackID &stack_id)
482     {
483         if (stack_id.IsValid())
484             return GetStackFrameList()->GetFrameWithStackID (stack_id);
485         return lldb::StackFrameSP();
486     }
487 
488     uint32_t
GetSelectedFrameIndex()489     GetSelectedFrameIndex ()
490     {
491         return GetStackFrameList()->GetSelectedFrameIndex();
492     }
493 
494     lldb::StackFrameSP
GetSelectedFrame()495     GetSelectedFrame ()
496     {
497         lldb::StackFrameListSP stack_frame_list_sp(GetStackFrameList());
498         return stack_frame_list_sp->GetFrameAtIndex (stack_frame_list_sp->GetSelectedFrameIndex());
499     }
500 
501     uint32_t
502     SetSelectedFrame (lldb_private::StackFrame *frame, bool broadcast = false);
503 
504 
505     bool
506     SetSelectedFrameByIndex (uint32_t frame_idx, bool broadcast = false);
507 
508     bool
509     SetSelectedFrameByIndexNoisily (uint32_t frame_idx, Stream &output_stream);
510 
511     void
SetDefaultFileAndLineToSelectedFrame()512     SetDefaultFileAndLineToSelectedFrame()
513     {
514         GetStackFrameList()->SetDefaultFileAndLineToSelectedFrame();
515     }
516 
517     virtual lldb::RegisterContextSP
518     GetRegisterContext () = 0;
519 
520     virtual lldb::RegisterContextSP
521     CreateRegisterContextForFrame (StackFrame *frame) = 0;
522 
523     virtual void
524     ClearStackFrames ();
525 
526     virtual bool
SetBackingThread(const lldb::ThreadSP & thread_sp)527     SetBackingThread (const lldb::ThreadSP &thread_sp)
528     {
529         return false;
530     }
531 
532     virtual lldb::ThreadSP
GetBackingThread()533     GetBackingThread () const
534     {
535         return lldb::ThreadSP();
536     }
537 
538     virtual void
ClearBackingThread()539     ClearBackingThread ()
540     {
541         // Subclasses can use this function if a thread is actually backed by
542         // another thread. This is currently used for the OperatingSystem plug-ins
543         // where they might have a thread that is in memory, yet its registers
544         // are available through the lldb_private::Thread subclass for the current
545         // lldb_private::Process class. Since each time the process stops the backing
546         // threads for memory threads can change, we need a way to clear the backing
547         // thread for all memory threads each time we stop.
548     }
549 
550     void
551     DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
552 
553     bool
554     GetDescription (Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo);
555 
556     //------------------------------------------------------------------
557     /// Default implementation for stepping into.
558     ///
559     /// This function is designed to be used by commands where the
560     /// process is publicly stopped.
561     ///
562     /// @param[in] source_step
563     ///     If true and the frame has debug info, then do a source level
564     ///     step in, else do a single instruction step in.
565     ///
566     /// @param[in] step_in_avoids_code_without_debug_info
567     ///     If \a true, then avoid stepping into code that doesn't have
568     ///     debug info, else step into any code regardless of whether it
569     ///     has debug info.
570     ///
571     /// @param[in] step_out_avoids_code_without_debug_info
572     ///     If \a true, then if you step out to code with no debug info, keep
573     ///     stepping out till you get to code with debug info.
574     ///
575     /// @return
576     ///     An error that describes anything that went wrong
577     //------------------------------------------------------------------
578     virtual Error
579     StepIn (bool source_step,
580             LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
581             LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
582 
583     //------------------------------------------------------------------
584     /// Default implementation for stepping over.
585     ///
586     /// This function is designed to be used by commands where the
587     /// process is publicly stopped.
588     ///
589     /// @param[in] source_step
590     ///     If true and the frame has debug info, then do a source level
591     ///     step over, else do a single instruction step over.
592     ///
593     /// @return
594     ///     An error that describes anything that went wrong
595     //------------------------------------------------------------------
596     virtual Error
597     StepOver (bool source_step,
598               LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
599 
600     //------------------------------------------------------------------
601     /// Default implementation for stepping out.
602     ///
603     /// This function is designed to be used by commands where the
604     /// process is publicly stopped.
605     ///
606     /// @return
607     ///     An error that describes anything that went wrong
608     //------------------------------------------------------------------
609     virtual Error
610     StepOut ();
611     //------------------------------------------------------------------
612     /// Retrieves the per-thread data area.
613     /// Most OSs maintain a per-thread pointer (e.g. the FS register on
614     /// x64), which we return the value of here.
615     ///
616     /// @return
617     ///     LLDB_INVALID_ADDRESS if not supported, otherwise the thread
618     ///     pointer value.
619     //------------------------------------------------------------------
620     virtual lldb::addr_t
621     GetThreadPointer ();
622 
623     //------------------------------------------------------------------
624     /// Retrieves the per-module TLS block for a thread.
625     ///
626     /// @param[in] module
627     ///     The module to query TLS data for.
628     ///
629     /// @return
630     ///     If the thread has TLS data allocated for the
631     ///     module, the address of the TLS block. Otherwise
632     ///     LLDB_INVALID_ADDRESS is returned.
633     //------------------------------------------------------------------
634     virtual lldb::addr_t
635     GetThreadLocalData (const lldb::ModuleSP module);
636 
637     //------------------------------------------------------------------
638     /// Check whether this thread is safe to run functions
639     ///
640     /// The SystemRuntime may know of certain thread states (functions in
641     /// process of execution, for instance) which can make it unsafe for
642     /// functions to be called.
643     ///
644     /// @return
645     ///     True if it is safe to call functions on this thread.
646     ///     False if function calls should be avoided on this thread.
647     //------------------------------------------------------------------
648     virtual bool
649     SafeToCallFunctions ();
650 
651     //------------------------------------------------------------------
652     // Thread Plan Providers:
653     // This section provides the basic thread plans that the Process control
654     // machinery uses to run the target.  ThreadPlan.h provides more details on
655     // how this mechanism works.
656     // The thread provides accessors to a set of plans that perform basic operations.
657     // The idea is that particular Platform plugins can override these methods to
658     // provide the implementation of these basic operations appropriate to their
659     // environment.
660     //
661     // NB: All the QueueThreadPlanXXX providers return Shared Pointers to
662     // Thread plans.  This is useful so that you can modify the plans after
663     // creation in ways specific to that plan type.  Also, it is often necessary for
664     // ThreadPlans that utilize other ThreadPlans to implement their task to keep a shared
665     // pointer to the sub-plan.
666     // But besides that, the shared pointers should only be held onto by entities who live no longer
667     // than the thread containing the ThreadPlan.
668     // FIXME: If this becomes a problem, we can make a version that just returns a pointer,
669     // which it is clearly unsafe to hold onto, and a shared pointer version, and only allow
670     // ThreadPlan and Co. to use the latter.  That is made more annoying to do because there's
671     // no elegant way to friend a method to all sub-classes of a given class.
672     //
673     //------------------------------------------------------------------
674 
675     //------------------------------------------------------------------
676     /// Queues the base plan for a thread.
677     /// The version returned by Process does some things that are useful,
678     /// like handle breakpoints and signals, so if you return a plugin specific
679     /// one you probably want to call through to the Process one for anything
680     /// your plugin doesn't explicitly handle.
681     ///
682     /// @param[in] abort_other_plans
683     ///    \b true if we discard the currently queued plans and replace them with this one.
684     ///    Otherwise this plan will go on the end of the plan stack.
685     ///
686     /// @return
687     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
688     //------------------------------------------------------------------
689     virtual lldb::ThreadPlanSP
690     QueueFundamentalPlan (bool abort_other_plans);
691 
692     //------------------------------------------------------------------
693     /// Queues the plan used to step one instruction from the current PC of \a thread.
694     ///
695     /// @param[in] step_over
696     ///    \b true if we step over calls to functions, false if we step in.
697     ///
698     /// @param[in] abort_other_plans
699     ///    \b true if we discard the currently queued plans and replace them with this one.
700     ///    Otherwise this plan will go on the end of the plan stack.
701     ///
702     /// @param[in] stop_other_threads
703     ///    \b true if we will stop other threads while we single step this one.
704     ///
705     /// @return
706     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
707     //------------------------------------------------------------------
708     virtual lldb::ThreadPlanSP
709     QueueThreadPlanForStepSingleInstruction (bool step_over,
710                                              bool abort_other_plans,
711                                              bool stop_other_threads);
712 
713     //------------------------------------------------------------------
714     /// Queues the plan used to step through an address range, stepping  over
715     /// function calls.
716     ///
717     /// @param[in] abort_other_plans
718     ///    \b true if we discard the currently queued plans and replace them with this one.
719     ///    Otherwise this plan will go on the end of the plan stack.
720     ///
721     /// @param[in] type
722     ///    Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
723     ///
724     /// @param[in] range
725     ///    The address range to step through.
726     ///
727     /// @param[in] addr_context
728     ///    When dealing with stepping through inlined functions the current PC is not enough information to know
729     ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
730     //     The \a addr_context provides the current symbol context the step
731     ///    is supposed to be out of.
732     //   FIXME: Currently unused.
733     ///
734     /// @param[in] stop_other_threads
735     ///    \b true if we will stop other threads while we single step this one.
736     ///
737     /// @param[in] step_out_avoids_code_without_debug_info
738     ///    If eLazyBoolYes, if the step over steps out it will continue to step out till it comes to a frame with debug info.
739     ///    If eLazyBoolCalculate, we will consult the default set in the thread.
740     ///
741     /// @return
742     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
743     //------------------------------------------------------------------
744     virtual lldb::ThreadPlanSP
745     QueueThreadPlanForStepOverRange (bool abort_other_plans,
746                                      const AddressRange &range,
747                                      const SymbolContext &addr_context,
748                                      lldb::RunMode stop_other_threads,
749                                      LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
750 
751     //------------------------------------------------------------------
752     /// Queues the plan used to step through an address range, stepping into functions.
753     ///
754     /// @param[in] abort_other_plans
755     ///    \b true if we discard the currently queued plans and replace them with this one.
756     ///    Otherwise this plan will go on the end of the plan stack.
757     ///
758     /// @param[in] type
759     ///    Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
760     ///
761     /// @param[in] range
762     ///    The address range to step through.
763     ///
764     /// @param[in] addr_context
765     ///    When dealing with stepping through inlined functions the current PC is not enough information to know
766     ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
767     //     The \a addr_context provides the current symbol context the step
768     ///    is supposed to be out of.
769     //   FIXME: Currently unused.
770     ///
771     /// @param[in] step_in_target
772     ///    Name if function we are trying to step into.  We will step out if we don't land in that function.
773     ///
774     /// @param[in] stop_other_threads
775     ///    \b true if we will stop other threads while we single step this one.
776     ///
777     /// @param[in] step_in_avoids_code_without_debug_info
778     ///    If eLazyBoolYes we will step out if we step into code with no debug info.
779     ///    If eLazyBoolCalculate we will consult the default set in the thread.
780     ///
781     /// @param[in] step_out_avoids_code_without_debug_info
782     ///    If eLazyBoolYes, if the step over steps out it will continue to step out till it comes to a frame with debug info.
783     ///    If eLazyBoolCalculate, it will consult the default set in the thread.
784     ///
785     /// @return
786     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
787     //------------------------------------------------------------------
788     virtual lldb::ThreadPlanSP
789     QueueThreadPlanForStepInRange (bool abort_other_plans,
790                                    const AddressRange &range,
791                                    const SymbolContext &addr_context,
792                                    const char *step_in_target,
793                                    lldb::RunMode stop_other_threads,
794                                    LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate,
795                                    LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
796 
797     //------------------------------------------------------------------
798     /// Queue the plan used to step out of the function at the current PC of
799     /// \a thread.
800     ///
801     /// @param[in] abort_other_plans
802     ///    \b true if we discard the currently queued plans and replace them with this one.
803     ///    Otherwise this plan will go on the end of the plan stack.
804     ///
805     /// @param[in] addr_context
806     ///    When dealing with stepping through inlined functions the current PC is not enough information to know
807     ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
808     //     The \a addr_context provides the current symbol context the step
809     ///    is supposed to be out of.
810     //   FIXME: Currently unused.
811     ///
812     /// @param[in] first_insn
813     ///     \b true if this is the first instruction of a function.
814     ///
815     /// @param[in] stop_other_threads
816     ///    \b true if we will stop other threads while we single step this one.
817     ///
818     /// @param[in] stop_vote
819     /// @param[in] run_vote
820     ///    See standard meanings for the stop & run votes in ThreadPlan.h.
821     ///
822     /// @param[in] step_out_avoids_code_without_debug_info
823     ///    If eLazyBoolYes, if the step over steps out it will continue to step out till it comes to a frame with debug info.
824     ///    If eLazyBoolCalculate, it will consult the default set in the thread.
825     ///
826     /// @return
827     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
828     //------------------------------------------------------------------
829     virtual lldb::ThreadPlanSP
830     QueueThreadPlanForStepOut (bool abort_other_plans,
831                                SymbolContext *addr_context,
832                                bool first_insn,
833                                bool stop_other_threads,
834                                Vote stop_vote, // = eVoteYes,
835                                Vote run_vote, // = eVoteNoOpinion);
836                                uint32_t frame_idx,
837                                LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate);
838 
839     //------------------------------------------------------------------
840     /// Queue the plan used to step out of the function at the current PC of
841     /// a thread.  This version does not consult the should stop here callback, and should only
842     /// be used by other thread plans when they need to retain control of the step out.
843     ///
844     /// @param[in] abort_other_plans
845     ///    \b true if we discard the currently queued plans and replace them with this one.
846     ///    Otherwise this plan will go on the end of the plan stack.
847     ///
848     /// @param[in] addr_context
849     ///    When dealing with stepping through inlined functions the current PC is not enough information to know
850     ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
851     //     The \a addr_context provides the current symbol context the step
852     ///    is supposed to be out of.
853     //   FIXME: Currently unused.
854     ///
855     /// @param[in] first_insn
856     ///     \b true if this is the first instruction of a function.
857     ///
858     /// @param[in] stop_other_threads
859     ///    \b true if we will stop other threads while we single step this one.
860     ///
861     /// @param[in] stop_vote
862     /// @param[in] run_vote
863     ///    See standard meanings for the stop & run votes in ThreadPlan.h.
864     ///
865     /// @return
866     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
867     //------------------------------------------------------------------
868     virtual lldb::ThreadPlanSP
869     QueueThreadPlanForStepOutNoShouldStop (bool abort_other_plans,
870                                            SymbolContext *addr_context,
871                                            bool first_insn,
872                                            bool stop_other_threads,
873                                            Vote stop_vote, // = eVoteYes,
874                                            Vote run_vote, // = eVoteNoOpinion);
875                                            uint32_t frame_idx);
876 
877     //------------------------------------------------------------------
878     /// Gets the plan used to step through the code that steps from a function
879     /// call site at the current PC into the actual function call.
880     ///
881     ///
882     /// @param[in] return_stack_id
883     ///    The stack id that we will return to (by setting backstop breakpoints on the return
884     ///    address to that frame) if we fail to step through.
885     ///
886     /// @param[in] abort_other_plans
887     ///    \b true if we discard the currently queued plans and replace them with this one.
888     ///    Otherwise this plan will go on the end of the plan stack.
889     ///
890     /// @param[in] stop_other_threads
891     ///    \b true if we will stop other threads while we single step this one.
892     ///
893     /// @return
894     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
895     //------------------------------------------------------------------
896     virtual lldb::ThreadPlanSP
897     QueueThreadPlanForStepThrough (StackID &return_stack_id,
898                                    bool abort_other_plans,
899                                    bool stop_other_threads);
900 
901     //------------------------------------------------------------------
902     /// Gets the plan used to continue from the current PC.
903     /// This is a simple plan, mostly useful as a backstop when you are continuing
904     /// for some particular purpose.
905     ///
906     /// @param[in] abort_other_plans
907     ///    \b true if we discard the currently queued plans and replace them with this one.
908     ///    Otherwise this plan will go on the end of the plan stack.
909     ///
910     /// @param[in] target_addr
911     ///    The address to which we're running.
912     ///
913     /// @param[in] stop_other_threads
914     ///    \b true if we will stop other threads while we single step this one.
915     ///
916     /// @return
917     ///     A shared pointer to the newly queued thread plan, or NULL if the plan could not be queued.
918     //------------------------------------------------------------------
919     virtual lldb::ThreadPlanSP
920     QueueThreadPlanForRunToAddress (bool abort_other_plans,
921                                     Address &target_addr,
922                                     bool stop_other_threads);
923 
924     virtual lldb::ThreadPlanSP
925     QueueThreadPlanForStepUntil (bool abort_other_plans,
926                                  lldb::addr_t *address_list,
927                                  size_t num_addresses,
928                                  bool stop_others,
929                                  uint32_t frame_idx);
930 
931     virtual lldb::ThreadPlanSP
932     QueueThreadPlanForStepScripted (bool abort_other_plans,
933                                     const char *class_name,
934                                     bool stop_other_threads);
935 
936     //------------------------------------------------------------------
937     // Thread Plan accessors:
938     //------------------------------------------------------------------
939 
940     //------------------------------------------------------------------
941     /// Gets the plan which will execute next on the plan stack.
942     ///
943     /// @return
944     ///     A pointer to the next executed plan.
945     //------------------------------------------------------------------
946     ThreadPlan *
947     GetCurrentPlan ();
948 
949     //------------------------------------------------------------------
950     /// Unwinds the thread stack for the innermost expression plan currently
951     /// on the thread plan stack.
952     ///
953     /// @return
954     ///     An error if the thread plan could not be unwound.
955     //------------------------------------------------------------------
956 
957     Error
958     UnwindInnermostExpression();
959 
960 private:
961     bool
962     PlanIsBasePlan (ThreadPlan *plan_ptr);
963 
964     void
965     BroadcastSelectedFrameChange(StackID &new_frame_id);
966 
967 public:
968 
969     //------------------------------------------------------------------
970     /// Gets the outer-most plan that was popped off the plan stack in the
971     /// most recent stop.  Useful for printing the stop reason accurately.
972     ///
973     /// @return
974     ///     A pointer to the last completed plan.
975     //------------------------------------------------------------------
976     lldb::ThreadPlanSP
977     GetCompletedPlan ();
978 
979     //------------------------------------------------------------------
980     /// Gets the outer-most return value from the completed plans
981     ///
982     /// @return
983     ///     A ValueObjectSP, either empty if there is no return value,
984     ///     or containing the return value.
985     //------------------------------------------------------------------
986     lldb::ValueObjectSP
987     GetReturnValueObject ();
988 
989     //------------------------------------------------------------------
990     /// Gets the outer-most expression variable from the completed plans
991     ///
992     /// @return
993     ///     A ClangExpressionVariableSP, either empty if there is no
994     ///     plan completed an expression during the current stop
995     ///     or the expression variable that was made for the completed expression.
996     //------------------------------------------------------------------
997     lldb::ClangExpressionVariableSP
998     GetExpressionVariable ();
999 
1000     //------------------------------------------------------------------
1001     ///  Checks whether the given plan is in the completed plans for this
1002     ///  stop.
1003     ///
1004     /// @param[in] plan
1005     ///     Pointer to the plan you're checking.
1006     ///
1007     /// @return
1008     ///     Returns true if the input plan is in the completed plan stack,
1009     ///     false otherwise.
1010     //------------------------------------------------------------------
1011     bool
1012     IsThreadPlanDone (ThreadPlan *plan);
1013 
1014     //------------------------------------------------------------------
1015     ///  Checks whether the given plan is in the discarded plans for this
1016     ///  stop.
1017     ///
1018     /// @param[in] plan
1019     ///     Pointer to the plan you're checking.
1020     ///
1021     /// @return
1022     ///     Returns true if the input plan is in the discarded plan stack,
1023     ///     false otherwise.
1024     //------------------------------------------------------------------
1025     bool
1026     WasThreadPlanDiscarded (ThreadPlan *plan);
1027 
1028     //------------------------------------------------------------------
1029     /// Queues a generic thread plan.
1030     ///
1031     /// @param[in] plan_sp
1032     ///    The plan to queue.
1033     ///
1034     /// @param[in] abort_other_plans
1035     ///    \b true if we discard the currently queued plans and replace them with this one.
1036     ///    Otherwise this plan will go on the end of the plan stack.
1037     ///
1038     /// @return
1039     ///     A pointer to the last completed plan.
1040     //------------------------------------------------------------------
1041     void
1042     QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
1043 
1044 
1045     //------------------------------------------------------------------
1046     /// Discards the plans queued on the plan stack of the current thread.  This is
1047     /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
1048     //  But if \a force is true, all thread plans are discarded.
1049     //------------------------------------------------------------------
1050     void
1051     DiscardThreadPlans (bool force);
1052 
1053     //------------------------------------------------------------------
1054     /// Discards the plans queued on the plan stack of the current thread up to and
1055     /// including up_to_plan_sp.
1056     //
1057     // @param[in] up_to_plan_sp
1058     //   Discard all plans up to and including this one.
1059     //------------------------------------------------------------------
1060     void
1061     DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp);
1062 
1063     void
1064     DiscardThreadPlansUpToPlan (ThreadPlan *up_to_plan_ptr);
1065 
1066     //------------------------------------------------------------------
1067     /// Discards the plans queued on the plan stack of the current thread up to and
1068     /// including the plan in that matches \a thread_index counting only
1069     /// the non-Private plans.
1070     ///
1071     /// @param[in] up_to_plan_sp
1072     ///   Discard all plans up to and including this user plan given by this index.
1073     ///
1074     /// @return
1075     ///    \b true if there was a thread plan with that user index, \b false otherwise.
1076     //------------------------------------------------------------------
1077     bool
1078     DiscardUserThreadPlansUpToIndex (uint32_t thread_index);
1079 
1080     //------------------------------------------------------------------
1081     /// Prints the current plan stack.
1082     ///
1083     /// @param[in] s
1084     ///    The stream to which to dump the plan stack info.
1085     ///
1086     //------------------------------------------------------------------
1087     void
1088     DumpThreadPlans (Stream *s,
1089                      lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose,
1090                      bool include_internal = true,
1091                      bool ignore_boring = false) const;
1092 
1093     virtual bool
1094     CheckpointThreadState (ThreadStateCheckpoint &saved_state);
1095 
1096     virtual bool
1097     RestoreRegisterStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
1098 
1099     virtual bool
1100     RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
1101 
1102     void
1103     EnableTracer (bool value, bool single_step);
1104 
1105     void
1106     SetTracer (lldb::ThreadPlanTracerSP &tracer_sp);
1107 
1108     //------------------------------------------------------------------
1109     // Get the thread index ID. The index ID that is guaranteed to not
1110     // be re-used by a process. They start at 1 and increase with each
1111     // new thread. This allows easy command line access by a unique ID
1112     // that is easier to type than the actual system thread ID.
1113     //------------------------------------------------------------------
1114     uint32_t
1115     GetIndexID () const;
1116 
1117     //------------------------------------------------------------------
1118     // Get the originating thread's index ID.
1119     // In the case of an "extended" thread -- a thread which represents
1120     // the stack that enqueued/spawned work that is currently executing --
1121     // we need to provide the IndexID of the thread that actually did
1122     // this work.  We don't want to just masquerade as that thread's IndexID
1123     // by using it in our own IndexID because that way leads to madness -
1124     // but the driver program which is iterating over extended threads
1125     // may ask for the OriginatingThreadID to display that information
1126     // to the user.
1127     // Normal threads will return the same thing as GetIndexID();
1128     //------------------------------------------------------------------
1129     virtual uint32_t
GetExtendedBacktraceOriginatingIndexID()1130     GetExtendedBacktraceOriginatingIndexID ()
1131     {
1132         return GetIndexID ();
1133     }
1134 
1135     //------------------------------------------------------------------
1136     // The API ID is often the same as the Thread::GetID(), but not in
1137     // all cases. Thread::GetID() is the user visible thread ID that
1138     // clients would want to see. The API thread ID is the thread ID
1139     // that is used when sending data to/from the debugging protocol.
1140     //------------------------------------------------------------------
1141     virtual lldb::user_id_t
GetProtocolID()1142     GetProtocolID () const
1143     {
1144         return GetID();
1145     }
1146 
1147     //------------------------------------------------------------------
1148     // lldb::ExecutionContextScope pure virtual functions
1149     //------------------------------------------------------------------
1150     virtual lldb::TargetSP
1151     CalculateTarget ();
1152 
1153     virtual lldb::ProcessSP
1154     CalculateProcess ();
1155 
1156     virtual lldb::ThreadSP
1157     CalculateThread ();
1158 
1159     virtual lldb::StackFrameSP
1160     CalculateStackFrame ();
1161 
1162     virtual void
1163     CalculateExecutionContext (ExecutionContext &exe_ctx);
1164 
1165     lldb::StackFrameSP
1166     GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
1167 
1168     size_t
1169     GetStatus (Stream &strm,
1170                uint32_t start_frame,
1171                uint32_t num_frames,
1172                uint32_t num_frames_with_source);
1173 
1174     size_t
1175     GetStackFrameStatus (Stream& strm,
1176                          uint32_t first_frame,
1177                          uint32_t num_frames,
1178                          bool show_frame_info,
1179                          uint32_t num_frames_with_source);
1180 
1181     // We need a way to verify that even though we have a thread in a shared
1182     // pointer that the object itself is still valid. Currently this won't be
1183     // the case if DestroyThread() was called. DestroyThread is called when
1184     // a thread has been removed from the Process' thread list.
1185     bool
IsValid()1186     IsValid () const
1187     {
1188         return !m_destroy_called;
1189     }
1190 
1191     // Sets and returns a valid stop info based on the process stop ID and the
1192     // current thread plan. If the thread stop ID does not match the process'
1193     // stop ID, the private stop reason is not set and an invalid StopInfoSP may
1194     // be returned.
1195     //
1196     // NOTE: This function must be called before the current thread plan is
1197     // moved to the completed plan stack (in Thread::ShouldStop()).
1198     //
1199     // NOTE: If subclasses override this function, ensure they do not overwrite
1200     // the m_actual_stop_info if it is valid.  The stop info may be a
1201     // "checkpointed and restored" stop info, so if it is still around it is
1202     // right even if you have not calculated this yourself, or if it disagrees
1203     // with what you might have calculated.
1204     virtual lldb::StopInfoSP
1205     GetPrivateStopInfo ();
1206 
1207     //----------------------------------------------------------------------
1208     // Ask the thread subclass to set its stop info.
1209     //
1210     // Thread subclasses should call Thread::SetStopInfo(...) with the
1211     // reason the thread stopped.
1212     //
1213     // @return
1214     //      True if Thread::SetStopInfo(...) was called, false otherwise.
1215     //----------------------------------------------------------------------
1216     virtual bool
1217     CalculateStopInfo () = 0;
1218 
1219     //----------------------------------------------------------------------
1220     // Gets the temporary resume state for a thread.
1221     //
1222     // This value gets set in each thread by complex debugger logic in
1223     // Thread::ShouldResume() and an appropriate thread resume state will get
1224     // set in each thread every time the process is resumed prior to calling
1225     // Process::DoResume(). The lldb_private::Process subclass should adhere
1226     // to the thread resume state request which will be one of:
1227     //
1228     //  eStateRunning   - thread will resume when process is resumed
1229     //  eStateStepping  - thread should step 1 instruction and stop when process
1230     //                    is resumed
1231     //  eStateSuspended - thread should not execute any instructions when
1232     //                    process is resumed
1233     //----------------------------------------------------------------------
1234     lldb::StateType
GetTemporaryResumeState()1235     GetTemporaryResumeState() const
1236     {
1237         return m_temporary_resume_state;
1238     }
1239 
1240     void
1241     SetStopInfo (const lldb::StopInfoSP &stop_info_sp);
1242 
1243     void
1244     SetShouldReportStop (Vote vote);
1245 
1246     //----------------------------------------------------------------------
1247     /// Sets the extended backtrace token for this thread
1248     ///
1249     /// Some Thread subclasses may maintain a token to help with providing
1250     /// an extended backtrace.  The SystemRuntime plugin will set/request this.
1251     ///
1252     /// @param [in] token
1253     //----------------------------------------------------------------------
1254     virtual void
SetExtendedBacktraceToken(uint64_t token)1255     SetExtendedBacktraceToken (uint64_t token) { }
1256 
1257     //----------------------------------------------------------------------
1258     /// Gets the extended backtrace token for this thread
1259     ///
1260     /// Some Thread subclasses may maintain a token to help with providing
1261     /// an extended backtrace.  The SystemRuntime plugin will set/request this.
1262     ///
1263     /// @return
1264     ///     The token needed by the SystemRuntime to create an extended backtrace.
1265     ///     LLDB_INVALID_ADDRESS is returned if no token is available.
1266     //----------------------------------------------------------------------
1267     virtual uint64_t
GetExtendedBacktraceToken()1268     GetExtendedBacktraceToken ()
1269     {
1270         return LLDB_INVALID_ADDRESS;
1271     }
1272 
1273 protected:
1274 
1275     friend class ThreadPlan;
1276     friend class ThreadList;
1277     friend class ThreadEventData;
1278     friend class StackFrameList;
1279     friend class StackFrame;
1280     friend class OperatingSystem;
1281 
1282     // This is necessary to make sure thread assets get destroyed while the thread is still in good shape
1283     // to call virtual thread methods.  This must be called by classes that derive from Thread in their destructor.
1284     virtual void DestroyThread ();
1285 
1286     void
1287     PushPlan (lldb::ThreadPlanSP &plan_sp);
1288 
1289     void
1290     PopPlan ();
1291 
1292     void
1293     DiscardPlan ();
1294 
1295     ThreadPlan *GetPreviousPlan (ThreadPlan *plan);
1296 
1297     typedef std::vector<lldb::ThreadPlanSP> plan_stack;
1298 
1299     virtual lldb_private::Unwind *
1300     GetUnwinder ();
1301 
1302     // Check to see whether the thread is still at the last breakpoint hit that stopped it.
1303     virtual bool
1304     IsStillAtLastBreakpointHit();
1305 
1306     // Some threads are threads that are made up by OperatingSystem plugins that
1307     // are threads that exist and are context switched out into memory. The
1308     // OperatingSystem plug-in need a ways to know if a thread is "real" or made
1309     // up.
1310     virtual bool
IsOperatingSystemPluginThread()1311     IsOperatingSystemPluginThread () const
1312     {
1313         return false;
1314     }
1315 
1316     // Subclasses that have a way to get an extended info dictionary for this thread should
1317     // fill
1318     virtual lldb_private::StructuredData::ObjectSP
FetchThreadExtendedInfo()1319     FetchThreadExtendedInfo ()
1320     {
1321         return StructuredData::ObjectSP();
1322     }
1323 
1324     lldb::StackFrameListSP
1325     GetStackFrameList ();
1326 
1327 
1328     //------------------------------------------------------------------
1329     // Classes that inherit from Process can see and modify these
1330     //------------------------------------------------------------------
1331     lldb::ProcessWP     m_process_wp;           ///< The process that owns this thread.
1332     lldb::StopInfoSP    m_stop_info_sp;         ///< The private stop reason for this thread
1333     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
1334     // the thread's m_stop_info_sp is current and you don't have to fetch it again
1335     uint32_t            m_stop_info_override_stop_id;    // The stop ID containing the last time the stop info was checked against the stop info override
1336     const uint32_t      m_index_id;             ///< A unique 1 based index assigned to each thread for easy UI/command line access.
1337     lldb::RegisterContextSP m_reg_context_sp;   ///< The register context for this thread's current register state.
1338     lldb::StateType     m_state;                ///< The state of our process.
1339     mutable Mutex       m_state_mutex;          ///< Multithreaded protection for m_state.
1340     plan_stack          m_plan_stack;           ///< The stack of plans this thread is executing.
1341     plan_stack          m_completed_plan_stack; ///< Plans that have been completed by this stop.  They get deleted when the thread resumes.
1342     plan_stack          m_discarded_plan_stack; ///< Plans that have been discarded by this stop.  They get deleted when the thread resumes.
1343     mutable Mutex       m_frame_mutex;          ///< Multithreaded protection for m_state.
1344     lldb::StackFrameListSP m_curr_frames_sp;    ///< The stack frames that get lazily populated after a thread stops.
1345     lldb::StackFrameListSP m_prev_frames_sp;    ///< The previous stack frames from the last time this thread stopped.
1346     int                 m_resume_signal;        ///< The signal that should be used when continuing this thread.
1347     lldb::StateType     m_resume_state;         ///< This state is used to force a thread to be suspended from outside the ThreadPlan logic.
1348     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.
1349                                                   /// It gets set in Thread::ShouldResume.
1350     std::unique_ptr<lldb_private::Unwind> m_unwinder_ap;
1351     bool                m_destroy_called;       // This is used internally to make sure derived Thread classes call DestroyThread.
1352     LazyBool            m_override_should_notify;
1353 private:
1354     bool                m_extended_info_fetched;  // Have we tried to retrieve the m_extended_info for this thread?
1355     StructuredData::ObjectSP m_extended_info;     // The extended info for this thread
1356     //------------------------------------------------------------------
1357     // For Thread only
1358     //------------------------------------------------------------------
1359 
1360     DISALLOW_COPY_AND_ASSIGN (Thread);
1361 
1362 };
1363 
1364 } // namespace lldb_private
1365 
1366 #endif  // liblldb_Thread_h_
1367