blob: b2ab9231a264644b177f579aa31ed52ae37050c9 [file] [log] [blame]
Johnny Chenc3fba812011-07-18 20:13:38 +00001//===-- SWIG Interface for SBProcess ----------------------------*- 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
10namespace lldb {
11
12%feature("docstring",
13"Represents the process associated with the target program.
14
15SBProcess supports thread iteration. For example (from test/lldbutil.py),
16
17# ==================================================
18# Utility functions related to Threads and Processes
19# ==================================================
20
21def get_stopped_threads(process, reason):
22 '''Returns the thread(s) with the specified stop reason in a list.
23
24 The list can be empty if no such thread exists.
25 '''
26 threads = []
27 for t in process:
28 if t.GetStopReason() == reason:
29 threads.append(t)
30 return threads
31
32...
33"
34) SBProcess;
35class SBProcess
36{
37public:
38 //------------------------------------------------------------------
39 /// Broadcaster event bits definitions.
40 //------------------------------------------------------------------
41 enum
42 {
43 eBroadcastBitStateChanged = (1 << 0),
44 eBroadcastBitInterrupt = (1 << 1),
45 eBroadcastBitSTDOUT = (1 << 2),
46 eBroadcastBitSTDERR = (1 << 3)
47 };
48
49 SBProcess ();
50
51 SBProcess (const lldb::SBProcess& rhs);
52
53 ~SBProcess();
54
55 void
56 Clear ();
57
58 bool
59 IsValid() const;
60
61 lldb::SBTarget
62 GetTarget() const;
63
64 lldb::ByteOrder
65 GetByteOrder() const;
66
Johnny Chen23038b62011-11-28 21:39:07 +000067 %feature("autodoc", "
68 Writes data into the current process's stdin. API client specifies a Python
69 string as the only argument.
70 ") PutSTDIN;
Johnny Chenc3fba812011-07-18 20:13:38 +000071 size_t
72 PutSTDIN (const char *src, size_t src_len);
73
Johnny Chen609b9ce2011-11-28 19:12:25 +000074 %feature("autodoc", "
75 Reads data from the current process's stdout stream. API client specifies
76 the size of the buffer to read data into. It returns the byte buffer in a
77 Python string.
78 ") GetSTDOUT;
Johnny Chenc3fba812011-07-18 20:13:38 +000079 size_t
80 GetSTDOUT (char *dst, size_t dst_len) const;
81
Johnny Chen609b9ce2011-11-28 19:12:25 +000082 %feature("autodoc", "
83 Reads data from the current process's stderr stream. API client specifies
84 the size of the buffer to read data into. It returns the byte buffer in a
85 Python string.
86 ") GetSTDERR;
Johnny Chenc3fba812011-07-18 20:13:38 +000087 size_t
88 GetSTDERR (char *dst, size_t dst_len) const;
89
90 void
91 ReportEventState (const lldb::SBEvent &event, FILE *out) const;
92
93 void
94 AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
95
96 %feature("docstring", "
97 //------------------------------------------------------------------
98 /// Remote connection related functions. These will fail if the
99 /// process is not in eStateConnected. They are intended for use
100 /// when connecting to an externally managed debugserver instance.
101 //------------------------------------------------------------------
102 ") RemoteAttachToProcessWithID;
103 bool
104 RemoteAttachToProcessWithID (lldb::pid_t pid,
105 lldb::SBError& error);
106
107 %feature("docstring",
108 "See SBTarget.Launch for argument description and usage."
109 ) RemoteLaunch;
110 bool
111 RemoteLaunch (char const **argv,
112 char const **envp,
113 const char *stdin_path,
114 const char *stdout_path,
115 const char *stderr_path,
116 const char *working_directory,
117 uint32_t launch_flags,
118 bool stop_at_entry,
119 lldb::SBError& error);
120
121 //------------------------------------------------------------------
122 // Thread related functions
123 //------------------------------------------------------------------
124 uint32_t
125 GetNumThreads ();
126
127 lldb::SBThread
128 GetThreadAtIndex (size_t index);
129
130 lldb::SBThread
131 GetThreadByID (lldb::tid_t sb_thread_id);
132
133 lldb::SBThread
134 GetSelectedThread () const;
135
136 bool
137 SetSelectedThread (const lldb::SBThread &thread);
138
139 bool
140 SetSelectedThreadByID (uint32_t tid);
141
142 //------------------------------------------------------------------
143 // Stepping related functions
144 //------------------------------------------------------------------
145
146 lldb::StateType
147 GetState ();
148
149 int
150 GetExitStatus ();
151
152 const char *
153 GetExitDescription ();
154
155 lldb::pid_t
156 GetProcessID ();
157
158 uint32_t
159 GetAddressByteSize() const;
160
161 %feature("docstring", "
162 Kills the process and shuts down all threads that were spawned to
163 track and monitor process.
164 ") Destroy;
165 lldb::SBError
166 Destroy ();
167
168 lldb::SBError
169 Continue ();
170
171 lldb::SBError
172 Stop ();
173
174 %feature("docstring", "Same as Destroy(self).") Destroy;
175 lldb::SBError
176 Kill ();
177
178 lldb::SBError
179 Detach ();
180
181 %feature("docstring", "Sends the process a unix signal.") Signal;
182 lldb::SBError
183 Signal (int signal);
184
185 %feature("autodoc", "
186 Reads memory from the current process's address space and removes any
187 traps that may have been inserted into the memory. It returns the byte
188 buffer in a Python string. Example:
189
190 # Read 4 bytes from address 'addr' and assume error.Success() is True.
191 content = process.ReadMemory(addr, 4, error)
192 # Use 'ascii' encoding as each byte of 'content' is within [0..255].
193 new_bytes = bytearray(content, 'ascii')
194 ") ReadMemory;
195 size_t
196 ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
197
198 %feature("autodoc", "
199 Writes memory to the current process's address space and maintains any
200 traps that might be present due to software breakpoints. Example:
201
202 # Create a Python string from the byte array.
203 new_value = str(bytes)
204 result = process.WriteMemory(addr, new_value, error)
205 if not error.Success() or result != len(bytes):
206 print 'SBProcess.WriteMemory() failed!'
207 ") WriteMemory;
208 size_t
209 WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
210
211 // Events
212 static lldb::StateType
213 GetStateFromEvent (const lldb::SBEvent &event);
214
215 static bool
216 GetRestartedFromEvent (const lldb::SBEvent &event);
217
218 static lldb::SBProcess
219 GetProcessFromEvent (const lldb::SBEvent &event);
220
221 lldb::SBBroadcaster
222 GetBroadcaster () const;
223
224 bool
225 GetDescription (lldb::SBStream &description);
226
227 uint32_t
228 LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
229
230 lldb::SBError
231 UnloadImage (uint32_t image_token);
232};
233
234} // namespace lldb