]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/API/SBProcess.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / include / lldb / API / SBProcess.h
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 "lldb/API/SBQueue.h"
17 #include <stdio.h>
18
19 namespace lldb {
20
21 class SBEvent;
22
23 class SBProcess
24 {
25 public:
26     //------------------------------------------------------------------
27     /// Broadcaster event bits definitions.
28     //------------------------------------------------------------------
29     enum
30     {
31         eBroadcastBitStateChanged   = (1 << 0),
32         eBroadcastBitInterrupt      = (1 << 1),
33         eBroadcastBitSTDOUT         = (1 << 2),
34         eBroadcastBitSTDERR         = (1 << 3),
35         eBroadcastBitProfileData    = (1 << 4)
36     };
37
38     SBProcess ();
39
40     SBProcess (const lldb::SBProcess& rhs);
41
42     const lldb::SBProcess&
43     operator = (const lldb::SBProcess& rhs);
44
45     SBProcess (const lldb::ProcessSP &process_sp);
46     
47     ~SBProcess();
48
49     static const char *
50     GetBroadcasterClassName ();
51     
52     const char *
53     GetPluginName ();
54     
55     // DEPRECATED: use GetPluginName()
56     const char *
57     GetShortPluginName ();
58     
59     void
60     Clear ();
61
62     bool
63     IsValid() const;
64
65     lldb::SBTarget
66     GetTarget() const;
67
68     lldb::ByteOrder
69     GetByteOrder() const;
70
71     size_t
72     PutSTDIN (const char *src, size_t src_len);
73
74     size_t
75     GetSTDOUT (char *dst, size_t dst_len) const;
76
77     size_t
78     GetSTDERR (char *dst, size_t dst_len) const;
79
80     size_t
81     GetAsyncProfileData(char *dst, size_t dst_len) const;
82     
83     void
84     ReportEventState (const lldb::SBEvent &event, FILE *out) const;
85
86     void
87     AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
88
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     //------------------------------------------------------------------
94     bool
95     RemoteAttachToProcessWithID (lldb::pid_t pid,
96                                  lldb::SBError& error);
97     
98     bool
99     RemoteLaunch (char const **argv,
100                   char const **envp,
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,
106                   bool stop_at_entry,
107                   lldb::SBError& error);
108     
109     //------------------------------------------------------------------
110     // Thread related functions
111     //------------------------------------------------------------------
112     uint32_t
113     GetNumThreads ();
114
115     lldb::SBThread
116     GetThreadAtIndex (size_t index);
117
118     lldb::SBThread
119     GetThreadByID (lldb::tid_t sb_thread_id);
120
121     lldb::SBThread
122     GetThreadByIndexID (uint32_t index_id);
123
124     lldb::SBThread
125     GetSelectedThread () const;
126
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     //------------------------------------------------------------------
133     lldb::SBThread
134     CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context);
135
136     bool
137     SetSelectedThread (const lldb::SBThread &thread);
138
139     bool
140     SetSelectedThreadByID (lldb::tid_t tid);
141     
142     bool
143     SetSelectedThreadByIndexID (uint32_t index_id);
144
145     //------------------------------------------------------------------
146     // Queue related functions
147     //------------------------------------------------------------------
148     uint32_t
149     GetNumQueues ();
150
151     lldb::SBQueue
152     GetQueueAtIndex (size_t index);
153
154     //------------------------------------------------------------------
155     // Stepping related functions
156     //------------------------------------------------------------------
157
158     lldb::StateType
159     GetState ();
160
161     int
162     GetExitStatus ();
163
164     const char *
165     GetExitDescription ();
166
167     //------------------------------------------------------------------
168     /// Gets the process ID
169     ///
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
173     /// process.
174     ///
175     /// @return
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
179     ///     valid.
180     //------------------------------------------------------------------
181     lldb::pid_t
182     GetProcessID ();
183
184     //------------------------------------------------------------------
185     /// Gets the unique ID associated with this process object
186     ///
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.
191     ///
192     /// @return
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     //------------------------------------------------------------------
197     uint32_t
198     GetUniqueID();
199
200     uint32_t
201     GetAddressByteSize() const;
202
203     lldb::SBError
204     Destroy ();
205
206     lldb::SBError
207     Continue ();
208
209     lldb::SBError
210     Stop ();
211
212     lldb::SBError
213     Kill ();
214
215     lldb::SBError
216     Detach ();
217
218     lldb::SBError
219     Detach (bool keep_stopped);
220
221     lldb::SBError
222     Signal (int signal);
223
224     void
225     SendAsyncInterrupt();
226     
227     uint32_t
228     GetStopID(bool include_expression_stops = false);
229     
230     size_t
231     ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
232
233     size_t
234     WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
235
236     size_t
237     ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
238
239     uint64_t
240     ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
241
242     lldb::addr_t
243     ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
244
245     // Events
246     static lldb::StateType
247     GetStateFromEvent (const lldb::SBEvent &event);
248
249     static bool
250     GetRestartedFromEvent (const lldb::SBEvent &event);
251     
252     static size_t
253     GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event);
254     
255     static const char *
256     GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx);
257
258     static lldb::SBProcess
259     GetProcessFromEvent (const lldb::SBEvent &event);
260     
261     static bool
262     EventIsProcessEvent (const lldb::SBEvent &event);
263
264     lldb::SBBroadcaster
265     GetBroadcaster () const;
266
267     static const char *
268     GetBroadcasterClass ();
269
270     bool
271     GetDescription (lldb::SBStream &description);
272
273     uint32_t
274     GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
275
276     uint32_t
277     LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
278     
279     lldb::SBError
280     UnloadImage (uint32_t image_token);
281     
282     //------------------------------------------------------------------
283     /// Return the number of different thread-origin extended backtraces
284     /// this process can support.
285     ///
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 
289     /// queue).
290     ///
291     /// @return
292     ///   The number of thread-origin extended backtrace types that may be
293     ///   available.
294     //------------------------------------------------------------------
295     uint32_t
296     GetNumExtendedBacktraceTypes ();
297
298     //------------------------------------------------------------------
299     /// Return the name of one of the thread-origin extended backtrace 
300     /// methods.
301     ///
302     /// @param [in] idx
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.
307     ///
308     /// @return
309     ///   The name at that index.
310     //------------------------------------------------------------------
311     const char *
312     GetExtendedBacktraceTypeAtIndex (uint32_t idx);
313
314 protected:
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;
326
327     lldb::ProcessSP
328     GetSP() const;
329     
330     void
331     SetSP (const lldb::ProcessSP &process_sp);
332
333     lldb::ProcessWP m_opaque_wp;
334 };
335
336 }  // namespace lldb
337
338 #endif  // LLDB_SBProcess_h_