SBThread.h revision 90c5214bc61ee2cdf68236b36d9746ecd275302e
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 21class SBThread 22{ 23public: 24 SBThread (); 25 26 SBThread (const lldb::SBThread &thread); 27 28 ~SBThread(); 29 30 bool 31 IsValid() const; 32 33 void 34 Clear (); 35 36 lldb::StopReason 37 GetStopReason(); 38 39 /// Get the number of words associated with the stop reason. 40 /// See also GetStopReasonDataAtIndex(). 41 size_t 42 GetStopReasonDataCount(); 43 44 //-------------------------------------------------------------------------- 45 /// Get information associated with a stop reason. 46 /// 47 /// Breakpoint stop reasons will have data that consists of pairs of 48 /// breakpoint IDs followed by the breakpoint location IDs (they always come 49 /// in pairs). 50 /// 51 /// Stop Reason Count Data Type 52 /// ======================== ===== ========================================= 53 /// eStopReasonNone 0 54 /// eStopReasonTrace 0 55 /// eStopReasonBreakpoint N duple: {breakpoint id, location id} 56 /// eStopReasonWatchpoint 1 watchpoint id 57 /// eStopReasonSignal 1 unix signal number 58 /// eStopReasonException N exception data 59 /// eStopReasonPlanComplete 0 60 //-------------------------------------------------------------------------- 61 uint64_t 62 GetStopReasonDataAtIndex(uint32_t idx); 63 64 size_t 65 GetStopDescription (char *dst, size_t dst_len); 66 67 SBValue 68 GetStopReturnValue (); 69 70 lldb::tid_t 71 GetThreadID () const; 72 73 uint32_t 74 GetIndexID () const; 75 76 const char * 77 GetName () const; 78 79 const char * 80 GetQueueName() const; 81 82 void 83 StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); 84 85 void 86 StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); 87 88 void 89 StepOut (); 90 91 void 92 StepOutOfFrame (lldb::SBFrame &frame); 93 94 void 95 StepInstruction(bool step_over); 96 97 SBError 98 StepOverUntil (lldb::SBFrame &frame, 99 lldb::SBFileSpec &file_spec, 100 uint32_t line); 101 102 void 103 RunToAddress (lldb::addr_t addr); 104 105 //-------------------------------------------------------------------------- 106 /// LLDB currently supports process centric debugging which means when any 107 /// thread in a process stops, all other threads are stopped. The Suspend() 108 /// call here tells our process to suspend a thread and not let it run when 109 /// the other threads in a process are allowed to run. So when 110 /// SBProcess::Continue() is called, any threads that aren't suspended will 111 /// be allowed to run. If any of the SBThread functions for stepping are 112 /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the 113 /// thread will now be allowed to run and these funtions will simply return. 114 /// 115 /// Eventually we plan to add support for thread centric debugging where 116 /// each thread is controlled individually and each thread would broadcast 117 /// its state, but we haven't implemented this yet. 118 /// 119 /// Likewise the SBThread::Resume() call will again allow the thread to run 120 /// when the process is continued. 121 /// 122 /// Suspend() and Resume() functions are not currently reference counted, if 123 /// anyone has the need for them to be reference counted, please let us 124 /// know. 125 //-------------------------------------------------------------------------- 126 bool 127 Suspend(); 128 129 bool 130 Resume (); 131 132 bool 133 IsSuspended(); 134 135 uint32_t 136 GetNumFrames (); 137 138 lldb::SBFrame 139 GetFrameAtIndex (uint32_t idx); 140 141 lldb::SBFrame 142 GetSelectedFrame (); 143 144 lldb::SBFrame 145 SetSelectedFrame (uint32_t frame_idx); 146 147 lldb::SBProcess 148 GetProcess (); 149 150#ifndef SWIG 151 152 const lldb::SBThread & 153 operator = (const lldb::SBThread &rhs); 154 155 bool 156 operator == (const lldb::SBThread &rhs) const; 157 158 bool 159 operator != (const lldb::SBThread &rhs) const; 160 161#endif 162 163 bool 164 GetDescription (lldb::SBStream &description) const; 165 166protected: 167 friend class SBBreakpoint; 168 friend class SBBreakpointLocation; 169 friend class SBFrame; 170 friend class SBProcess; 171 friend class SBDebugger; 172 friend class SBValue; 173 174 SBThread (const lldb::ThreadSP& lldb_object_sp); 175 176 void 177 SetThread (const lldb::ThreadSP& lldb_object_sp); 178 179private: 180 //------------------------------------------------------------------ 181 // Classes that inherit from Thread can see and modify these 182 //------------------------------------------------------------------ 183 184 lldb::ThreadWP m_opaque_wp; 185}; 186 187} // namespace lldb 188 189#endif // LLDB_SBThread_h_ 190