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