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