1 //===-- SBProcess.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBProcess_h_
11 #define LLDB_SBProcess_h_
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBError.h"
15 #include "lldb/API/SBTarget.h"
16 #include "lldb/API/SBQueue.h"
26 //------------------------------------------------------------------
27 /// Broadcaster event bits definitions.
28 //------------------------------------------------------------------
31 eBroadcastBitStateChanged = (1 << 0),
32 eBroadcastBitInterrupt = (1 << 1),
33 eBroadcastBitSTDOUT = (1 << 2),
34 eBroadcastBitSTDERR = (1 << 3),
35 eBroadcastBitProfileData = (1 << 4)
40 SBProcess (const lldb::SBProcess& rhs);
42 const lldb::SBProcess&
43 operator = (const lldb::SBProcess& rhs);
45 SBProcess (const lldb::ProcessSP &process_sp);
50 GetBroadcasterClassName ();
55 // DEPRECATED: use GetPluginName()
57 GetShortPluginName ();
72 PutSTDIN (const char *src, size_t src_len);
75 GetSTDOUT (char *dst, size_t dst_len) const;
78 GetSTDERR (char *dst, size_t dst_len) const;
81 GetAsyncProfileData(char *dst, size_t dst_len) const;
84 ReportEventState (const lldb::SBEvent &event, FILE *out) const;
87 AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
89 //------------------------------------------------------------------
90 /// Remote connection related functions. These will fail if the
91 /// process is not in eStateConnected. They are intended for use
92 /// when connecting to an externally managed debugserver instance.
93 //------------------------------------------------------------------
95 RemoteAttachToProcessWithID (lldb::pid_t pid,
96 lldb::SBError& error);
99 RemoteLaunch (char const **argv,
101 const char *stdin_path,
102 const char *stdout_path,
103 const char *stderr_path,
104 const char *working_directory,
105 uint32_t launch_flags,
107 lldb::SBError& error);
109 //------------------------------------------------------------------
110 // Thread related functions
111 //------------------------------------------------------------------
116 GetThreadAtIndex (size_t index);
119 GetThreadByID (lldb::tid_t sb_thread_id);
122 GetThreadByIndexID (uint32_t index_id);
125 GetSelectedThread () const;
127 //------------------------------------------------------------------
128 // Function for lazily creating a thread using the current OS
129 // plug-in. This function will be removed in the future when there
130 // are APIs to create SBThread objects through the interface and add
131 // them to the process through the SBProcess API.
132 //------------------------------------------------------------------
134 CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context);
137 SetSelectedThread (const lldb::SBThread &thread);
140 SetSelectedThreadByID (lldb::tid_t tid);
143 SetSelectedThreadByIndexID (uint32_t index_id);
145 //------------------------------------------------------------------
146 // Queue related functions
147 //------------------------------------------------------------------
152 GetQueueAtIndex (size_t index);
154 //------------------------------------------------------------------
155 // Stepping related functions
156 //------------------------------------------------------------------
165 GetExitDescription ();
167 //------------------------------------------------------------------
168 /// Gets the process ID
170 /// Returns the process identifier for the process as it is known
171 /// on the system on which the process is running. For unix systems
172 /// this is typically the same as if you called "getpid()" in the
176 /// Returns LLDB_INVALID_PROCESS_ID if this object does not
177 /// contain a valid process object, or if the process has not
178 /// been launched. Returns a valid process ID if the process is
180 //------------------------------------------------------------------
184 //------------------------------------------------------------------
185 /// Gets the unique ID associated with this process object
187 /// Unique IDs start at 1 and increment up with each new process
188 /// instance. Since starting a process on a system might always
189 /// create a process with the same process ID, there needs to be a
190 /// way to tell two process instances apart.
193 /// Returns a non-zero integer ID if this object contains a
194 /// valid process object, zero if this object does not contain
195 /// a valid process object.
196 //------------------------------------------------------------------
201 GetAddressByteSize() const;
219 Detach (bool keep_stopped);
225 SendAsyncInterrupt();
228 GetStopID(bool include_expression_stops = false);
231 ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
234 WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
237 ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
240 ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
243 ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
246 static lldb::StateType
247 GetStateFromEvent (const lldb::SBEvent &event);
250 GetRestartedFromEvent (const lldb::SBEvent &event);
253 GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event);
256 GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx);
258 static lldb::SBProcess
259 GetProcessFromEvent (const lldb::SBEvent &event);
262 EventIsProcessEvent (const lldb::SBEvent &event);
265 GetBroadcaster () const;
268 GetBroadcasterClass ();
271 GetDescription (lldb::SBStream &description);
274 GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
277 LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
280 UnloadImage (uint32_t image_token);
282 //------------------------------------------------------------------
283 /// Return the number of different thread-origin extended backtraces
284 /// this process can support.
286 /// When the process is stopped and you have an SBThread, lldb may be
287 /// able to show a backtrace of when that thread was originally created,
288 /// or the work item was enqueued to it (in the case of a libdispatch
292 /// The number of thread-origin extended backtrace types that may be
294 //------------------------------------------------------------------
296 GetNumExtendedBacktraceTypes ();
298 //------------------------------------------------------------------
299 /// Return the name of one of the thread-origin extended backtrace
303 /// The index of the name to return. They will be returned in
304 /// the order that the user will most likely want to see them.
305 /// e.g. if the type at index 0 is not available for a thread,
306 /// see if the type at index 1 provides an extended backtrace.
309 /// The name at that index.
310 //------------------------------------------------------------------
312 GetExtendedBacktraceTypeAtIndex (uint32_t idx);
315 friend class SBAddress;
316 friend class SBBreakpoint;
317 friend class SBBreakpointLocation;
318 friend class SBCommandInterpreter;
319 friend class SBDebugger;
320 friend class SBFunction;
321 friend class SBModule;
322 friend class SBTarget;
323 friend class SBThread;
324 friend class SBValue;
325 friend class lldb_private::QueueImpl;
331 SetSP (const lldb::ProcessSP &process_sp);
333 lldb::ProcessWP m_opaque_wp;
338 #endif // LLDB_SBProcess_h_