SBThread.h revision f59388aa57559d7d074613d65b88abacfd699845
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 SBError 106 ReturnFromFrame (SBFrame &frame, SBValue &return_value); 107 108 //-------------------------------------------------------------------------- 109 /// LLDB currently supports process centric debugging which means when any 110 /// thread in a process stops, all other threads are stopped. The Suspend() 111 /// call here tells our process to suspend a thread and not let it run when 112 /// the other threads in a process are allowed to run. So when 113 /// SBProcess::Continue() is called, any threads that aren't suspended will 114 /// be allowed to run. If any of the SBThread functions for stepping are 115 /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the 116 /// thread will now be allowed to run and these funtions will simply return. 117 /// 118 /// Eventually we plan to add support for thread centric debugging where 119 /// each thread is controlled individually and each thread would broadcast 120 /// its state, but we haven't implemented this yet. 121 /// 122 /// Likewise the SBThread::Resume() call will again allow the thread to run 123 /// when the process is continued. 124 /// 125 /// Suspend() and Resume() functions are not currently reference counted, if 126 /// anyone has the need for them to be reference counted, please let us 127 /// know. 128 //-------------------------------------------------------------------------- 129 bool 130 Suspend(); 131 132 bool 133 Resume (); 134 135 bool 136 IsSuspended(); 137 138 uint32_t 139 GetNumFrames (); 140 141 lldb::SBFrame 142 GetFrameAtIndex (uint32_t idx); 143 144 lldb::SBFrame 145 GetSelectedFrame (); 146 147 lldb::SBFrame 148 SetSelectedFrame (uint32_t frame_idx); 149 150 lldb::SBProcess 151 GetProcess (); 152 153 const lldb::SBThread & 154 operator = (const lldb::SBThread &rhs); 155 156 bool 157 operator == (const lldb::SBThread &rhs) const; 158 159 bool 160 operator != (const lldb::SBThread &rhs) const; 161 162 bool 163 GetDescription (lldb::SBStream &description) const; 164 165protected: 166 friend class SBBreakpoint; 167 friend class SBBreakpointLocation; 168 friend class SBFrame; 169 friend class SBProcess; 170 friend class SBDebugger; 171 friend class SBValue; 172 173 SBThread (const lldb::ThreadSP& lldb_object_sp); 174 175 void 176 SetThread (const lldb::ThreadSP& lldb_object_sp); 177 178#ifndef SWIG 179 SBError 180 ResumeNewPlan (lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan); 181#endif 182 183private: 184 lldb::ExecutionContextRefSP m_opaque_sp; 185}; 186 187} // namespace lldb 188 189#endif // LLDB_SBThread_h_ 190