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