Thread.h revision bf97d74c0c3e9a0f7c89fe0cd4a059015ec482d5
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 (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        return GetStackFrameAtIndex (GetStackFrameList().GetSelectedFrameIndex());
351    }
352
353    uint32_t
354    SetSelectedFrame (lldb_private::StackFrame *frame)
355    {
356        return GetStackFrameList().SetSelectedFrame(frame);
357    }
358
359    bool
360    SetSelectedFrameByIndex (uint32_t frame_idx)
361    {
362        return GetStackFrameList().SetSelectedFrameByIndex(frame_idx);
363    }
364
365    void
366    SetDefaultFileAndLineToSelectedFrame()
367    {
368        GetStackFrameList().SetDefaultFileAndLineToSelectedFrame();
369    }
370
371    virtual lldb::RegisterContextSP
372    GetRegisterContext () = 0;
373
374    virtual lldb::RegisterContextSP
375    CreateRegisterContextForFrame (StackFrame *frame) = 0;
376
377    virtual void
378    ClearStackFrames ();
379
380    void
381    DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
382
383    //------------------------------------------------------------------
384    // Thread Plan Providers:
385    // This section provides the basic thread plans that the Process control
386    // machinery uses to run the target.  ThreadPlan.h provides more details on
387    // how this mechanism works.
388    // The thread provides accessors to a set of plans that perform basic operations.
389    // The idea is that particular Platform plugins can override these methods to
390    // provide the implementation of these basic operations appropriate to their
391    // environment.
392    //------------------------------------------------------------------
393
394    //------------------------------------------------------------------
395    /// Queues the base plan for a thread.
396    /// The version returned by Process does some things that are useful,
397    /// like handle breakpoints and signals, so if you return a plugin specific
398    /// one you probably want to call through to the Process one for anything
399    /// your plugin doesn't explicitly handle.
400    ///
401    /// @param[in] abort_other_plans
402    ///    \b true if we discard the currently queued plans and replace them with this one.
403    ///    Otherwise this plan will go on the end of the plan stack.
404    ///
405    /// @return
406    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
407    //------------------------------------------------------------------
408    virtual ThreadPlan *
409    QueueFundamentalPlan (bool abort_other_plans);
410
411    //------------------------------------------------------------------
412    /// Queues the plan used to step over a breakpoint at the current PC of \a thread.
413    /// The default version returned by Process handles trap based breakpoints, and
414    /// will disable the breakpoint, single step over it, then re-enable it.
415    ///
416    /// @param[in] abort_other_plans
417    ///    \b true if we discard the currently queued plans and replace them with this one.
418    ///    Otherwise this plan will go on the end of the plan stack.
419    ///
420    /// @return
421    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
422    //------------------------------------------------------------------
423    virtual ThreadPlan *
424    QueueThreadPlanForStepOverBreakpointPlan (bool abort_other_plans);
425
426    //------------------------------------------------------------------
427    /// Queues the plan used to step one instruction from the current PC of \a thread.
428    ///
429    /// @param[in] step_over
430    ///    \b true if we step over calls to functions, false if we step in.
431    ///
432    /// @param[in] abort_other_plans
433    ///    \b true if we discard the currently queued plans and replace them with this one.
434    ///    Otherwise this plan will go on the end of the plan stack.
435    ///
436    /// @param[in] stop_other_threads
437    ///    \b true if we will stop other threads while we single step this one.
438    ///
439    /// @return
440    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
441    //------------------------------------------------------------------
442    virtual ThreadPlan *
443    QueueThreadPlanForStepSingleInstruction (bool step_over,
444                                             bool abort_other_plans,
445                                             bool stop_other_threads);
446
447    //------------------------------------------------------------------
448    /// Queues the plan used to step through an address range, stepping into or over
449    /// function calls depending on the value of StepType.
450    ///
451    /// @param[in] abort_other_plans
452    ///    \b true if we discard the currently queued plans and replace them with this one.
453    ///    Otherwise this plan will go on the end of the plan stack.
454    ///
455    /// @param[in] type
456    ///    Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
457    ///
458    /// @param[in] range
459    ///    The address range to step through.
460    ///
461    /// @param[in] addr_context
462    ///    When dealing with stepping through inlined functions the current PC is not enough information to know
463    ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
464    //     The \a addr_context provides the current symbol context the step
465    ///    is supposed to be out of.
466    //   FIXME: Currently unused.
467    ///
468    /// @param[in] stop_other_threads
469    ///    \b true if we will stop other threads while we single step this one.
470    ///
471    /// @return
472    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
473    //------------------------------------------------------------------
474    virtual ThreadPlan *
475    QueueThreadPlanForStepRange (bool abort_other_plans,
476                                 StepType type,
477                                 const AddressRange &range,
478                                 const SymbolContext &addr_context,
479                                 lldb::RunMode stop_other_threads,
480                                 bool avoid_code_without_debug_info);
481
482    //------------------------------------------------------------------
483    /// Queue the plan used to step out of the function at the current PC of
484    /// \a thread.
485    ///
486    /// @param[in] abort_other_plans
487    ///    \b true if we discard the currently queued plans and replace them with this one.
488    ///    Otherwise this plan will go on the end of the plan stack.
489    ///
490    /// @param[in] addr_context
491    ///    When dealing with stepping through inlined functions the current PC is not enough information to know
492    ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
493    //     The \a addr_context provides the current symbol context the step
494    ///    is supposed to be out of.
495    //   FIXME: Currently unused.
496    ///
497    /// @param[in] first_insn
498    ///     \b true if this is the first instruction of a function.
499    ///
500    /// @param[in] stop_other_threads
501    ///    \b true if we will stop other threads while we single step this one.
502    ///
503    /// @param[in] stop_vote
504    /// @param[in] run_vote
505    ///    See standard meanings for the stop & run votes in ThreadPlan.h.
506    ///
507    /// @return
508    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
509    //------------------------------------------------------------------
510    virtual ThreadPlan *
511    QueueThreadPlanForStepOut (bool abort_other_plans,
512                               SymbolContext *addr_context,
513                               bool first_insn,
514                               bool stop_other_threads,
515                               Vote stop_vote, // = eVoteYes,
516                               Vote run_vote, // = eVoteNoOpinion);
517                               uint32_t frame_idx);
518
519    //------------------------------------------------------------------
520    /// Gets the plan used to step through the code that steps from a function
521    /// call site at the current PC into the actual function call.
522    ///
523    /// @param[in] abort_other_plans
524    ///    \b true if we discard the currently queued plans and replace them with this one.
525    ///    Otherwise this plan will go on the end of the plan stack.
526    ///
527    /// @param[in] stop_other_threads
528    ///    \b true if we will stop other threads while we single step this one.
529    ///
530    /// @return
531    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
532    //------------------------------------------------------------------
533    virtual ThreadPlan *
534    QueueThreadPlanForStepThrough (bool abort_other_plans,
535                                   bool stop_other_threads);
536
537    //------------------------------------------------------------------
538    /// Gets the plan used to continue from the current PC.
539    /// This is a simple plan, mostly useful as a backstop when you are continuing
540    /// for some particular purpose.
541    ///
542    /// @param[in] abort_other_plans
543    ///    \b true if we discard the currently queued plans and replace them with this one.
544    ///    Otherwise this plan will go on the end of the plan stack.
545    ///
546    /// @param[in] target_addr
547    ///    The address to which we're running.
548    ///
549    /// @param[in] stop_other_threads
550    ///    \b true if we will stop other threads while we single step this one.
551    ///
552    /// @return
553    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
554    //------------------------------------------------------------------
555    virtual ThreadPlan *
556    QueueThreadPlanForRunToAddress (bool abort_other_plans,
557                                    Address &target_addr,
558                                    bool stop_other_threads);
559
560    virtual ThreadPlan *
561    QueueThreadPlanForStepUntil (bool abort_other_plans,
562                                 lldb::addr_t *address_list,
563                                 size_t num_addresses,
564                                 bool stop_others,
565                                 uint32_t frame_idx);
566
567    virtual ThreadPlan *
568    QueueThreadPlanForCallFunction (bool abort_other_plans,
569                                    Address& function,
570                                    lldb::addr_t arg,
571                                    bool stop_other_threads,
572                                    bool discard_on_error = false);
573
574    //------------------------------------------------------------------
575    // Thread Plan accessors:
576    //------------------------------------------------------------------
577
578    //------------------------------------------------------------------
579    /// Gets the plan which will execute next on the plan stack.
580    ///
581    /// @return
582    ///     A pointer to the next executed plan.
583    //------------------------------------------------------------------
584    ThreadPlan *
585    GetCurrentPlan ();
586
587private:
588    bool
589    PlanIsBasePlan (ThreadPlan *plan_ptr)
590    {
591        if (m_plan_stack.size() == 0)
592            return false;
593        return m_plan_stack[0].get() == plan_ptr;
594    }
595public:
596
597    //------------------------------------------------------------------
598    /// Gets the outer-most plan that was popped off the plan stack in the
599    /// most recent stop.  Useful for printing the stop reason accurately.
600    ///
601    /// @return
602    ///     A pointer to the last completed plan.
603    //------------------------------------------------------------------
604    lldb::ThreadPlanSP
605    GetCompletedPlan ();
606
607    //------------------------------------------------------------------
608    /// Gets the outer-most return value from the completed plans
609    ///
610    /// @return
611    ///     A ValueObjectSP, either empty if there is no return value,
612    ///     or containing the return value.
613    //------------------------------------------------------------------
614    lldb::ValueObjectSP
615    GetReturnValueObject ();
616
617    //------------------------------------------------------------------
618    ///  Checks whether the given plan is in the completed plans for this
619    ///  stop.
620    ///
621    /// @param[in] plan
622    ///     Pointer to the plan you're checking.
623    ///
624    /// @return
625    ///     Returns true if the input plan is in the completed plan stack,
626    ///     false otherwise.
627    //------------------------------------------------------------------
628    bool
629    IsThreadPlanDone (ThreadPlan *plan);
630
631    //------------------------------------------------------------------
632    ///  Checks whether the given plan is in the discarded plans for this
633    ///  stop.
634    ///
635    /// @param[in] plan
636    ///     Pointer to the plan you're checking.
637    ///
638    /// @return
639    ///     Returns true if the input plan is in the discarded plan stack,
640    ///     false otherwise.
641    //------------------------------------------------------------------
642    bool
643    WasThreadPlanDiscarded (ThreadPlan *plan);
644
645    //------------------------------------------------------------------
646    /// Queues a generic thread plan.
647    ///
648    /// @param[in] plan_sp
649    ///    The plan to queue.
650    ///
651    /// @param[in] abort_other_plans
652    ///    \b true if we discard the currently queued plans and replace them with this one.
653    ///    Otherwise this plan will go on the end of the plan stack.
654    ///
655    /// @return
656    ///     A pointer to the last completed plan.
657    //------------------------------------------------------------------
658    void
659    QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
660
661
662    //------------------------------------------------------------------
663    /// Discards the plans queued on the plan stack of the current thread.  This is
664    /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
665    //  But if \a force is true, all thread plans are discarded.
666    //------------------------------------------------------------------
667    void
668    DiscardThreadPlans (bool force);
669
670    //------------------------------------------------------------------
671    /// Discards the plans queued on the plan stack of the current thread up to and
672    /// including up_to_plan_sp.
673    //
674    // @param[in] up_to_plan_sp
675    //   Discard all plans up to and including this one.
676    //------------------------------------------------------------------
677    void
678    DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp);
679
680    //------------------------------------------------------------------
681    /// Prints the current plan stack.
682    ///
683    /// @param[in] s
684    ///    The stream to which to dump the plan stack info.
685    ///
686    //------------------------------------------------------------------
687    void
688    DumpThreadPlans (Stream *s) const;
689
690    virtual bool
691    CheckpointThreadState (ThreadStateCheckpoint &saved_state);
692
693    virtual bool
694    RestoreThreadStateFromCheckpoint (ThreadStateCheckpoint &saved_state);
695
696    void
697    EnableTracer (bool value, bool single_step);
698
699    void
700    SetTracer (lldb::ThreadPlanTracerSP &tracer_sp);
701
702    //------------------------------------------------------------------
703    /// The regular expression returned determines symbols that this
704    /// thread won't stop in during "step-in" operations.
705    ///
706    /// @return
707    ///    A pointer to a regular expression to compare against symbols,
708    ///    or NULL if all symbols are allowed.
709    ///
710    //------------------------------------------------------------------
711    RegularExpression *
712    GetSymbolsToAvoidRegexp()
713    {
714        return ThreadInstanceSettings::GetSymbolsToAvoidRegexp();
715    }
716
717    // Get the thread index ID. The index ID that is guaranteed to not be
718    // re-used by a process. They start at 1 and increase with each new thread.
719    // This allows easy command line access by a unique ID that is easier to
720    // type than the actual system thread ID.
721    uint32_t
722    GetIndexID () const;
723
724    //------------------------------------------------------------------
725    // lldb::ExecutionContextScope pure virtual functions
726    //------------------------------------------------------------------
727    virtual lldb::TargetSP
728    CalculateTarget ();
729
730    virtual lldb::ProcessSP
731    CalculateProcess ();
732
733    virtual lldb::ThreadSP
734    CalculateThread ();
735
736    virtual lldb::StackFrameSP
737    CalculateStackFrame ();
738
739    virtual void
740    CalculateExecutionContext (ExecutionContext &exe_ctx);
741
742    lldb::StackFrameSP
743    GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
744
745    size_t
746    GetStatus (Stream &strm,
747               uint32_t start_frame,
748               uint32_t num_frames,
749               uint32_t num_frames_with_source);
750
751    size_t
752    GetStackFrameStatus (Stream& strm,
753                         uint32_t first_frame,
754                         uint32_t num_frames,
755                         bool show_frame_info,
756                         uint32_t num_frames_with_source,
757                         uint32_t source_lines_before,
758                         uint32_t source_lines_after);
759
760protected:
761
762    friend class ThreadPlan;
763    friend class ThreadList;
764    friend class StackFrameList;
765
766    // This is necessary to make sure thread assets get destroyed while the thread is still in good shape
767    // to call virtual thread methods.  This must be called by classes that derive from Thread in their destructor.
768    virtual void DestroyThread ();
769
770    void
771    PushPlan (lldb::ThreadPlanSP &plan_sp);
772
773    void
774    PopPlan ();
775
776    void
777    DiscardPlan ();
778
779    ThreadPlan *GetPreviousPlan (ThreadPlan *plan);
780
781    // When you implement this method, make sure you don't overwrite the m_actual_stop_info if it claims to be
782    // valid.  The stop info may be a "checkpointed and restored" stop info, so if it is still around it is right
783    // even if you have not calculated this yourself, or if it disagrees with what you might have calculated.
784    virtual lldb::StopInfoSP
785    GetPrivateStopReason () = 0;
786
787    typedef std::vector<lldb::ThreadPlanSP> plan_stack;
788
789    void
790    SetStopInfo (const lldb::StopInfoSP &stop_info_sp);
791
792    virtual bool
793    SaveFrameZeroState (RegisterCheckpoint &checkpoint);
794
795    virtual bool
796    RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
797
798    virtual lldb_private::Unwind *
799    GetUnwinder ();
800
801    StackFrameList &
802    GetStackFrameList ();
803
804    lldb::StateType GetTemporaryResumeState()
805    {
806        return m_temporary_resume_state;
807    }
808
809    lldb::StateType SetTemporaryResumeState(lldb::StateType resume_state)
810    {
811        lldb::StateType old_temp_resume_state = m_temporary_resume_state;
812        m_temporary_resume_state = resume_state;
813        return old_temp_resume_state;
814    }
815
816    struct ThreadState
817    {
818        uint32_t           orig_stop_id;
819        lldb::StopInfoSP   stop_info_sp;
820        RegisterCheckpoint register_backup;
821    };
822
823    //------------------------------------------------------------------
824    // Classes that inherit from Process can see and modify these
825    //------------------------------------------------------------------
826    lldb::ProcessWP     m_process_wp;           ///< The process that owns this thread.
827    lldb::StopInfoSP    m_actual_stop_info_sp;  ///< The private stop reason for this thread
828    const uint32_t      m_index_id;             ///< A unique 1 based index assigned to each thread for easy UI/command line access.
829    lldb::RegisterContextSP m_reg_context_sp;   ///< The register context for this thread's current register state.
830    lldb::StateType     m_state;                ///< The state of our process.
831    mutable Mutex       m_state_mutex;          ///< Multithreaded protection for m_state.
832    plan_stack          m_plan_stack;           ///< The stack of plans this thread is executing.
833    plan_stack          m_completed_plan_stack; ///< Plans that have been completed by this stop.  They get deleted when the thread resumes.
834    plan_stack          m_discarded_plan_stack; ///< Plans that have been discarded by this stop.  They get deleted when the thread resumes.
835    lldb::StackFrameListSP m_curr_frames_sp;    ///< The stack frames that get lazily populated after a thread stops.
836    lldb::StackFrameListSP m_prev_frames_sp;    ///< The previous stack frames from the last time this thread stopped.
837    int                 m_resume_signal;        ///< The signal that should be used when continuing this thread.
838    lldb::StateType     m_resume_state;         ///< This state is used to force a thread to be suspended from outside the ThreadPlan logic.
839    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.
840                                                  /// It gets set in Thread::WillResume.
841    std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;
842    bool                m_destroy_called;       // This is used internally to make sure derived Thread classes call DestroyThread.
843    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
844                                                // the thread's m_actual_stop_info_sp is current and you don't have to fetch it again
845
846private:
847    //------------------------------------------------------------------
848    // For Thread only
849    //------------------------------------------------------------------
850
851    DISALLOW_COPY_AND_ASSIGN (Thread);
852
853};
854
855} // namespace lldb_private
856
857#endif  // liblldb_Thread_h_
858