Thread.h revision a830adbcd63d1995a01e6e18da79893c1426ca43
15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)//===-- Thread.h ------------------------------------------------*- C++ -*-===//
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)//
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)//                     The LLVM Compiler Infrastructure
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)//
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// This file is distributed under the University of Illinois Open Source
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// License. See LICENSE.TXT for details.
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)//
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)//===----------------------------------------------------------------------===//
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef liblldb_Thread_h_
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define liblldb_Thread_h_
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "lldb/lldb-private.h"
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "lldb/Host/Mutex.h"
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "lldb/Core/UserID.h"
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "lldb/Core/UserSettingsController.h"
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "lldb/Target/ExecutionContextScope.h"
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "lldb/Target/StackFrameList.h"
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "libunwind/include/libunwind.h"
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define LLDB_THREAD_MAX_STOP_EXC_DATA 8
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// I forward declare these here so I don't have to #include ThreadPlan, so in turn I
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// can use Thread.h in ThreadPlan.h.
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace lldb_private {
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class ThreadInstanceSettings : public InstanceSettings
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ThreadInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL);
335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ThreadInstanceSettings (const ThreadInstanceSettings &rhs);
355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    virtual
371e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    ~ThreadInstanceSettings ();
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
39c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    ThreadInstanceSettings&
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    operator= (const ThreadInstanceSettings &rhs);
4109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
43323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    void
445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    UpdateInstanceSettingsVariable (const ConstString &var_name,
455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                                    const char *index_value,
46bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)                                    const char *value,
475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                                    const ConstString &instance_name,
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                                    const SettingEntry &entry,
495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                                    lldb::VarSetOperationType op,
50bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)                                    Error &err,
515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                                    bool pending);
52591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GetInstanceSettingsValue (const SettingEntry &entry,
555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                              const ConstString &var_name,
5651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)                              StringList &value,
575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                              Error *err);
585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    RegularExpression *
605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    GetSymbolsToAvoidRegexp()
615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    {
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        return m_avoid_regexp_ap.get();
635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
6443e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)
6543e7502580f146aa5b3db8267ba6dbb5c733a489Torne (Richard Coles)    static const ConstString &
665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    StepAvoidRegexpVarName ();
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)protected:
695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
70c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    void
715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                          bool pending);
73
74    const ConstString
75    CreateInstanceName ();
76
77private:
78
79    std::auto_ptr<RegularExpression> m_avoid_regexp_ap;
80};
81
82class Thread :
83    public UserID,
84    public ExecutionContextScope,
85    public ThreadInstanceSettings
86{
87public:
88
89    class ThreadSettingsController : public UserSettingsController
90    {
91    public:
92
93        ThreadSettingsController ();
94
95        virtual
96        ~ThreadSettingsController ();
97
98        static SettingEntry global_settings_table[];
99        static SettingEntry instance_settings_table[];
100
101    protected:
102
103        lldb::InstanceSettingsSP
104        CreateInstanceSettings (const char *instance_name);
105
106    private:
107
108        // Class-wide settings.
109
110        DISALLOW_COPY_AND_ASSIGN (ThreadSettingsController);
111    };
112
113    class RegisterCheckpoint
114    {
115    public:
116
117        RegisterCheckpoint() :
118            m_stack_id (),
119            m_data_sp ()
120        {
121        }
122
123        RegisterCheckpoint (const StackID &stack_id) :
124            m_stack_id (stack_id),
125            m_data_sp ()
126        {
127        }
128
129        ~RegisterCheckpoint()
130        {
131        }
132
133        const StackID &
134        GetStackID()
135        {
136            return m_stack_id;
137        }
138
139        void
140        SetStackID (const StackID &stack_id)
141        {
142            m_stack_id = stack_id;
143        }
144
145        lldb::DataBufferSP &
146        GetData()
147        {
148            return m_data_sp;
149        }
150
151        const lldb::DataBufferSP &
152        GetData() const
153        {
154            return m_data_sp;
155        }
156
157    protected:
158        StackID m_stack_id;
159        lldb::DataBufferSP m_data_sp;
160    };
161
162    void
163    UpdateInstanceName ();
164
165    static lldb::UserSettingsControllerSP
166    GetSettingsController (bool finish = false);
167
168    Thread (Process &process, lldb::tid_t tid);
169    virtual ~Thread();
170
171    Process &
172    GetProcess() { return m_process; }
173
174    const Process &
175    GetProcess() const { return m_process; }
176
177    int
178    GetResumeSignal () const;
179
180    void
181    SetResumeSignal (int signal);
182
183    lldb::StateType
184    GetState() const;
185
186    lldb::ThreadSP
187    GetSP ();
188
189    void
190    SetState (lldb::StateType state);
191
192    lldb::StateType
193    GetResumeState () const;
194
195    void
196    SetResumeState (lldb::StateType state);
197
198    // This function is called on all the threads before "WillResume" in case
199    // a thread needs to change its state before the ThreadList polls all the
200    // threads to figure out which ones actually will get to run and how.
201    void
202    SetupForResume ();
203
204    // Override this to do platform specific tasks before resume, but always
205    // call the Thread::WillResume at the end of your work.
206
207    virtual bool
208    WillResume (lldb::StateType resume_state);
209
210    // This clears generic thread state after a resume.  If you subclass this,
211    // be sure to call it.
212    virtual void
213    DidResume ();
214
215    virtual void
216    RefreshStateAfterStop() = 0;
217
218    void
219    WillStop ();
220
221    bool
222    ShouldStop (Event *event_ptr);
223
224    lldb::Vote
225    ShouldReportStop (Event *event_ptr);
226
227    lldb::Vote
228    ShouldReportRun (Event *event_ptr);
229
230    // Return whether this thread matches the specification in ThreadSpec.  This is a virtual
231    // method because at some point we may extend the thread spec with a platform specific
232    // dictionary of attributes, which then only the platform specific Thread implementation
233    // would know how to match.  For now, this just calls through to the ThreadSpec's
234    // ThreadPassesBasicTests method.
235    virtual bool
236    MatchesSpec (const ThreadSpec *spec);
237
238    StopInfo *
239    GetStopInfo ();
240
241    bool
242    ThreadStoppedForAReason ();
243
244    virtual const char *
245    GetInfo () = 0;
246
247    virtual const char *
248    GetName ()
249    {
250        return NULL;
251    }
252
253    virtual const char *
254    GetQueueName ()
255    {
256        return NULL;
257    }
258
259    virtual uint32_t
260    GetStackFrameCount();
261
262    virtual lldb::StackFrameSP
263    GetStackFrameAtIndex (uint32_t idx);
264
265    lldb::StackFrameSP
266    GetSelectedFrame ();
267
268    uint32_t
269    SetSelectedFrame (lldb_private::StackFrame *frame);
270
271    void
272    SetSelectedFrameByIndex (uint32_t frame_idx);
273
274    virtual RegisterContext *
275    GetRegisterContext () = 0;
276
277    virtual bool
278    SaveFrameZeroState (RegisterCheckpoint &checkpoint) = 0;
279
280    virtual bool
281    RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint) = 0;
282
283    virtual RegisterContext *
284    CreateRegisterContextForFrame (StackFrame *frame) = 0;
285
286    virtual void
287    ClearStackFrames ();
288
289    void
290    DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
291
292    //------------------------------------------------------------------
293    // Thread Plan Providers:
294    // This section provides the basic thread plans that the Process control
295    // machinery uses to run the target.  ThreadPlan.h provides more details on
296    // how this mechanism works.
297    // The thread provides accessors to a set of plans that perform basic operations.
298    // The idea is that particular Platform plugins can override these methods to
299    // provide the implementation of these basic operations appropriate to their
300    // environment.
301    //------------------------------------------------------------------
302
303    //------------------------------------------------------------------
304    /// Queues the base plan for a thread.
305    /// The version returned by Process does some things that are useful,
306    /// like handle breakpoints and signals, so if you return a plugin specific
307    /// one you probably want to call through to the Process one for anything
308    /// your plugin doesn't explicitly handle.
309    ///
310    /// @param[in] abort_other_plans
311    ///    \b true if we discard the currently queued plans and replace them with this one.
312    ///    Otherwise this plan will go on the end of the plan stack.
313    ///
314    /// @return
315    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
316    //------------------------------------------------------------------
317    virtual ThreadPlan *
318    QueueFundamentalPlan (bool abort_other_plans);
319
320    //------------------------------------------------------------------
321    /// Queues the plan used to step over a breakpoint at the current PC of \a thread.
322    /// The default version returned by Process handles trap based breakpoints, and
323    /// will disable the breakpoint, single step over it, then re-enable it.
324    ///
325    /// @param[in] abort_other_plans
326    ///    \b true if we discard the currently queued plans and replace them with this one.
327    ///    Otherwise this plan will go on the end of the plan stack.
328    ///
329    /// @return
330    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
331    //------------------------------------------------------------------
332    virtual ThreadPlan *
333    QueueThreadPlanForStepOverBreakpointPlan (bool abort_other_plans);
334
335    //------------------------------------------------------------------
336    /// Queues the plan used to step one instruction from the current PC of \a thread.
337    ///
338    /// @param[in] step_over
339    ///    \b true if we step over calls to functions, false if we step in.
340    ///
341    /// @param[in] abort_other_plans
342    ///    \b true if we discard the currently queued plans and replace them with this one.
343    ///    Otherwise this plan will go on the end of the plan stack.
344    ///
345    /// @param[in] stop_other_threads
346    ///    \b true if we will stop other threads while we single step this one.
347    ///
348    /// @return
349    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
350    //------------------------------------------------------------------
351    virtual ThreadPlan *
352    QueueThreadPlanForStepSingleInstruction (bool step_over,
353                                             bool abort_other_plans,
354                                             bool stop_other_threads);
355
356    //------------------------------------------------------------------
357    /// Queues the plan used to step through an address range, stepping into or over
358    /// function calls depending on the value of StepType.
359    ///
360    /// @param[in] abort_other_plans
361    ///    \b true if we discard the currently queued plans and replace them with this one.
362    ///    Otherwise this plan will go on the end of the plan stack.
363    ///
364    /// @param[in] type
365    ///    Type of step to do, only eStepTypeInto and eStepTypeOver are supported by this plan.
366    ///
367    /// @param[in] range
368    ///    The address range to step through.
369    ///
370    /// @param[in] addr_context
371    ///    When dealing with stepping through inlined functions the current PC is not enough information to know
372    ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
373    //     The \a addr_context provides the current symbol context the step
374    ///    is supposed to be out of.
375    //   FIXME: Currently unused.
376    ///
377    /// @param[in] stop_other_threads
378    ///    \b true if we will stop other threads while we single step this one.
379    ///
380    /// @return
381    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
382    //------------------------------------------------------------------
383    virtual ThreadPlan *
384    QueueThreadPlanForStepRange (bool abort_other_plans,
385                                 lldb::StepType type,
386                                 const AddressRange &range,
387                                 const SymbolContext &addr_context,
388                                 lldb::RunMode stop_other_threads,
389                                 bool avoid_code_without_debug_info);
390
391    //------------------------------------------------------------------
392    /// Queue the plan used to step out of the function at the current PC of
393    /// \a thread.
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] addr_context
400    ///    When dealing with stepping through inlined functions the current PC is not enough information to know
401    ///    what "step" means.  For instance a series of nested inline functions might start at the same address.
402    //     The \a addr_context provides the current symbol context the step
403    ///    is supposed to be out of.
404    //   FIXME: Currently unused.
405    ///
406    /// @param[in] first_insn
407    ///     \b true if this is the first instruction of a function.
408    ///
409    /// @param[in] stop_other_threads
410    ///    \b true if we will stop other threads while we single step this one.
411    ///
412    /// @param[in] stop_vote
413    /// @param[in] run_vote
414    ///    See standard meanings for the stop & run votes in ThreadPlan.h.
415    ///
416    /// @return
417    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
418    //------------------------------------------------------------------
419    virtual ThreadPlan *
420    QueueThreadPlanForStepOut (bool abort_other_plans,
421                               SymbolContext *addr_context,
422                               bool first_insn,
423                               bool stop_other_threads,
424                               lldb::Vote stop_vote = lldb::eVoteYes,
425                               lldb::Vote run_vote = lldb::eVoteNoOpinion);
426
427    //------------------------------------------------------------------
428    /// Gets the plan used to step through the code that steps from a function
429    /// call site at the current PC into the actual function call.
430    ///
431    /// @param[in] abort_other_plans
432    ///    \b true if we discard the currently queued plans and replace them with this one.
433    ///    Otherwise this plan will go on the end of the plan stack.
434    ///
435    /// @param[in] stop_other_threads
436    ///    \b true if we will stop other threads while we single step this one.
437    ///
438    /// @return
439    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
440    //------------------------------------------------------------------
441    virtual ThreadPlan *
442    QueueThreadPlanForStepThrough (bool abort_other_plans,
443                                   bool stop_other_threads);
444
445    //------------------------------------------------------------------
446    /// Gets the plan used to continue from the current PC.
447    /// This is a simple plan, mostly useful as a backstop when you are continuing
448    /// for some particular purpose.
449    ///
450    /// @param[in] abort_other_plans
451    ///    \b true if we discard the currently queued plans and replace them with this one.
452    ///    Otherwise this plan will go on the end of the plan stack.
453    ///
454    /// @param[in] target_addr
455    ///    The address to which we're running.
456    ///
457    /// @param[in] stop_other_threads
458    ///    \b true if we will stop other threads while we single step this one.
459    ///
460    /// @return
461    ///     A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
462    //------------------------------------------------------------------
463    virtual ThreadPlan *
464    QueueThreadPlanForRunToAddress (bool abort_other_plans,
465                                    Address &target_addr,
466                                    bool stop_other_threads);
467
468    virtual ThreadPlan *
469    QueueThreadPlanForStepUntil (bool abort_other_plans,
470                               lldb::addr_t *address_list,
471                               size_t num_addresses,
472                               bool stop_others);
473
474    virtual ThreadPlan *
475    QueueThreadPlanForCallFunction (bool abort_other_plans,
476                                    Address& function,
477                                    lldb::addr_t arg,
478                                    bool stop_other_threads,
479                                    bool discard_on_error = false);
480
481    virtual ThreadPlan *
482    QueueThreadPlanForCallFunction (bool abort_other_plans,
483                                    Address& function,
484                                    ValueList &args,
485                                    bool stop_other_threads,
486                                    bool discard_on_error = false);
487
488    //------------------------------------------------------------------
489    // Thread Plan accessors:
490    //------------------------------------------------------------------
491
492    //------------------------------------------------------------------
493    /// Gets the plan which will execute next on the plan stack.
494    ///
495    /// @return
496    ///     A pointer to the next executed plan.
497    //------------------------------------------------------------------
498    ThreadPlan *
499    GetCurrentPlan ();
500
501    //------------------------------------------------------------------
502    /// Gets the inner-most plan that was popped off the plan stack in the
503    /// most recent stop.  Useful for printing the stop reason accurately.
504    ///
505    /// @return
506    ///     A pointer to the last completed plan.
507    //------------------------------------------------------------------
508    lldb::ThreadPlanSP
509    GetCompletedPlan ();
510
511    //------------------------------------------------------------------
512    ///  Checks whether the given plan is in the completed plans for this
513    ///  stop.
514    ///
515    /// @param[in] plan
516    ///     Pointer to the plan you're checking.
517    ///
518    /// @return
519    ///     Returns true if the input plan is in the completed plan stack,
520    ///     false otherwise.
521    //------------------------------------------------------------------
522    bool
523    IsThreadPlanDone (ThreadPlan *plan);
524
525    //------------------------------------------------------------------
526    ///  Checks whether the given plan is in the discarded plans for this
527    ///  stop.
528    ///
529    /// @param[in] plan
530    ///     Pointer to the plan you're checking.
531    ///
532    /// @return
533    ///     Returns true if the input plan is in the discarded plan stack,
534    ///     false otherwise.
535    //------------------------------------------------------------------
536    bool
537    WasThreadPlanDiscarded (ThreadPlan *plan);
538
539    //------------------------------------------------------------------
540    /// Queues a generic thread plan.
541    ///
542    /// @param[in] plan_sp
543    ///    The plan to queue.
544    ///
545    /// @param[in] abort_other_plans
546    ///    \b true if we discard the currently queued plans and replace them with this one.
547    ///    Otherwise this plan will go on the end of the plan stack.
548    ///
549    /// @return
550    ///     A pointer to the last completed plan.
551    //------------------------------------------------------------------
552    void
553    QueueThreadPlan (lldb::ThreadPlanSP &plan_sp, bool abort_other_plans);
554
555
556    //------------------------------------------------------------------
557    /// Discards the plans queued on the plan stack of the current thread.  This is
558    /// arbitrated by the "Master" ThreadPlans, using the "OkayToDiscard" call.
559    //  But if \a force is true, all thread plans are discarded.
560    //------------------------------------------------------------------
561    void
562    DiscardThreadPlans (bool force);
563
564    //------------------------------------------------------------------
565    /// Prints the current plan stack.
566    ///
567    /// @param[in] s
568    ///    The stream to which to dump the plan stack info.
569    ///
570    //------------------------------------------------------------------
571    void
572    DumpThreadPlans (Stream *s) const;
573
574    //------------------------------------------------------------------
575    /// The regular expression returned determines symbols that this
576    /// thread won't stop in during "step-in" operations.
577    ///
578    /// @return
579    ///    A pointer to a regular expression to compare against symbols,
580    ///    or NULL if all symbols are allowed.
581    ///
582    //------------------------------------------------------------------
583    RegularExpression *
584    GetSymbolsToAvoidRegexp()
585    {
586        return ThreadInstanceSettings::GetSymbolsToAvoidRegexp();
587    }
588
589    // Get the thread index ID. The index ID that is guaranteed to not be
590    // re-used by a process. They start at 1 and increase with each new thread.
591    // This allows easy command line access by a unique ID that is easier to
592    // type than the actual system thread ID.
593    uint32_t
594    GetIndexID () const;
595
596    //------------------------------------------------------------------
597    // lldb::ExecutionContextScope pure virtual functions
598    //------------------------------------------------------------------
599    virtual Target *
600    CalculateTarget ();
601
602    virtual Process *
603    CalculateProcess ();
604
605    virtual Thread *
606    CalculateThread ();
607
608    virtual StackFrame *
609    CalculateStackFrame ();
610
611    virtual void
612    CalculateExecutionContext (ExecutionContext &exe_ctx);
613
614    lldb::StackFrameSP
615    GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
616
617protected:
618
619    friend class ThreadPlan;
620    friend class StackFrameList;
621
622    void
623    PushPlan (lldb::ThreadPlanSP &plan_sp);
624
625    void
626    PopPlan ();
627
628    void
629    DiscardPlan ();
630
631    ThreadPlan *GetPreviousPlan (ThreadPlan *plan);
632
633    virtual lldb::StopInfoSP
634    GetPrivateStopReason () = 0;
635
636    typedef std::vector<lldb::ThreadPlanSP> plan_stack;
637
638    virtual lldb_private::Unwind *
639    GetUnwinder () = 0;
640
641    StackFrameList &
642    GetStackFrameList ();
643
644    //------------------------------------------------------------------
645    // Classes that inherit from Process can see and modify these
646    //------------------------------------------------------------------
647    Process &           m_process;          ///< The process that owns this thread.
648    lldb::StopInfoSP    m_public_stop_info_sp;     ///< The public stop reason for this thread
649    lldb::StopInfoSP    m_actual_stop_info_sp;     ///< The private stop reason for this thread
650    const uint32_t      m_index_id;         ///< A unique 1 based index assigned to each thread for easy UI/command line access.
651    lldb::RegisterContextSP   m_reg_context_sp;   ///< The register context for this thread's current register state.
652    lldb::StateType     m_state;            ///< The state of our process.
653    mutable Mutex       m_state_mutex;      ///< Multithreaded protection for m_state.
654    plan_stack          m_plan_stack;       ///< The stack of plans this thread is executing.
655    plan_stack          m_immediate_plan_stack; ///< The plans that need to get executed before any other work gets done.
656    plan_stack          m_completed_plan_stack;  ///< Plans that have been completed by this stop.  They get deleted when the thread resumes.
657    plan_stack          m_discarded_plan_stack;  ///< Plans that have been discarded by this stop.  They get deleted when the thread resumes.
658    std::auto_ptr<StackFrameList> m_curr_frames_ap; ///< The stack frames that get lazily populated after a thread stops.
659    lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped.
660    int                 m_resume_signal;    ///< The signal that should be used when continuing this thread.
661    lldb::StateType     m_resume_state;     ///< The state that indicates what this thread should do when the process is resumed.
662    std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;
663private:
664    //------------------------------------------------------------------
665    // For Thread only
666    //------------------------------------------------------------------
667    DISALLOW_COPY_AND_ASSIGN (Thread);
668
669};
670
671} // namespace lldb_private
672
673#endif  // liblldb_Thread_h_
674