SBProcess.h revision efbdd2280873cc87634bf4f4a37ab8b99662522a
1//===-- SBProcess.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_SBProcess_h_ 11#define LLDB_SBProcess_h_ 12 13#include "lldb/API/SBDefines.h" 14#include "lldb/API/SBError.h" 15#include "lldb/API/SBTarget.h" 16#include <stdio.h> 17 18namespace lldb { 19 20class SBEvent; 21 22class SBProcess 23{ 24public: 25 //------------------------------------------------------------------ 26 /// Broadcaster event bits definitions. 27 //------------------------------------------------------------------ 28 enum 29 { 30 eBroadcastBitStateChanged = (1 << 0), 31 eBroadcastBitInterrupt = (1 << 1), 32 eBroadcastBitSTDOUT = (1 << 2), 33 eBroadcastBitSTDERR = (1 << 3) 34 }; 35 36 SBProcess (); 37 38 SBProcess (const lldb::SBProcess& rhs); 39 40 const lldb::SBProcess& 41 operator = (const lldb::SBProcess& rhs); 42 43 ~SBProcess(); 44 45 static const char * 46 GetBroadcasterClassName (); 47 48 void 49 Clear (); 50 51 bool 52 IsValid() const; 53 54 lldb::SBTarget 55 GetTarget() const; 56 57 lldb::ByteOrder 58 GetByteOrder() const; 59 60 size_t 61 PutSTDIN (const char *src, size_t src_len); 62 63 size_t 64 GetSTDOUT (char *dst, size_t dst_len) const; 65 66 size_t 67 GetSTDERR (char *dst, size_t dst_len) const; 68 69 void 70 ReportEventState (const lldb::SBEvent &event, FILE *out) const; 71 72 void 73 AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); 74 75 //------------------------------------------------------------------ 76 /// Remote connection related functions. These will fail if the 77 /// process is not in eStateConnected. They are intended for use 78 /// when connecting to an externally managed debugserver instance. 79 //------------------------------------------------------------------ 80 bool 81 RemoteAttachToProcessWithID (lldb::pid_t pid, 82 lldb::SBError& error); 83 84 bool 85 RemoteLaunch (char const **argv, 86 char const **envp, 87 const char *stdin_path, 88 const char *stdout_path, 89 const char *stderr_path, 90 const char *working_directory, 91 uint32_t launch_flags, 92 bool stop_at_entry, 93 lldb::SBError& error); 94 95 //------------------------------------------------------------------ 96 // Thread related functions 97 //------------------------------------------------------------------ 98 uint32_t 99 GetNumThreads (); 100 101 lldb::SBThread 102 GetThreadAtIndex (size_t index); 103 104 lldb::SBThread 105 GetThreadByID (lldb::tid_t sb_thread_id); 106 107 lldb::SBThread 108 GetThreadByIndexID (uint32_t index_id); 109 110 lldb::SBThread 111 GetSelectedThread () const; 112 113 bool 114 SetSelectedThread (const lldb::SBThread &thread); 115 116 bool 117 SetSelectedThreadByID (uint32_t tid); 118 119 bool 120 SetSelectedThreadByIndexID (uint32_t index_id); 121 122 //------------------------------------------------------------------ 123 // Stepping related functions 124 //------------------------------------------------------------------ 125 126 lldb::StateType 127 GetState (); 128 129 int 130 GetExitStatus (); 131 132 const char * 133 GetExitDescription (); 134 135 lldb::pid_t 136 GetProcessID (); 137 138 uint32_t 139 GetAddressByteSize() const; 140 141 lldb::SBError 142 Destroy (); 143 144 lldb::SBError 145 Continue (); 146 147 lldb::SBError 148 Stop (); 149 150 lldb::SBError 151 Kill (); 152 153 lldb::SBError 154 Detach (); 155 156 lldb::SBError 157 Signal (int signal); 158 159 size_t 160 ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); 161 162 size_t 163 WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); 164 165 size_t 166 ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); 167 168 uint64_t 169 ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); 170 171 lldb::addr_t 172 ReadPointerFromMemory (addr_t addr, lldb::SBError &error); 173 174 // Events 175 static lldb::StateType 176 GetStateFromEvent (const lldb::SBEvent &event); 177 178 static bool 179 GetRestartedFromEvent (const lldb::SBEvent &event); 180 181 static lldb::SBProcess 182 GetProcessFromEvent (const lldb::SBEvent &event); 183 184 static bool 185 EventIsProcessEvent (const lldb::SBEvent &event); 186 187 lldb::SBBroadcaster 188 GetBroadcaster () const; 189 190 static const char * 191 GetBroadcasterClass (); 192 193 bool 194 GetDescription (lldb::SBStream &description); 195 196 uint32_t 197 GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; 198 199 uint32_t 200 LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); 201 202 lldb::SBError 203 UnloadImage (uint32_t image_token); 204 205protected: 206 friend class SBAddress; 207 friend class SBBreakpoint; 208 friend class SBBreakpointLocation; 209 friend class SBCommandInterpreter; 210 friend class SBDebugger; 211 friend class SBFunction; 212 friend class SBModule; 213 friend class SBTarget; 214 friend class SBThread; 215 friend class SBValue; 216 217 SBProcess (const lldb::ProcessSP &process_sp); 218 219 lldb::ProcessSP 220 GetSP() const; 221 222 void 223 SetSP (const lldb::ProcessSP &process_sp); 224 225 lldb::ProcessWP m_opaque_wp; 226}; 227 228} // namespace lldb 229 230#endif // LLDB_SBProcess_h_ 231