]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/API/SBThread.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.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     lldb::queue_id_t
98     GetQueueID() const;
99
100     void
101     StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
102
103     void
104     StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
105
106     void
107     StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
108     
109     void
110     StepOut ();
111
112     void
113     StepOutOfFrame (lldb::SBFrame &frame);
114
115     void
116     StepInstruction(bool step_over);
117
118     SBError
119     StepOverUntil (lldb::SBFrame &frame, 
120                    lldb::SBFileSpec &file_spec, 
121                    uint32_t line);
122
123     SBError
124     JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line);
125
126     void
127     RunToAddress (lldb::addr_t addr);
128     
129     SBError
130     ReturnFromFrame (SBFrame &frame, SBValue &return_value);
131
132     //--------------------------------------------------------------------------
133     /// LLDB currently supports process centric debugging which means when any
134     /// thread in a process stops, all other threads are stopped. The Suspend()
135     /// call here tells our process to suspend a thread and not let it run when
136     /// the other threads in a process are allowed to run. So when 
137     /// SBProcess::Continue() is called, any threads that aren't suspended will
138     /// be allowed to run. If any of the SBThread functions for stepping are 
139     /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
140     /// thread will not be allowed to run and these funtions will simply return.
141     ///
142     /// Eventually we plan to add support for thread centric debugging where
143     /// each thread is controlled individually and each thread would broadcast
144     /// its state, but we haven't implemented this yet.
145     /// 
146     /// Likewise the SBThread::Resume() call will again allow the thread to run
147     /// when the process is continued.
148     ///
149     /// Suspend() and Resume() functions are not currently reference counted, if
150     /// anyone has the need for them to be reference counted, please let us
151     /// know.
152     //--------------------------------------------------------------------------
153     bool
154     Suspend();
155     
156     bool
157     Resume ();
158     
159     bool
160     IsSuspended();
161
162     bool
163     IsStopped();
164
165     uint32_t
166     GetNumFrames ();
167
168     lldb::SBFrame
169     GetFrameAtIndex (uint32_t idx);
170
171     lldb::SBFrame
172     GetSelectedFrame ();
173
174     lldb::SBFrame
175     SetSelectedFrame (uint32_t frame_idx);
176     
177     static bool
178     EventIsThreadEvent (const SBEvent &event);
179     
180     static SBFrame
181     GetStackFrameFromEvent (const SBEvent &event);
182     
183     static SBThread
184     GetThreadFromEvent (const SBEvent &event);
185
186     lldb::SBProcess
187     GetProcess ();
188
189     const lldb::SBThread &
190     operator = (const lldb::SBThread &rhs);
191
192     bool
193     operator == (const lldb::SBThread &rhs) const;
194
195     bool
196     operator != (const lldb::SBThread &rhs) const;
197
198     bool
199     GetDescription (lldb::SBStream &description) const;
200     
201     bool
202     GetStatus (lldb::SBStream &status) const;
203
204     SBThread
205     GetExtendedBacktraceThread (const char *type);
206
207     uint32_t
208     GetExtendedBacktraceOriginatingIndexID ();
209
210 protected:
211     friend class SBBreakpoint;
212     friend class SBBreakpointLocation;
213     friend class SBFrame;
214     friend class SBProcess;
215     friend class SBDebugger;
216     friend class SBValue;
217     friend class lldb_private::QueueImpl;
218     friend class SBQueueItem;
219
220     void
221     SetThread (const lldb::ThreadSP& lldb_object_sp);
222
223 #ifndef SWIG
224     SBError
225     ResumeNewPlan (lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan);
226 #endif
227
228 private:
229     lldb::ExecutionContextRefSP m_opaque_sp;
230 };
231
232 } // namespace lldb
233
234 #endif  // LLDB_SBThread_h_