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 StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
98 void StepInto(const char *target_name,
99 lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
101 void StepInto(const char *target_name, uint32_t end_line, SBError &error,
102 lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
106 void StepOutOfFrame(lldb::SBFrame &frame);
108 void StepInstruction(bool step_over);
110 SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec,
113 SBError StepUsingScriptedThreadPlan(const char *script_class_name);
115 SBError StepUsingScriptedThreadPlan(const char *script_class_name,
116 bool resume_immediately);
118 SBError JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line);
120 void RunToAddress(lldb::addr_t addr);
122 SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value);
124 SBError UnwindInnermostExpression();
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, RunToAddress), the
134 /// thread will not be allowed to run and these functions will simply return.
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.
140 /// Likewise the SBThread::Resume() call will again allow the thread to run
141 /// when the process is continued.
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
146 //--------------------------------------------------------------------------
155 uint32_t GetNumFrames();
157 lldb::SBFrame GetFrameAtIndex(uint32_t idx);
159 lldb::SBFrame GetSelectedFrame();
161 lldb::SBFrame SetSelectedFrame(uint32_t frame_idx);
163 static bool EventIsThreadEvent(const SBEvent &event);
165 static SBFrame GetStackFrameFromEvent(const SBEvent &event);
167 static SBThread GetThreadFromEvent(const SBEvent &event);
169 lldb::SBProcess GetProcess();
171 const lldb::SBThread &operator=(const lldb::SBThread &rhs);
173 bool operator==(const lldb::SBThread &rhs) const;
175 bool operator!=(const lldb::SBThread &rhs) const;
177 bool GetDescription(lldb::SBStream &description) const;
179 bool GetDescription(lldb::SBStream &description, bool stop_format) const;
181 bool GetStatus(lldb::SBStream &status) const;
183 SBThread GetExtendedBacktraceThread(const char *type);
185 uint32_t GetExtendedBacktraceOriginatingIndexID();
187 bool SafeToCallFunctions();
190 lldb_private::Thread *operator->();
192 lldb_private::Thread *get();
197 friend class SBBreakpoint;
198 friend class SBBreakpointLocation;
199 friend class SBExecutionContext;
200 friend class SBFrame;
201 friend class SBProcess;
202 friend class SBDebugger;
203 friend class SBValue;
204 friend class lldb_private::QueueImpl;
205 friend class SBQueueItem;
207 void SetThread(const lldb::ThreadSP &lldb_object_sp);
210 SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
211 lldb_private::ThreadPlan *new_plan);
215 lldb::ExecutionContextRefSP m_opaque_sp;
220 #endif // LLDB_SBThread_h_