LLDB mainline
SBThread.h
Go to the documentation of this file.
1//===-- SBThread.h ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_API_SBTHREAD_H
10#define LLDB_API_SBTHREAD_H
11
12#include "lldb/API/SBDefines.h"
13
14#include <cstdio>
15
16namespace lldb {
17
18class SBFrame;
19
21public:
22 enum {
23 eBroadcastBitStackChanged = (1 << 0),
24 eBroadcastBitThreadSuspended = (1 << 1),
25 eBroadcastBitThreadResumed = (1 << 2),
26 eBroadcastBitSelectedFrameChanged = (1 << 3),
27 eBroadcastBitThreadSelected = (1 << 4)
28 };
29
30 static const char *GetBroadcasterClassName();
31
32 SBThread();
33
34 SBThread(const lldb::SBThread &thread);
35
36#ifndef SWIG
37 SBThread(const lldb::ThreadSP &lldb_object_sp);
38#endif
39
41
42 lldb::SBQueue GetQueue() const;
43
44 explicit operator bool() const;
45
46 bool IsValid() const;
47
48 void Clear();
49
50 lldb::StopReason GetStopReason();
51
52 /// Get the number of words associated with the stop reason.
53 /// See also GetStopReasonDataAtIndex().
54 size_t GetStopReasonDataCount();
55
56 /// Get information associated with a stop reason.
57 ///
58 /// Breakpoint stop reasons will have data that consists of pairs of
59 /// breakpoint IDs followed by the breakpoint location IDs (they always come
60 /// in pairs).
61 ///
62 /// Stop Reason Count Data Type
63 /// ======================== ===== =========================================
64 /// eStopReasonNone 0
65 /// eStopReasonTrace 0
66 /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
67 /// eStopReasonWatchpoint 1 watchpoint id
68 /// eStopReasonSignal 1 unix signal number
69 /// eStopReasonException N exception data
70 /// eStopReasonExec 0
71 /// eStopReasonFork 1 pid of the child process
72 /// eStopReasonVFork 1 pid of the child process
73 /// eStopReasonVForkDone 0
74 /// eStopReasonPlanComplete 0
75 uint64_t GetStopReasonDataAtIndex(uint32_t idx);
76
77 bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream);
78
80 GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type);
81
82 size_t GetStopDescription(char *dst_or_null, size_t dst_len);
83
84 SBValue GetStopReturnValue();
85
86 lldb::tid_t GetThreadID() const;
87
88 uint32_t GetIndexID() const;
89
90 const char *GetName() const;
91
92 const char *GetQueueName() const;
93
94 lldb::queue_id_t GetQueueID() const;
95
96 bool GetInfoItemByPathAsString(const char *path, SBStream &strm);
97
98 void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
99
100 void StepOver(lldb::RunMode stop_other_threads, SBError &error);
101
102 void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
103
104 void StepInto(const char *target_name,
105 lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
106
107 void StepInto(const char *target_name, uint32_t end_line, SBError &error,
108 lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
109
110 void StepOut();
111
112 void StepOut(SBError &error);
113
114 void StepOutOfFrame(SBFrame &frame);
115
116 void StepOutOfFrame(SBFrame &frame, SBError &error);
117
118 void StepInstruction(bool step_over);
119
120 void StepInstruction(bool step_over, SBError &error);
121
122 SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec,
123 uint32_t line);
124
125 SBError StepUsingScriptedThreadPlan(const char *script_class_name);
126
127 SBError StepUsingScriptedThreadPlan(const char *script_class_name,
128 bool resume_immediately);
129
130 SBError StepUsingScriptedThreadPlan(const char *script_class_name,
131 lldb::SBStructuredData &args_data,
132 bool resume_immediately);
133
134 SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line);
135
136 void RunToAddress(lldb::addr_t addr);
137
138 void RunToAddress(lldb::addr_t addr, SBError &error);
139
140 SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value);
141
142 SBError UnwindInnermostExpression();
143
144 /// LLDB currently supports process centric debugging which means when any
145 /// thread in a process stops, all other threads are stopped. The Suspend()
146 /// call here tells our process to suspend a thread and not let it run when
147 /// the other threads in a process are allowed to run. So when
148 /// SBProcess::Continue() is called, any threads that aren't suspended will
149 /// be allowed to run. If any of the SBThread functions for stepping are
150 /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddress), the
151 /// thread will not be allowed to run and these functions will simply return.
152 ///
153 /// Eventually we plan to add support for thread centric debugging where
154 /// each thread is controlled individually and each thread would broadcast
155 /// its state, but we haven't implemented this yet.
156 ///
157 /// Likewise the SBThread::Resume() call will again allow the thread to run
158 /// when the process is continued.
159 ///
160 /// Suspend() and Resume() functions are not currently reference counted, if
161 /// anyone has the need for them to be reference counted, please let us
162 /// know.
163 bool Suspend();
164
165 bool Suspend(SBError &error);
166
167 bool Resume();
168
169 bool Resume(SBError &error);
170
171 bool IsSuspended();
172
173 bool IsStopped();
174
175 uint32_t GetNumFrames();
176
177 lldb::SBFrame GetFrameAtIndex(uint32_t idx);
178
179 lldb::SBFrame GetSelectedFrame();
180
181 lldb::SBFrame SetSelectedFrame(uint32_t frame_idx);
182
183 static bool EventIsThreadEvent(const SBEvent &event);
184
185 static SBFrame GetStackFrameFromEvent(const SBEvent &event);
186
187 static SBThread GetThreadFromEvent(const SBEvent &event);
188
189 lldb::SBProcess GetProcess();
190
191 const lldb::SBThread &operator=(const lldb::SBThread &rhs);
192
193 bool operator==(const lldb::SBThread &rhs) const;
194
195 bool operator!=(const lldb::SBThread &rhs) const;
196
197 bool GetDescription(lldb::SBStream &description) const;
198
199 bool GetDescription(lldb::SBStream &description, bool stop_format) const;
200
201 bool GetStatus(lldb::SBStream &status) const;
202
203 SBThread GetExtendedBacktraceThread(const char *type);
204
205 uint32_t GetExtendedBacktraceOriginatingIndexID();
206
207 SBValue GetCurrentException();
208
209 SBThread GetCurrentExceptionBacktrace();
210
211 bool SafeToCallFunctions();
212
213 SBValue GetSiginfo();
214
215private:
216 friend class SBBreakpoint;
219 friend class SBExecutionContext;
220 friend class SBFrame;
221 friend class SBProcess;
222 friend class SBDebugger;
223 friend class SBValue;
225 friend class SBQueueItem;
226 friend class SBThreadPlan;
227 friend class SBTrace;
228
229 void SetThread(const lldb::ThreadSP &lldb_object_sp);
230
231 SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
232 lldb_private::ThreadPlan *new_plan);
233
234 lldb::ExecutionContextRefSP m_opaque_sp;
235
236 lldb_private::Thread *operator->();
237
239};
240
241} // namespace lldb
242
243#endif // LLDB_API_SBTHREAD_H
static llvm::raw_ostream & error(Stream &strm)
bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs)
bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs)
#define LLDB_API
Definition: SBDefines.h:26
static llvm::StringRef GetName(XcodeSDK::Type type)
Definition: XcodeSDK.cpp:21
SBThread(const lldb::ThreadSP &lldb_object_sp)
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBThread.h:234
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Definition: SBAddress.h:15
InstrumentationRuntimeType
uint64_t addr_t
Definition: lldb-types.h:79
StopReason
Thread stop reasons.
class LLDB_API SBFrame
Definition: SBDefines.h:60
RunMode
Thread Run Modes.
@ eOnlyDuringStepping
uint64_t tid_t
Definition: lldb-types.h:82
uint64_t queue_id_t
Definition: lldb-types.h:87