blob: 9685c94fcc129cc6bbd4548a349c7b7b11077fc5 [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
Greg Clayton0a8dcac2012-02-24 05:03:03 +000012class SBLaunchInfo
13{
Greg Clayton98ca1e62012-02-24 20:59:25 +000014public:
15 SBLaunchInfo (const char **argv);
Greg Clayton0a8dcac2012-02-24 05:03:03 +000016
17 uint32_t
18 GetUserID();
19
20 uint32_t
21 GetGroupID();
22
23 bool
24 UserIDIsValid ();
25
26 bool
27 GroupIDIsValid ();
28
29 void
30 SetUserID (uint32_t uid);
31
32 void
33 SetGroupID (uint32_t gid);
34
Greg Clayton0a8dcac2012-02-24 05:03:03 +000035 uint32_t
36 GetNumArguments ();
37
38 const char *
39 GetArgumentAtIndex (uint32_t idx);
40
41 void
42 SetArguments (const char **argv, bool append);
43
44 uint32_t
45 GetNumEnvironmentEntries ();
46
47 const char *
48 GetEnvironmentEntryAtIndex (uint32_t idx);
49
50 void
51 SetEnvironmentEntries (const char **envp, bool append);
52
53 void
54 Clear ();
55
56 const char *
57 GetWorkingDirectory () const;
58
59 void
60 SetWorkingDirectory (const char *working_dir);
61
62 uint32_t
63 GetLaunchFlags ();
64
65 void
66 SetLaunchFlags (uint32_t flags);
67
68 const char *
69 GetProcessPluginName ();
70
71 void
72 SetProcessPluginName (const char *plugin_name);
73
74 const char *
75 GetShell ();
76
77 void
78 SetShell (const char * path);
79
80 uint32_t
81 GetResumeCount ();
82
83 void
84 SetResumeCount (uint32_t c);
85
86 bool
87 AddCloseFileAction (int fd);
88
89 bool
90 AddDuplicateFileAction (int fd, int dup_fd);
91
92 bool
93 AddOpenFileAction (int fd, const char *path, bool read, bool write);
94
95 bool
96 AddSuppressFileAction (int fd, bool read, bool write);
97};
98
99class SBAttachInfo
100{
101public:
102 SBAttachInfo ();
103
104 SBAttachInfo (lldb::pid_t pid);
105
106 SBAttachInfo (const char *path, bool wait_for);
107
108 SBAttachInfo (const lldb::SBAttachInfo &rhs);
109
110 lldb::pid_t
111 GetProcessID ();
112
113 void
114 SetProcessID (lldb::pid_t pid);
115
116 void
117 SetExecutable (const char *path);
118
119 void
120 SetExecutable (lldb::SBFileSpec exe_file);
121
122 bool
123 GetWaitForLaunch ();
124
125 void
126 SetWaitForLaunch (bool b);
127
Jim Ingham3a458eb2012-07-20 21:37:13 +0000128 bool
129 GetIgnoreExisting ();
130
131 void
132 SetIgnoreExisting (bool b);
133
Greg Clayton0a8dcac2012-02-24 05:03:03 +0000134 uint32_t
135 GetResumeCount ();
136
137 void
138 SetResumeCount (uint32_t c);
139
140 const char *
141 GetProcessPluginName ();
142
143 void
144 SetProcessPluginName (const char *plugin_name);
145
146 uint32_t
Greg Clayton80efa5e2012-02-24 23:56:06 +0000147 GetUserID();
148
149 uint32_t
150 GetGroupID();
151
152 bool
153 UserIDIsValid ();
154
155 bool
156 GroupIDIsValid ();
157
158 void
159 SetUserID (uint32_t uid);
160
161 void
162 SetGroupID (uint32_t gid);
163
164 uint32_t
Greg Clayton0a8dcac2012-02-24 05:03:03 +0000165 GetEffectiveUserID();
166
167 uint32_t
168 GetEffectiveGroupID();
169
170 bool
171 EffectiveUserIDIsValid ();
172
173 bool
174 EffectiveGroupIDIsValid ();
175
176 void
177 SetEffectiveUserID (uint32_t uid);
178
179 void
180 SetEffectiveGroupID (uint32_t gid);
181
182 lldb::pid_t
183 GetParentProcessID ();
184
185 void
186 SetParentProcessID (lldb::pid_t pid);
187
188 bool
189 ParentProcessIDIsValid();
190};
191
192
Johnny Chenebd63b22011-07-16 21:15:39 +0000193%feature("docstring",
194"Represents the target program running under the debugger.
195
Johnny Chenecd4feb2011-10-14 00:42:25 +0000196SBTarget supports module, breakpoint, and watchpoint iterations. For example,
Johnny Chenebd63b22011-07-16 21:15:39 +0000197
198 for m in target.module_iter():
199 print m
200
201produces:
202
203(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
204(x86_64) /usr/lib/dyld
205(x86_64) /usr/lib/libstdc++.6.dylib
206(x86_64) /usr/lib/libSystem.B.dylib
207(x86_64) /usr/lib/system/libmathCommon.A.dylib
208(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
209
210and,
211
212 for b in target.breakpoint_iter():
213 print b
214
215produces:
216
217SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
Johnny Chen092bd152011-09-27 01:19:20 +0000218SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
219
220and,
221
Johnny Chenecd4feb2011-10-14 00:42:25 +0000222 for wp_loc in target.watchpoint_iter():
Johnny Chen092bd152011-09-27 01:19:20 +0000223 print wp_loc
224
225produces:
226
Johnny Chenecd4feb2011-10-14 00:42:25 +0000227Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
Johnny Chen092bd152011-09-27 01:19:20 +0000228 declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
Johnny Chenecd4feb2011-10-14 00:42:25 +0000229 hw_index = 0 hit_count = 2 ignore_count = 0"
Johnny Chenc3fba812011-07-18 20:13:38 +0000230) SBTarget;
Johnny Chenebd63b22011-07-16 21:15:39 +0000231class SBTarget
232{
Johnny Chenebd63b22011-07-16 21:15:39 +0000233public:
234 //------------------------------------------------------------------
235 // Broadcaster bits.
236 //------------------------------------------------------------------
237 enum
238 {
239 eBroadcastBitBreakpointChanged = (1 << 0),
240 eBroadcastBitModulesLoaded = (1 << 1),
241 eBroadcastBitModulesUnloaded = (1 << 2)
242 };
243
244 //------------------------------------------------------------------
245 // Constructors
246 //------------------------------------------------------------------
247 SBTarget ();
248
249 SBTarget (const lldb::SBTarget& rhs);
250
Johnny Chenebd63b22011-07-16 21:15:39 +0000251 //------------------------------------------------------------------
252 // Destructor
253 //------------------------------------------------------------------
254 ~SBTarget();
255
Jim Ingham5a15e692012-02-16 06:50:00 +0000256 static const char *
257 GetBroadcasterClassName ();
258
Johnny Chenebd63b22011-07-16 21:15:39 +0000259 bool
260 IsValid() const;
261
262 lldb::SBProcess
263 GetProcess ();
264
265 %feature("docstring", "
266 //------------------------------------------------------------------
267 /// Launch a new process.
268 ///
269 /// Launch a new process by spawning a new process using the
270 /// target object's executable module's file as the file to launch.
271 /// Arguments are given in \a argv, and the environment variables
272 /// are in \a envp. Standard input and output files can be
273 /// optionally re-directed to \a stdin_path, \a stdout_path, and
274 /// \a stderr_path.
275 ///
276 /// @param[in] listener
277 /// An optional listener that will receive all process events.
278 /// If \a listener is valid then \a listener will listen to all
279 /// process events. If not valid, then this target's debugger
280 /// (SBTarget::GetDebugger()) will listen to all process events.
281 ///
282 /// @param[in] argv
283 /// The argument array.
284 ///
285 /// @param[in] envp
286 /// The environment array.
287 ///
288 /// @param[in] launch_flags
289 /// Flags to modify the launch (@see lldb::LaunchFlags)
290 ///
291 /// @param[in] stdin_path
292 /// The path to use when re-directing the STDIN of the new
293 /// process. If all stdXX_path arguments are NULL, a pseudo
294 /// terminal will be used.
295 ///
296 /// @param[in] stdout_path
297 /// The path to use when re-directing the STDOUT of the new
298 /// process. If all stdXX_path arguments are NULL, a pseudo
299 /// terminal will be used.
300 ///
301 /// @param[in] stderr_path
302 /// The path to use when re-directing the STDERR of the new
303 /// process. If all stdXX_path arguments are NULL, a pseudo
304 /// terminal will be used.
305 ///
306 /// @param[in] working_directory
307 /// The working directory to have the child process run in
308 ///
309 /// @param[in] launch_flags
310 /// Some launch options specified by logical OR'ing
311 /// lldb::LaunchFlags enumeration values together.
312 ///
313 /// @param[in] stop_at_endtry
314 /// If false do not stop the inferior at the entry point.
315 ///
316 /// @param[out]
317 /// An error object. Contains the reason if there is some failure.
318 ///
319 /// @return
320 /// A process object for the newly created process.
321 //------------------------------------------------------------------
322
323 For example,
324
325 process = target.Launch(self.dbg.GetListener(), None, None,
326 None, '/tmp/stdout.txt', None,
327 None, 0, False, error)
328
329 launches a new process by passing nothing for both the args and the envs
330 and redirect the standard output of the inferior to the /tmp/stdout.txt
331 file. It does not specify a working directory so that the debug server
332 will use its idea of what the current working directory is for the
333 inferior. Also, we ask the debugger not to stop the inferior at the
334 entry point. If no breakpoint is specified for the inferior, it should
335 run to completion if no user interaction is required.
336 ") Launch;
337 lldb::SBProcess
338 Launch (SBListener &listener,
339 char const **argv,
340 char const **envp,
341 const char *stdin_path,
342 const char *stdout_path,
343 const char *stderr_path,
344 const char *working_directory,
345 uint32_t launch_flags, // See LaunchFlags
346 bool stop_at_entry,
347 lldb::SBError& error);
348
349 %feature("docstring", "
350 //------------------------------------------------------------------
351 /// Launch a new process with sensible defaults.
352 ///
353 /// @param[in] argv
354 /// The argument array.
355 ///
356 /// @param[in] envp
357 /// The environment array.
358 ///
359 /// @param[in] working_directory
360 /// The working directory to have the child process run in
361 ///
362 /// Default: listener
363 /// Set to the target's debugger (SBTarget::GetDebugger())
364 ///
365 /// Default: launch_flags
366 /// Empty launch flags
367 ///
368 /// Default: stdin_path
369 /// Default: stdout_path
370 /// Default: stderr_path
371 /// A pseudo terminal will be used.
372 ///
373 /// @return
374 /// A process object for the newly created process.
375 //------------------------------------------------------------------
376
377 For example,
378
379 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
380
381 launches a new process by passing 'X', 'Y', 'Z' as the args to the
382 executable.
383 ") LaunchSimple;
384 lldb::SBProcess
385 LaunchSimple (const char **argv,
386 const char **envp,
387 const char *working_directory);
388
Greg Clayton0a8dcac2012-02-24 05:03:03 +0000389 lldb::SBProcess
390 Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
391
392 lldb::SBProcess
393 Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error);
394
395
Johnny Chenebd63b22011-07-16 21:15:39 +0000396 %feature("docstring", "
397 //------------------------------------------------------------------
398 /// Attach to process with pid.
399 ///
400 /// @param[in] listener
401 /// An optional listener that will receive all process events.
402 /// If \a listener is valid then \a listener will listen to all
403 /// process events. If not valid, then this target's debugger
404 /// (SBTarget::GetDebugger()) will listen to all process events.
405 ///
406 /// @param[in] pid
407 /// The process ID to attach to.
408 ///
409 /// @param[out]
410 /// An error explaining what went wrong if attach fails.
411 ///
412 /// @return
413 /// A process object for the attached process.
414 //------------------------------------------------------------------
415 ") AttachToProcessWithID;
416 lldb::SBProcess
417 AttachToProcessWithID (SBListener &listener,
418 lldb::pid_t pid,
419 lldb::SBError& error);
420
421 %feature("docstring", "
422 //------------------------------------------------------------------
423 /// Attach to process with name.
424 ///
425 /// @param[in] listener
426 /// An optional listener that will receive all process events.
427 /// If \a listener is valid then \a listener will listen to all
428 /// process events. If not valid, then this target's debugger
429 /// (SBTarget::GetDebugger()) will listen to all process events.
430 ///
431 /// @param[in] name
432 /// Basename of process to attach to.
433 ///
434 /// @param[in] wait_for
435 /// If true wait for a new instance of 'name' to be launched.
436 ///
437 /// @param[out]
438 /// An error explaining what went wrong if attach fails.
439 ///
440 /// @return
441 /// A process object for the attached process.
442 //------------------------------------------------------------------
443 ") AttachToProcessWithName;
444 lldb::SBProcess
445 AttachToProcessWithName (SBListener &listener,
446 const char *name,
447 bool wait_for,
448 lldb::SBError& error);
449
450 %feature("docstring", "
451 //------------------------------------------------------------------
452 /// Connect to a remote debug server with url.
453 ///
454 /// @param[in] listener
455 /// An optional listener that will receive all process events.
456 /// If \a listener is valid then \a listener will listen to all
457 /// process events. If not valid, then this target's debugger
458 /// (SBTarget::GetDebugger()) will listen to all process events.
459 ///
460 /// @param[in] url
461 /// The url to connect to, e.g., 'connect://localhost:12345'.
462 ///
463 /// @param[in] plugin_name
464 /// The plugin name to be used; can be NULL.
465 ///
466 /// @param[out]
467 /// An error explaining what went wrong if the connect fails.
468 ///
469 /// @return
470 /// A process object for the connected process.
471 //------------------------------------------------------------------
472 ") ConnectRemote;
473 lldb::SBProcess
474 ConnectRemote (SBListener &listener,
475 const char *url,
476 const char *plugin_name,
477 SBError& error);
478
479 lldb::SBFileSpec
480 GetExecutable ();
481
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000482 bool
483 AddModule (lldb::SBModule &module);
484
485 lldb::SBModule
486 AddModule (const char *path,
487 const char *triple,
488 const char *uuid);
489
Greg Claytonf0bc8152012-04-23 20:23:39 +0000490 lldb::SBModule
491 AddModule (const char *path,
492 const char *triple,
493 const char *uuid_cstr,
494 const char *symfile);
495
Johnny Chenebd63b22011-07-16 21:15:39 +0000496 uint32_t
497 GetNumModules () const;
498
499 lldb::SBModule
500 GetModuleAtIndex (uint32_t idx);
501
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000502 bool
503 RemoveModule (lldb::SBModule module);
504
Johnny Chenebd63b22011-07-16 21:15:39 +0000505 lldb::SBDebugger
506 GetDebugger() const;
507
508 lldb::SBModule
509 FindModule (const lldb::SBFileSpec &file_spec);
510
Greg Clayton1b925202012-01-29 06:07:39 +0000511 lldb::ByteOrder
512 GetByteOrder ();
513
514 uint32_t
515 GetAddressByteSize();
516
517 const char *
518 GetTriple ();
519
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000520 lldb::SBError
521 SetSectionLoadAddress (lldb::SBSection section,
522 lldb::addr_t section_base_addr);
523
524 lldb::SBError
525 ClearSectionLoadAddress (lldb::SBSection section);
526
527 lldb::SBError
528 SetModuleLoadAddress (lldb::SBModule module,
529 int64_t sections_offset);
530
531 lldb::SBError
532 ClearModuleLoadAddress (lldb::SBModule module);
533
Johnny Chenebd63b22011-07-16 21:15:39 +0000534 %feature("docstring", "
535 //------------------------------------------------------------------
536 /// Find functions by name.
537 ///
538 /// @param[in] name
539 /// The name of the function we are looking for.
540 ///
541 /// @param[in] name_type_mask
542 /// A logical OR of one or more FunctionNameType enum bits that
543 /// indicate what kind of names should be used when doing the
544 /// lookup. Bits include fully qualified names, base names,
545 /// C++ methods, or ObjC selectors.
546 /// See FunctionNameType for more details.
547 ///
Johnny Chenebd63b22011-07-16 21:15:39 +0000548 /// @return
Greg Clayton7dd5c512012-02-06 01:44:54 +0000549 /// A lldb::SBSymbolContextList that gets filled in with all of
550 /// the symbol contexts for all the matches.
Johnny Chenebd63b22011-07-16 21:15:39 +0000551 //------------------------------------------------------------------
552 ") FindFunctions;
Greg Clayton7dd5c512012-02-06 01:44:54 +0000553 lldb::SBSymbolContextList
Johnny Chenebd63b22011-07-16 21:15:39 +0000554 FindFunctions (const char *name,
Greg Clayton7dd5c512012-02-06 01:44:54 +0000555 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
Enrico Granata979e20d2011-07-29 19:53:35 +0000556
557 lldb::SBType
558 FindFirstType (const char* type);
559
560 lldb::SBTypeList
561 FindTypes (const char* type);
Johnny Chenebd63b22011-07-16 21:15:39 +0000562
Greg Clayton0b93a752012-12-05 21:24:42 +0000563 lldb::SBType
564 GetBasicType(lldb::BasicType type);
565
Jim Inghamcc637462011-09-13 00:29:56 +0000566 lldb::SBSourceManager
567 GetSourceManager ();
568
Johnny Chenebd63b22011-07-16 21:15:39 +0000569 %feature("docstring", "
570 //------------------------------------------------------------------
571 /// Find global and static variables by name.
572 ///
573 /// @param[in] name
574 /// The name of the global or static variable we are looking
575 /// for.
576 ///
577 /// @param[in] max_matches
578 /// Allow the number of matches to be limited to \a max_matches.
579 ///
580 /// @return
581 /// A list of matched variables in an SBValueList.
582 //------------------------------------------------------------------
583 ") FindGlobalVariables;
584 lldb::SBValueList
585 FindGlobalVariables (const char *name,
586 uint32_t max_matches);
587
588 void
589 Clear ();
590
Greg Claytona3955062011-07-22 16:46:35 +0000591 lldb::SBAddress
592 ResolveLoadAddress (lldb::addr_t vm_addr);
Johnny Chenebd63b22011-07-16 21:15:39 +0000593
594 SBSymbolContext
595 ResolveSymbolContextForAddress (const SBAddress& addr,
596 uint32_t resolve_scope);
597
598 lldb::SBBreakpoint
599 BreakpointCreateByLocation (const char *file, uint32_t line);
600
601 lldb::SBBreakpoint
602 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
603
604 lldb::SBBreakpoint
605 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
606
607 lldb::SBBreakpoint
Jim Ingham1fb8a2d2011-10-11 01:18:55 +0000608 BreakpointCreateByName (const char *symbol_name,
609 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
610 const SBFileSpecList &module_list,
611 const SBFileSpecList &comp_unit_list);
612
613 lldb::SBBreakpoint
Jim Ingham4722b102012-03-06 00:37:27 +0000614 BreakpointCreateByNames (const char *symbol_name[],
615 uint32_t num_names,
616 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
617 const SBFileSpecList &module_list,
618 const SBFileSpecList &comp_unit_list);
619
620 lldb::SBBreakpoint
Johnny Chenebd63b22011-07-16 21:15:39 +0000621 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
622
623 lldb::SBBreakpoint
Jim Ingham03c8ee52011-09-21 01:17:13 +0000624 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
625
626 lldb::SBBreakpoint
Jim Ingham4722b102012-03-06 00:37:27 +0000627 BreakpointCreateForException (lldb::LanguageType language,
628 bool catch_bp,
629 bool throw_bp);
630
631 lldb::SBBreakpoint
Johnny Chenebd63b22011-07-16 21:15:39 +0000632 BreakpointCreateByAddress (addr_t address);
633
634 uint32_t
635 GetNumBreakpoints () const;
636
637 lldb::SBBreakpoint
638 GetBreakpointAtIndex (uint32_t idx) const;
639
640 bool
641 BreakpointDelete (break_id_t break_id);
642
643 lldb::SBBreakpoint
644 FindBreakpointByID (break_id_t break_id);
645
646 bool
647 EnableAllBreakpoints ();
648
649 bool
650 DisableAllBreakpoints ();
651
652 bool
653 DeleteAllBreakpoints ();
654
Johnny Chen092bd152011-09-27 01:19:20 +0000655 uint32_t
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000656 GetNumWatchpoints () const;
657
658 lldb::SBWatchpoint
659 GetWatchpointAtIndex (uint32_t idx) const;
660
Johnny Chen092bd152011-09-27 01:19:20 +0000661 bool
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000662 DeleteWatchpoint (lldb::watch_id_t watch_id);
663
664 lldb::SBWatchpoint
665 FindWatchpointByID (lldb::watch_id_t watch_id);
666
Johnny Chen092bd152011-09-27 01:19:20 +0000667 bool
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000668 EnableAllWatchpoints ();
669
Johnny Chen092bd152011-09-27 01:19:20 +0000670 bool
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000671 DisableAllWatchpoints ();
672
Johnny Chen092bd152011-09-27 01:19:20 +0000673 bool
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000674 DeleteAllWatchpoints ();
675
676 lldb::SBWatchpoint
677 WatchAddress (lldb::addr_t addr,
678 size_t size,
679 bool read,
Johnny Chen3f883492012-06-04 23:19:54 +0000680 bool write,
681 SBError &error);
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000682
Johnny Chen092bd152011-09-27 01:19:20 +0000683
Johnny Chenebd63b22011-07-16 21:15:39 +0000684 lldb::SBBroadcaster
685 GetBroadcaster () const;
Sean Callananef1f6902011-12-14 23:49:37 +0000686
687 lldb::SBInstructionList
Greg Claytona9893072012-03-06 22:24:44 +0000688 ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
689
690 lldb::SBInstructionList
Sean Callananef1f6902011-12-14 23:49:37 +0000691 GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
692
Greg Claytonb3dafc62012-12-04 02:22:16 +0000693 lldb::SBSymbolContextList
694 FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
695
Johnny Chenebd63b22011-07-16 21:15:39 +0000696 bool
Greg Clayton96154be2011-11-13 06:57:31 +0000697 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
Greg Clayton1b925202012-01-29 06:07:39 +0000698
699 %pythoncode %{
Greg Claytonb302dff2012-02-01 08:09:32 +0000700 class modules_access(object):
701 '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
702 def __init__(self, sbtarget):
703 self.sbtarget = sbtarget
704
705 def __len__(self):
706 if self.sbtarget:
Filipe Cabecinhas3cae38b2012-05-11 20:39:42 +0000707 return int(self.sbtarget.GetNumModules())
Greg Claytonb302dff2012-02-01 08:09:32 +0000708 return 0
709
710 def __getitem__(self, key):
711 num_modules = self.sbtarget.GetNumModules()
712 if type(key) is int:
713 if key < num_modules:
714 return self.sbtarget.GetModuleAtIndex(key)
715 elif type(key) is str:
716 if key.find('/') == -1:
717 for idx in range(num_modules):
718 module = self.sbtarget.GetModuleAtIndex(idx)
719 if module.file.basename == key:
720 return module
721 else:
722 for idx in range(num_modules):
723 module = self.sbtarget.GetModuleAtIndex(idx)
724 if module.file.fullpath == key:
725 return module
726 # See if the string is a UUID
727 the_uuid = uuid.UUID(key)
728 if the_uuid:
729 for idx in range(num_modules):
730 module = self.sbtarget.GetModuleAtIndex(idx)
731 if module.uuid == the_uuid:
732 return module
733 elif type(key) is uuid.UUID:
734 for idx in range(num_modules):
735 module = self.sbtarget.GetModuleAtIndex(idx)
736 if module.uuid == key:
737 return module
738 elif type(key) is re.SRE_Pattern:
739 matching_modules = []
740 for idx in range(num_modules):
741 module = self.sbtarget.GetModuleAtIndex(idx)
742 re_match = key.search(module.path.fullpath)
743 if re_match:
744 matching_modules.append(module)
745 return matching_modules
746 else:
747 print "error: unsupported item type: %s" % type(key)
748 return None
749
750 def get_modules_access_object(self):
Greg Claytonb6a5ba62012-02-03 03:22:53 +0000751 '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.'''
Greg Claytonb302dff2012-02-01 08:09:32 +0000752 return self.modules_access (self)
753
754 def get_modules_array(self):
Greg Claytonb6a5ba62012-02-03 03:22:53 +0000755 '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
Greg Claytonb302dff2012-02-01 08:09:32 +0000756 modules = []
757 for idx in range(self.GetNumModules()):
758 modules.append(self.GetModuleAtIndex(idx))
759 return modules
760
761 __swig_getmethods__["modules"] = get_modules_array
Greg Clayton2a94be12012-06-29 22:00:42 +0000762 if _newclass: modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''')
Greg Claytonb302dff2012-02-01 08:09:32 +0000763
764 __swig_getmethods__["module"] = get_modules_access_object
Greg Clayton2a94be12012-06-29 22:00:42 +0000765 if _newclass: module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[<int>] allows array access to any modules.\n target.module[<str>] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''')
Greg Claytonb302dff2012-02-01 08:09:32 +0000766
Greg Clayton1b925202012-01-29 06:07:39 +0000767 __swig_getmethods__["process"] = GetProcess
Greg Clayton2a94be12012-06-29 22:00:42 +0000768 if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000769
770 __swig_getmethods__["executable"] = GetExecutable
Greg Clayton2a94be12012-06-29 22:00:42 +0000771 if _newclass: executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000772
773 __swig_getmethods__["debugger"] = GetDebugger
Greg Clayton2a94be12012-06-29 22:00:42 +0000774 if _newclass: debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000775
Greg Clayton1b925202012-01-29 06:07:39 +0000776 __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints
Greg Clayton2a94be12012-06-29 22:00:42 +0000777 if _newclass: num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000778
779 __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints
Greg Clayton2a94be12012-06-29 22:00:42 +0000780 if _newclass: num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000781
782 __swig_getmethods__["broadcaster"] = GetBroadcaster
Greg Clayton2a94be12012-06-29 22:00:42 +0000783 if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000784
785 __swig_getmethods__["byte_order"] = GetByteOrder
Greg Clayton2a94be12012-06-29 22:00:42 +0000786 if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000787
788 __swig_getmethods__["addr_size"] = GetAddressByteSize
Greg Clayton2a94be12012-06-29 22:00:42 +0000789 if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000790
791 __swig_getmethods__["triple"] = GetTriple
Greg Clayton2a94be12012-06-29 22:00:42 +0000792 if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''')
Greg Clayton1b925202012-01-29 06:07:39 +0000793 %}
794
Johnny Chenebd63b22011-07-16 21:15:39 +0000795};
796
797} // namespace lldb