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