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"
23 class LLDB_API SBProcess
26 //------------------------------------------------------------------
27 /// Broadcaster event bits definitions.
28 //------------------------------------------------------------------
29 FLAGS_ANONYMOUS_ENUM()
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);
228 SendAsyncInterrupt();
231 GetStopID(bool include_expression_stops = false);
233 //------------------------------------------------------------------
234 /// Gets the stop event corresponding to stop ID.
236 /// Note that it wasn't fully implemented and tracks only the stop
237 /// event for the last natural stop ID.
239 /// @param [in] stop_id
240 /// The ID of the stop event to return.
243 /// The stop event corresponding to stop ID.
244 //------------------------------------------------------------------
246 GetStopEventForStopID(uint32_t stop_id);
249 ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
252 WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
255 ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
258 ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
261 ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
264 static lldb::StateType
265 GetStateFromEvent (const lldb::SBEvent &event);
268 GetRestartedFromEvent (const lldb::SBEvent &event);
271 GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event);
274 GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx);
276 static lldb::SBProcess
277 GetProcessFromEvent (const lldb::SBEvent &event);
280 GetInterruptedFromEvent (const lldb::SBEvent &event);
283 EventIsProcessEvent (const lldb::SBEvent &event);
286 GetBroadcaster () const;
289 GetBroadcasterClass ();
292 GetDescription (lldb::SBStream &description);
295 GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
297 //------------------------------------------------------------------
298 /// Load a shared library into this process.
300 /// @param[in] remote_image_spec
301 /// The path for the shared library on the target what you want
304 /// @param[out] error
305 /// An error object that gets filled in with any errors that
306 /// might occur when trying to load the shared library.
309 /// A token that represents the shared library that can be
310 /// later used to unload the shared library. A value of
311 /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
312 /// library can't be opened.
313 //------------------------------------------------------------------
315 LoadImage (lldb::SBFileSpec &remote_image_spec, lldb::SBError &error);
317 //------------------------------------------------------------------
318 /// Load a shared library into this process.
320 /// @param[in] local_image_spec
321 /// The file spec that points to the shared library that you
322 /// want to load if the library is located on the host. The
323 /// library will be copied over to the location specified by
324 /// remote_image_spec or into the current working directory with
325 /// the same filename if the remote_image_spec isn't specified.
327 /// @param[in] remote_image_spec
328 /// If local_image_spec is specified then the location where the
329 /// library should be copied over from the host. If
330 /// local_image_spec isn't specified, then the path for the
331 /// shared library on the target what you want to load.
333 /// @param[out] error
334 /// An error object that gets filled in with any errors that
335 /// might occur when trying to load the shared library.
338 /// A token that represents the shared library that can be
339 /// later used to unload the shared library. A value of
340 /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
341 /// library can't be opened.
342 //------------------------------------------------------------------
344 LoadImage (const lldb::SBFileSpec &local_image_spec,
345 const lldb::SBFileSpec &remote_image_spec,
346 lldb::SBError &error);
349 UnloadImage (uint32_t image_token);
352 SendEventData (const char *data);
354 //------------------------------------------------------------------
355 /// Return the number of different thread-origin extended backtraces
356 /// this process can support.
358 /// When the process is stopped and you have an SBThread, lldb may be
359 /// able to show a backtrace of when that thread was originally created,
360 /// or the work item was enqueued to it (in the case of a libdispatch
364 /// The number of thread-origin extended backtrace types that may be
366 //------------------------------------------------------------------
368 GetNumExtendedBacktraceTypes ();
370 //------------------------------------------------------------------
371 /// Return the name of one of the thread-origin extended backtrace
375 /// The index of the name to return. They will be returned in
376 /// the order that the user will most likely want to see them.
377 /// e.g. if the type at index 0 is not available for a thread,
378 /// see if the type at index 1 provides an extended backtrace.
381 /// The name at that index.
382 //------------------------------------------------------------------
384 GetExtendedBacktraceTypeAtIndex (uint32_t idx);
386 lldb::SBThreadCollection
387 GetHistoryThreads (addr_t addr);
390 IsInstrumentationRuntimePresent(InstrumentationRuntimeType type);
392 // Save the state of the process in a core file (or mini dump on Windows).
394 SaveCore(const char *file_name);
397 friend class SBAddress;
398 friend class SBBreakpoint;
399 friend class SBBreakpointLocation;
400 friend class SBCommandInterpreter;
401 friend class SBDebugger;
402 friend class SBExecutionContext;
403 friend class SBFunction;
404 friend class SBModule;
405 friend class SBTarget;
406 friend class SBThread;
407 friend class SBValue;
408 friend class lldb_private::QueueImpl;
414 SetSP (const lldb::ProcessSP &process_sp);
416 lldb::ProcessWP m_opaque_wp;
421 #endif // LLDB_SBProcess_h_