1 //===-- SBThread.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBThread_h_
11 #define LLDB_SBThread_h_
13 #include "lldb/API/SBDefines.h"
21 class LLDB_API SBThread {
24 eBroadcastBitStackChanged = (1 << 0),
25 eBroadcastBitThreadSuspended = (1 << 1),
26 eBroadcastBitThreadResumed = (1 << 2),
27 eBroadcastBitSelectedFrameChanged = (1 << 3),
28 eBroadcastBitThreadSelected = (1 << 4)
31 static const char *GetBroadcasterClassName();
35 SBThread(const lldb::SBThread &thread);
37 SBThread(const lldb::ThreadSP &lldb_object_sp);
41 lldb::SBQueue GetQueue() const;
47 lldb::StopReason GetStopReason();
49 /// Get the number of words associated with the stop reason.
50 /// See also GetStopReasonDataAtIndex().
51 size_t GetStopReasonDataCount();
53 //--------------------------------------------------------------------------
54 /// Get information associated with a stop reason.
56 /// Breakpoint stop reasons will have data that consists of pairs of
57 /// breakpoint IDs followed by the breakpoint location IDs (they always come
60 /// Stop Reason Count Data Type
61 /// ======================== ===== =========================================
63 /// eStopReasonTrace 0
64 /// eStopReasonBreakpoint N duple: {breakpoint id, location id}
65 /// eStopReasonWatchpoint 1 watchpoint id
66 /// eStopReasonSignal 1 unix signal number
67 /// eStopReasonException N exception data
69 /// eStopReasonPlanComplete 0
70 //--------------------------------------------------------------------------
71 uint64_t GetStopReasonDataAtIndex(uint32_t idx);
73 bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream);
76 GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type);
78 size_t GetStopDescription(char *dst, size_t dst_len);
80 SBValue GetStopReturnValue();
82 lldb::tid_t GetThreadID() const;
84 uint32_t GetIndexID() const;
86 const char *GetName() const;
88 const char *GetQueueName() const;
90 lldb::queue_id_t GetQueueID() const;
92 bool GetInfoItemByPathAsString(const char *path, SBStream &strm);
94 void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
96 void StepOver(lldb::RunMode stop_other_threads, SBError &error);
98 void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
100 void StepInto(const char *target_name,
101 lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
103 void StepInto(const char *target_name, uint32_t end_line, SBError &error,
104 lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
108 void StepOut(SBError &error);
110 void StepOutOfFrame(SBFrame &frame);
112 void StepOutOfFrame(SBFrame &frame, SBError &error);
114 void StepInstruction(bool step_over);
116 void StepInstruction(bool step_over, SBError &error);
118 SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec,
121 SBError StepUsingScriptedThreadPlan(const char *script_class_name);
123 SBError StepUsingScriptedThreadPlan(const char *script_class_name,
124 bool resume_immediately);
126 SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line);
128 void RunToAddress(lldb::addr_t addr);
130 void RunToAddress(lldb::addr_t addr, SBError &error);
132 SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value);
134 SBError UnwindInnermostExpression();
136 //--------------------------------------------------------------------------
137 /// LLDB currently supports process centric debugging which means when any
138 /// thread in a process stops, all other threads are stopped. The Suspend()
139 /// call here tells our process to suspend a thread and not let it run when
140 /// the other threads in a process are allowed to run. So when
141 /// SBProcess::Continue() is called, any threads that aren't suspended will
142 /// be allowed to run. If any of the SBThread functions for stepping are
143 /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddress), the
144 /// thread will not be allowed to run and these functions will simply return.
146 /// Eventually we plan to add support for thread centric debugging where
147 /// each thread is controlled individually and each thread would broadcast
148 /// its state, but we haven't implemented this yet.
150 /// Likewise the SBThread::Resume() call will again allow the thread to run
151 /// when the process is continued.
153 /// Suspend() and Resume() functions are not currently reference counted, if
154 /// anyone has the need for them to be reference counted, please let us
156 //--------------------------------------------------------------------------
159 bool Suspend(SBError &error);
163 bool Resume(SBError &error);
169 uint32_t GetNumFrames();
171 lldb::SBFrame GetFrameAtIndex(uint32_t idx);
173 lldb::SBFrame GetSelectedFrame();
175 lldb::SBFrame SetSelectedFrame(uint32_t frame_idx);
177 static bool EventIsThreadEvent(const SBEvent &event);
179 static SBFrame GetStackFrameFromEvent(const SBEvent &event);
181 static SBThread GetThreadFromEvent(const SBEvent &event);
183 lldb::SBProcess GetProcess();
185 const lldb::SBThread &operator=(const lldb::SBThread &rhs);
187 bool operator==(const lldb::SBThread &rhs) const;
189 bool operator!=(const lldb::SBThread &rhs) const;
191 bool GetDescription(lldb::SBStream &description) const;
193 bool GetDescription(lldb::SBStream &description, bool stop_format) const;
195 bool GetStatus(lldb::SBStream &status) const;
197 SBThread GetExtendedBacktraceThread(const char *type);
199 uint32_t GetExtendedBacktraceOriginatingIndexID();
201 bool SafeToCallFunctions();
204 lldb_private::Thread *operator->();
206 lldb_private::Thread *get();
211 friend class SBBreakpoint;
212 friend class SBBreakpointLocation;
213 friend class SBBreakpointCallbackBaton;
214 friend class SBExecutionContext;
215 friend class SBFrame;
216 friend class SBProcess;
217 friend class SBDebugger;
218 friend class SBValue;
219 friend class lldb_private::QueueImpl;
220 friend class SBQueueItem;
222 void SetThread(const lldb::ThreadSP &lldb_object_sp);
225 SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
226 lldb_private::ThreadPlan *new_plan);
230 lldb::ExecutionContextRefSP m_opaque_sp;
235 #endif // LLDB_SBThread_h_