blob: 649d39773aaabb04457881f638a89f511ec54ed9 [file] [log] [blame]
Johnny Chenebd63b22011-07-16 21:15:39 +00001//===-- SWIG Interface for SBTarget -----------------------------*- 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 target program running under the debugger.
14
15SBTarget supports module and breakpoint iterations. For example,
16
17 for m in target.module_iter():
18 print m
19
20produces:
21
22(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
23(x86_64) /usr/lib/dyld
24(x86_64) /usr/lib/libstdc++.6.dylib
25(x86_64) /usr/lib/libSystem.B.dylib
26(x86_64) /usr/lib/system/libmathCommon.A.dylib
27(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
28
29and,
30
31 for b in target.breakpoint_iter():
32 print b
33
34produces:
35
36SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
37SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
38"
39 ) SBTarget;
40class SBTarget
41{
Johnny Chenebd63b22011-07-16 21:15:39 +000042public:
43 //------------------------------------------------------------------
44 // Broadcaster bits.
45 //------------------------------------------------------------------
46 enum
47 {
48 eBroadcastBitBreakpointChanged = (1 << 0),
49 eBroadcastBitModulesLoaded = (1 << 1),
50 eBroadcastBitModulesUnloaded = (1 << 2)
51 };
52
53 //------------------------------------------------------------------
54 // Constructors
55 //------------------------------------------------------------------
56 SBTarget ();
57
58 SBTarget (const lldb::SBTarget& rhs);
59
Johnny Chenebd63b22011-07-16 21:15:39 +000060 //------------------------------------------------------------------
61 // Destructor
62 //------------------------------------------------------------------
63 ~SBTarget();
64
65 bool
66 IsValid() const;
67
68 lldb::SBProcess
69 GetProcess ();
70
71 %feature("docstring", "
72 //------------------------------------------------------------------
73 /// Launch a new process.
74 ///
75 /// Launch a new process by spawning a new process using the
76 /// target object's executable module's file as the file to launch.
77 /// Arguments are given in \a argv, and the environment variables
78 /// are in \a envp. Standard input and output files can be
79 /// optionally re-directed to \a stdin_path, \a stdout_path, and
80 /// \a stderr_path.
81 ///
82 /// @param[in] listener
83 /// An optional listener that will receive all process events.
84 /// If \a listener is valid then \a listener will listen to all
85 /// process events. If not valid, then this target's debugger
86 /// (SBTarget::GetDebugger()) will listen to all process events.
87 ///
88 /// @param[in] argv
89 /// The argument array.
90 ///
91 /// @param[in] envp
92 /// The environment array.
93 ///
94 /// @param[in] launch_flags
95 /// Flags to modify the launch (@see lldb::LaunchFlags)
96 ///
97 /// @param[in] stdin_path
98 /// The path to use when re-directing the STDIN of the new
99 /// process. If all stdXX_path arguments are NULL, a pseudo
100 /// terminal will be used.
101 ///
102 /// @param[in] stdout_path
103 /// The path to use when re-directing the STDOUT of the new
104 /// process. If all stdXX_path arguments are NULL, a pseudo
105 /// terminal will be used.
106 ///
107 /// @param[in] stderr_path
108 /// The path to use when re-directing the STDERR of the new
109 /// process. If all stdXX_path arguments are NULL, a pseudo
110 /// terminal will be used.
111 ///
112 /// @param[in] working_directory
113 /// The working directory to have the child process run in
114 ///
115 /// @param[in] launch_flags
116 /// Some launch options specified by logical OR'ing
117 /// lldb::LaunchFlags enumeration values together.
118 ///
119 /// @param[in] stop_at_endtry
120 /// If false do not stop the inferior at the entry point.
121 ///
122 /// @param[out]
123 /// An error object. Contains the reason if there is some failure.
124 ///
125 /// @return
126 /// A process object for the newly created process.
127 //------------------------------------------------------------------
128
129 For example,
130
131 process = target.Launch(self.dbg.GetListener(), None, None,
132 None, '/tmp/stdout.txt', None,
133 None, 0, False, error)
134
135 launches a new process by passing nothing for both the args and the envs
136 and redirect the standard output of the inferior to the /tmp/stdout.txt
137 file. It does not specify a working directory so that the debug server
138 will use its idea of what the current working directory is for the
139 inferior. Also, we ask the debugger not to stop the inferior at the
140 entry point. If no breakpoint is specified for the inferior, it should
141 run to completion if no user interaction is required.
142 ") Launch;
143 lldb::SBProcess
144 Launch (SBListener &listener,
145 char const **argv,
146 char const **envp,
147 const char *stdin_path,
148 const char *stdout_path,
149 const char *stderr_path,
150 const char *working_directory,
151 uint32_t launch_flags, // See LaunchFlags
152 bool stop_at_entry,
153 lldb::SBError& error);
154
155 %feature("docstring", "
156 //------------------------------------------------------------------
157 /// Launch a new process with sensible defaults.
158 ///
159 /// @param[in] argv
160 /// The argument array.
161 ///
162 /// @param[in] envp
163 /// The environment array.
164 ///
165 /// @param[in] working_directory
166 /// The working directory to have the child process run in
167 ///
168 /// Default: listener
169 /// Set to the target's debugger (SBTarget::GetDebugger())
170 ///
171 /// Default: launch_flags
172 /// Empty launch flags
173 ///
174 /// Default: stdin_path
175 /// Default: stdout_path
176 /// Default: stderr_path
177 /// A pseudo terminal will be used.
178 ///
179 /// @return
180 /// A process object for the newly created process.
181 //------------------------------------------------------------------
182
183 For example,
184
185 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
186
187 launches a new process by passing 'X', 'Y', 'Z' as the args to the
188 executable.
189 ") LaunchSimple;
190 lldb::SBProcess
191 LaunchSimple (const char **argv,
192 const char **envp,
193 const char *working_directory);
194
195 %feature("docstring", "
196 //------------------------------------------------------------------
197 /// Attach to process with pid.
198 ///
199 /// @param[in] listener
200 /// An optional listener that will receive all process events.
201 /// If \a listener is valid then \a listener will listen to all
202 /// process events. If not valid, then this target's debugger
203 /// (SBTarget::GetDebugger()) will listen to all process events.
204 ///
205 /// @param[in] pid
206 /// The process ID to attach to.
207 ///
208 /// @param[out]
209 /// An error explaining what went wrong if attach fails.
210 ///
211 /// @return
212 /// A process object for the attached process.
213 //------------------------------------------------------------------
214 ") AttachToProcessWithID;
215 lldb::SBProcess
216 AttachToProcessWithID (SBListener &listener,
217 lldb::pid_t pid,
218 lldb::SBError& error);
219
220 %feature("docstring", "
221 //------------------------------------------------------------------
222 /// Attach to process with name.
223 ///
224 /// @param[in] listener
225 /// An optional listener that will receive all process events.
226 /// If \a listener is valid then \a listener will listen to all
227 /// process events. If not valid, then this target's debugger
228 /// (SBTarget::GetDebugger()) will listen to all process events.
229 ///
230 /// @param[in] name
231 /// Basename of process to attach to.
232 ///
233 /// @param[in] wait_for
234 /// If true wait for a new instance of 'name' to be launched.
235 ///
236 /// @param[out]
237 /// An error explaining what went wrong if attach fails.
238 ///
239 /// @return
240 /// A process object for the attached process.
241 //------------------------------------------------------------------
242 ") AttachToProcessWithName;
243 lldb::SBProcess
244 AttachToProcessWithName (SBListener &listener,
245 const char *name,
246 bool wait_for,
247 lldb::SBError& error);
248
249 %feature("docstring", "
250 //------------------------------------------------------------------
251 /// Connect to a remote debug server with url.
252 ///
253 /// @param[in] listener
254 /// An optional listener that will receive all process events.
255 /// If \a listener is valid then \a listener will listen to all
256 /// process events. If not valid, then this target's debugger
257 /// (SBTarget::GetDebugger()) will listen to all process events.
258 ///
259 /// @param[in] url
260 /// The url to connect to, e.g., 'connect://localhost:12345'.
261 ///
262 /// @param[in] plugin_name
263 /// The plugin name to be used; can be NULL.
264 ///
265 /// @param[out]
266 /// An error explaining what went wrong if the connect fails.
267 ///
268 /// @return
269 /// A process object for the connected process.
270 //------------------------------------------------------------------
271 ") ConnectRemote;
272 lldb::SBProcess
273 ConnectRemote (SBListener &listener,
274 const char *url,
275 const char *plugin_name,
276 SBError& error);
277
278 lldb::SBFileSpec
279 GetExecutable ();
280
281 uint32_t
282 GetNumModules () const;
283
284 lldb::SBModule
285 GetModuleAtIndex (uint32_t idx);
286
287 lldb::SBDebugger
288 GetDebugger() const;
289
290 lldb::SBModule
291 FindModule (const lldb::SBFileSpec &file_spec);
292
293 %feature("docstring", "
294 //------------------------------------------------------------------
295 /// Find functions by name.
296 ///
297 /// @param[in] name
298 /// The name of the function we are looking for.
299 ///
300 /// @param[in] name_type_mask
301 /// A logical OR of one or more FunctionNameType enum bits that
302 /// indicate what kind of names should be used when doing the
303 /// lookup. Bits include fully qualified names, base names,
304 /// C++ methods, or ObjC selectors.
305 /// See FunctionNameType for more details.
306 ///
307 /// @param[in] append
308 /// If true, any matches will be appended to \a sc_list, else
309 /// matches replace the contents of \a sc_list.
310 ///
311 /// @param[out] sc_list
312 /// A symbol context list that gets filled in with all of the
313 /// matches.
314 ///
315 /// @return
316 /// The number of matches added to \a sc_list.
317 //------------------------------------------------------------------
318 ") FindFunctions;
319 uint32_t
320 FindFunctions (const char *name,
321 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
322 bool append,
323 lldb::SBSymbolContextList& sc_list);
324
325 %feature("docstring", "
326 //------------------------------------------------------------------
327 /// Find global and static variables by name.
328 ///
329 /// @param[in] name
330 /// The name of the global or static variable we are looking
331 /// for.
332 ///
333 /// @param[in] max_matches
334 /// Allow the number of matches to be limited to \a max_matches.
335 ///
336 /// @return
337 /// A list of matched variables in an SBValueList.
338 //------------------------------------------------------------------
339 ") FindGlobalVariables;
340 lldb::SBValueList
341 FindGlobalVariables (const char *name,
342 uint32_t max_matches);
343
344 void
345 Clear ();
346
347 bool
348 ResolveLoadAddress (lldb::addr_t vm_addr,
349 lldb::SBAddress& addr);
350
351 SBSymbolContext
352 ResolveSymbolContextForAddress (const SBAddress& addr,
353 uint32_t resolve_scope);
354
355 lldb::SBBreakpoint
356 BreakpointCreateByLocation (const char *file, uint32_t line);
357
358 lldb::SBBreakpoint
359 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
360
361 lldb::SBBreakpoint
362 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
363
364 lldb::SBBreakpoint
365 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
366
367 lldb::SBBreakpoint
368 BreakpointCreateByAddress (addr_t address);
369
370 uint32_t
371 GetNumBreakpoints () const;
372
373 lldb::SBBreakpoint
374 GetBreakpointAtIndex (uint32_t idx) const;
375
376 bool
377 BreakpointDelete (break_id_t break_id);
378
379 lldb::SBBreakpoint
380 FindBreakpointByID (break_id_t break_id);
381
382 bool
383 EnableAllBreakpoints ();
384
385 bool
386 DisableAllBreakpoints ();
387
388 bool
389 DeleteAllBreakpoints ();
390
391 lldb::SBBroadcaster
392 GetBroadcaster () const;
393
Johnny Chenebd63b22011-07-16 21:15:39 +0000394 bool
395 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level) const;
Johnny Chenebd63b22011-07-16 21:15:39 +0000396};
397
398} // namespace lldb