SBThread.h revision a894fe78bc15344a0025c1154e414c554ab31dd9
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 const lldb::SBThread & 151 operator = (const lldb::SBThread &rhs); 152 153 bool 154 operator == (const lldb::SBThread &rhs) const; 155 156 bool 157 operator != (const lldb::SBThread &rhs) const; 158 159 bool 160 GetDescription (lldb::SBStream &description) const; 161 162protected: 163 friend class SBBreakpoint; 164 friend class SBBreakpointLocation; 165 friend class SBFrame; 166 friend class SBProcess; 167 friend class SBDebugger; 168 friend class SBValue; 169 170 SBThread (const lldb::ThreadSP& lldb_object_sp); 171 172 void 173 SetThread (const lldb::ThreadSP& lldb_object_sp); 174 175private: 176 lldb::ExecutionContextRefSP m_opaque_sp; 177}; 178 179} // namespace lldb 180 181#endif // LLDB_SBThread_h_ 182