]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/llvm/tools/lldb/include/lldb/API/SBThread.h
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / contrib / llvm / tools / lldb / include / lldb / API / SBThread.h
1 //===-- SBThread.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 LLDB_SBThread_h_
11 #define LLDB_SBThread_h_
12
13 #include "lldb/API/SBDefines.h"
14
15 #include <stdio.h>
16
17 namespace lldb {
18
19 class SBFrame;
20
21 class SBThread
22 {
23 public:
24     enum
25     {
26         eBroadcastBitStackChanged           = (1 << 0),
27         eBroadcastBitThreadSuspended        = (1 << 1),
28         eBroadcastBitThreadResumed          = (1 << 2),
29         eBroadcastBitSelectedFrameChanged   = (1 << 3),
30         eBroadcastBitThreadSelected         = (1 << 4)
31     };
32
33     static const char *
34     GetBroadcasterClassName ();
35     
36     SBThread ();
37
38     SBThread (const lldb::SBThread &thread);
39     
40     SBThread (const lldb::ThreadSP& lldb_object_sp);
41
42    ~SBThread();
43
44     bool
45     IsValid() const;
46
47     void
48     Clear ();
49
50     lldb::StopReason
51     GetStopReason();
52
53     /// Get the number of words associated with the stop reason.
54     /// See also GetStopReasonDataAtIndex().
55     size_t
56     GetStopReasonDataCount();
57
58     //--------------------------------------------------------------------------
59     /// Get information associated with a stop reason.
60     ///
61     /// Breakpoint stop reasons will have data that consists of pairs of 
62     /// breakpoint IDs followed by the breakpoint location IDs (they always come
63     /// in pairs).
64     ///
65     /// Stop Reason              Count Data Type
66     /// ======================== ===== =========================================
67     /// eStopReasonNone          0
68     /// eStopReasonTrace         0
69     /// eStopReasonBreakpoint    N     duple: {breakpoint id, location id}
70     /// eStopReasonWatchpoint    1     watchpoint id
71     /// eStopReasonSignal        1     unix signal number
72     /// eStopReasonException     N     exception data
73     /// eStopReasonExec          0
74     /// eStopReasonPlanComplete  0
75     //--------------------------------------------------------------------------
76     uint64_t
77     GetStopReasonDataAtIndex(uint32_t idx);
78
79     size_t
80     GetStopDescription (char *dst, size_t dst_len);
81     
82     SBValue
83     GetStopReturnValue ();
84
85     lldb::tid_t
86     GetThreadID () const;
87
88     uint32_t
89     GetIndexID () const;
90
91     const char *
92     GetName () const;
93
94     const char *
95     GetQueueName() const;
96
97     void
98     StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
99
100     void
101     StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
102
103     void
104     StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
105     
106     void
107     StepOut ();
108
109     void
110     StepOutOfFrame (lldb::SBFrame &frame);
111
112     void
113     StepInstruction(bool step_over);
114
115     SBError
116     StepOverUntil (lldb::SBFrame &frame, 
117                    lldb::SBFileSpec &file_spec, 
118                    uint32_t line);
119
120     void
121     RunToAddress (lldb::addr_t addr);
122     
123     SBError
124     ReturnFromFrame (SBFrame &frame, SBValue &return_value);
125
126     //--------------------------------------------------------------------------
127     /// LLDB currently supports process centric debugging which means when any
128     /// thread in a process stops, all other threads are stopped. The Suspend()
129     /// call here tells our process to suspend a thread and not let it run when
130     /// the other threads in a process are allowed to run. So when 
131     /// SBProcess::Continue() is called, any threads that aren't suspended will
132     /// be allowed to run. If any of the SBThread functions for stepping are 
133     /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
134     /// thread will not be allowed to run and these funtions will simply return.
135     ///
136     /// Eventually we plan to add support for thread centric debugging where
137     /// each thread is controlled individually and each thread would broadcast
138     /// its state, but we haven't implemented this yet.
139     /// 
140     /// Likewise the SBThread::Resume() call will again allow the thread to run
141     /// when the process is continued.
142     ///
143     /// Suspend() and Resume() functions are not currently reference counted, if
144     /// anyone has the need for them to be reference counted, please let us
145     /// know.
146     //--------------------------------------------------------------------------
147     bool
148     Suspend();
149     
150     bool
151     Resume ();
152     
153     bool
154     IsSuspended();
155
156     bool
157     IsStopped();
158
159     uint32_t
160     GetNumFrames ();
161
162     lldb::SBFrame
163     GetFrameAtIndex (uint32_t idx);
164
165     lldb::SBFrame
166     GetSelectedFrame ();
167
168     lldb::SBFrame
169     SetSelectedFrame (uint32_t frame_idx);
170     
171     static bool
172     EventIsThreadEvent (const SBEvent &event);
173     
174     static SBFrame
175     GetStackFrameFromEvent (const SBEvent &event);
176     
177     static SBThread
178     GetThreadFromEvent (const SBEvent &event);
179
180     lldb::SBProcess
181     GetProcess ();
182
183     const lldb::SBThread &
184     operator = (const lldb::SBThread &rhs);
185
186     bool
187     operator == (const lldb::SBThread &rhs) const;
188
189     bool
190     operator != (const lldb::SBThread &rhs) const;
191
192     bool
193     GetDescription (lldb::SBStream &description) const;
194     
195     bool
196     GetStatus (lldb::SBStream &status) const;
197
198 protected:
199     friend class SBBreakpoint;
200     friend class SBBreakpointLocation;
201     friend class SBFrame;
202     friend class SBProcess;
203     friend class SBDebugger;
204     friend class SBValue;
205
206     void
207     SetThread (const lldb::ThreadSP& lldb_object_sp);
208
209 #ifndef SWIG
210     SBError
211     ResumeNewPlan (lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan);
212 #endif
213
214 private:
215     lldb::ExecutionContextRefSP m_opaque_sp;
216 };
217
218 } // namespace lldb
219
220 #endif  // LLDB_SBThread_h_