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