SBThread.h revision 2ded5ed80f3f4c794a2323b68a5da11fad61b6f2
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 17namespace lldb { 18 19class SBFrame; 20 21#ifdef SWIG 22%feature("docstring", 23"Represents a thread of execution. SBProcess contains SBThread(s). 24 25For example (in test/lldbutil.py), 26 27# ================================================== 28# Utility functions related to Threads and Processes 29# ================================================== 30 31def get_stopped_threads(process, reason): 32 '''Returns the thread(s) with the specified stop reason in a list. 33 34 The list can be empty if no such thread exists. 35 ''' 36 threads = [] 37 for t in process: 38 if t.GetStopReason() == reason: 39 threads.append(t) 40 return threads 41 42... 43" 44 ) SBThread; 45#endif 46class SBThread 47{ 48#ifdef SWIG 49 %feature("autodoc", "1"); 50#endif 51 52public: 53 SBThread (); 54 55 SBThread (const lldb::SBThread &thread); 56 57 ~SBThread(); 58 59 bool 60 IsValid() const; 61 62 void 63 Clear (); 64 65 lldb::StopReason 66 GetStopReason(); 67 68#ifdef SWIG 69 %feature("docstring", " 70#endif 71 /// Get the number of words associated with the stop reason. 72 /// See also GetStopReasonDataAtIndex(). 73#ifdef SWIG 74 ") GetStopReasonDataCount; 75#endif 76 size_t 77 GetStopReasonDataCount(); 78 79#ifdef SWIG 80 %feature("docstring", " 81#endif 82 //-------------------------------------------------------------------------- 83 /// Get information associated with a stop reason. 84 /// 85 /// Breakpoint stop reasons will have data that consists of pairs of 86 /// breakpoint IDs followed by the breakpoint location IDs (they always come 87 /// in pairs). 88 /// 89 /// Stop Reason Count Data Type 90 /// ======================== ===== ========================================= 91 /// eStopReasonNone 0 92 /// eStopReasonTrace 0 93 /// eStopReasonBreakpoint N duple: {breakpoint id, location id} 94 /// eStopReasonWatchpoint N duple: {watchpoint id, location id} 95 /// eStopReasonSignal 1 unix signal number 96 /// eStopReasonException N exception data 97 /// eStopReasonPlanComplete 0 98 //-------------------------------------------------------------------------- 99#ifdef SWIG 100 ") GetStopReasonDataAtIndex; 101#endif 102 uint64_t 103 GetStopReasonDataAtIndex(uint32_t idx); 104 105 size_t 106 GetStopDescription (char *dst, size_t dst_len); 107 108 lldb::tid_t 109 GetThreadID () const; 110 111 uint32_t 112 GetIndexID () const; 113 114 const char * 115 GetName () const; 116 117 const char * 118 GetQueueName() const; 119 120 void 121 StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); 122 123 void 124 StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); 125 126 void 127 StepOut (); 128 129 void 130 StepOutOfFrame (lldb::SBFrame &frame); 131 132 void 133 StepInstruction(bool step_over); 134 135 SBError 136 StepOverUntil (lldb::SBFrame &frame, 137 lldb::SBFileSpec &file_spec, 138 uint32_t line); 139 140 void 141 RunToAddress (lldb::addr_t addr); 142 143#ifdef SWIG 144 %feature("docstring", " 145#endif 146 //-------------------------------------------------------------------------- 147 /// LLDB currently supports process centric debugging which means when any 148 /// thread in a process stops, all other threads are stopped. The Suspend() 149 /// call here tells our process to suspend a thread and not let it run when 150 /// the other threads in a process are allowed to run. So when 151 /// SBProcess::Continue() is called, any threads that aren't suspended will 152 /// be allowed to run. If any of the SBThread functions for stepping are 153 /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the 154 /// thread will now be allowed to run and these funtions will simply return. 155 /// 156 /// Eventually we plan to add support for thread centric debugging where 157 /// each thread is controlled individually and each thread would broadcast 158 /// its state, but we haven't implemented this yet. 159 /// 160 /// Likewise the SBThread::Resume() call will again allow the thread to run 161 /// when the process is continued. 162 /// 163 /// Suspend() and Resume() functions are not currently reference counted, if 164 /// anyone has the need for them to be reference counted, please let us 165 /// know. 166 //-------------------------------------------------------------------------- 167#ifdef SWIG 168 ") Suspend; 169#endif 170 bool 171 Suspend(); 172 173 bool 174 Resume (); 175 176 bool 177 IsSuspended(); 178 179 uint32_t 180 GetNumFrames (); 181 182 lldb::SBFrame 183 GetFrameAtIndex (uint32_t idx); 184 185 lldb::SBFrame 186 GetSelectedFrame (); 187 188 lldb::SBFrame 189 SetSelectedFrame (uint32_t frame_idx); 190 191 lldb::SBProcess 192 GetProcess (); 193 194#ifndef SWIG 195 196 const lldb::SBThread & 197 operator = (const lldb::SBThread &rhs); 198 199 bool 200 operator == (const lldb::SBThread &rhs) const; 201 202 bool 203 operator != (const lldb::SBThread &rhs) const; 204 205#endif 206 207 bool 208 GetDescription (lldb::SBStream &description) const; 209 210protected: 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 218 219#ifndef SWIG 220 221 lldb_private::Thread * 222 get (); 223 224 const lldb_private::Thread * 225 operator->() const; 226 227 const lldb_private::Thread & 228 operator*() const; 229 230 231 lldb_private::Thread * 232 operator->(); 233 234 lldb_private::Thread & 235 operator*(); 236 237#endif 238 239 SBThread (const lldb::ThreadSP& lldb_object_sp); 240 241 void 242 SetThread (const lldb::ThreadSP& lldb_object_sp); 243 244private: 245 //------------------------------------------------------------------ 246 // Classes that inherit from Thread can see and modify these 247 //------------------------------------------------------------------ 248 249 lldb::ThreadSP m_opaque_sp; 250}; 251 252} // namespace lldb 253 254#endif // LLDB_SBThread_h_ 255