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