blob: 531cd5903cf2c2cbd0f32059a09886ccf61ed142 [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
67 size_t
68 PutSTDIN (const char *src, size_t src_len);
69
Johnny Chen609b9ce2011-11-28 19:12:25 +000070 %feature("autodoc", "
71 Reads data from the current process's stdout stream. API client specifies
72 the size of the buffer to read data into. It returns the byte buffer in a
73 Python string.
74 ") GetSTDOUT;
Johnny Chenc3fba812011-07-18 20:13:38 +000075 size_t
76 GetSTDOUT (char *dst, size_t dst_len) const;
77
Johnny Chen609b9ce2011-11-28 19:12:25 +000078 %feature("autodoc", "
79 Reads data from the current process's stderr stream. API client specifies
80 the size of the buffer to read data into. It returns the byte buffer in a
81 Python string.
82 ") GetSTDERR;
Johnny Chenc3fba812011-07-18 20:13:38 +000083 size_t
84 GetSTDERR (char *dst, size_t dst_len) const;
85
86 void
87 ReportEventState (const lldb::SBEvent &event, FILE *out) const;
88
89 void
90 AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
91
92 %feature("docstring", "
93 //------------------------------------------------------------------
94 /// Remote connection related functions. These will fail if the
95 /// process is not in eStateConnected. They are intended for use
96 /// when connecting to an externally managed debugserver instance.
97 //------------------------------------------------------------------
98 ") RemoteAttachToProcessWithID;
99 bool
100 RemoteAttachToProcessWithID (lldb::pid_t pid,
101 lldb::SBError& error);
102
103 %feature("docstring",
104 "See SBTarget.Launch for argument description and usage."
105 ) RemoteLaunch;
106 bool
107 RemoteLaunch (char const **argv,
108 char const **envp,
109 const char *stdin_path,
110 const char *stdout_path,
111 const char *stderr_path,
112 const char *working_directory,
113 uint32_t launch_flags,
114 bool stop_at_entry,
115 lldb::SBError& error);
116
117 //------------------------------------------------------------------
118 // Thread related functions
119 //------------------------------------------------------------------
120 uint32_t
121 GetNumThreads ();
122
123 lldb::SBThread
124 GetThreadAtIndex (size_t index);
125
126 lldb::SBThread
127 GetThreadByID (lldb::tid_t sb_thread_id);
128
129 lldb::SBThread
130 GetSelectedThread () const;
131
132 bool
133 SetSelectedThread (const lldb::SBThread &thread);
134
135 bool
136 SetSelectedThreadByID (uint32_t tid);
137
138 //------------------------------------------------------------------
139 // Stepping related functions
140 //------------------------------------------------------------------
141
142 lldb::StateType
143 GetState ();
144
145 int
146 GetExitStatus ();
147
148 const char *
149 GetExitDescription ();
150
151 lldb::pid_t
152 GetProcessID ();
153
154 uint32_t
155 GetAddressByteSize() const;
156
157 %feature("docstring", "
158 Kills the process and shuts down all threads that were spawned to
159 track and monitor process.
160 ") Destroy;
161 lldb::SBError
162 Destroy ();
163
164 lldb::SBError
165 Continue ();
166
167 lldb::SBError
168 Stop ();
169
170 %feature("docstring", "Same as Destroy(self).") Destroy;
171 lldb::SBError
172 Kill ();
173
174 lldb::SBError
175 Detach ();
176
177 %feature("docstring", "Sends the process a unix signal.") Signal;
178 lldb::SBError
179 Signal (int signal);
180
181 %feature("autodoc", "
182 Reads memory from the current process's address space and removes any
183 traps that may have been inserted into the memory. It returns the byte
184 buffer in a Python string. Example:
185
186 # Read 4 bytes from address 'addr' and assume error.Success() is True.
187 content = process.ReadMemory(addr, 4, error)
188 # Use 'ascii' encoding as each byte of 'content' is within [0..255].
189 new_bytes = bytearray(content, 'ascii')
190 ") ReadMemory;
191 size_t
192 ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
193
194 %feature("autodoc", "
195 Writes memory to the current process's address space and maintains any
196 traps that might be present due to software breakpoints. Example:
197
198 # Create a Python string from the byte array.
199 new_value = str(bytes)
200 result = process.WriteMemory(addr, new_value, error)
201 if not error.Success() or result != len(bytes):
202 print 'SBProcess.WriteMemory() failed!'
203 ") WriteMemory;
204 size_t
205 WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
206
207 // Events
208 static lldb::StateType
209 GetStateFromEvent (const lldb::SBEvent &event);
210
211 static bool
212 GetRestartedFromEvent (const lldb::SBEvent &event);
213
214 static lldb::SBProcess
215 GetProcessFromEvent (const lldb::SBEvent &event);
216
217 lldb::SBBroadcaster
218 GetBroadcaster () const;
219
220 bool
221 GetDescription (lldb::SBStream &description);
222
223 uint32_t
224 LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
225
226 lldb::SBError
227 UnloadImage (uint32_t image_token);
228};
229
230} // namespace lldb