blob: 0237dd5cc1f69af35cac9ade64c6507f12631f1c [file] [log] [blame]
Johnny Chendc7d3c12011-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 Clayton0e615682012-02-24 05:03:03 +000012class SBLaunchInfo
13{
Greg Clayton38d1f052012-02-24 20:59:25 +000014public:
15 SBLaunchInfo (const char **argv);
Greg Clayton0e615682012-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 Clayton3e32ad62014-05-07 20:16:06 +000035 lldb::SBFileSpec
36 GetExecutableFile ();
37
38 void
39 SetExecutableFile (lldb::SBFileSpec exe_file, bool add_as_first_arg);
40
Greg Clayton8012cad2014-11-17 19:39:20 +000041 lldb::SBListener
42 GetListener ();
43
44 void
45 SetListener (lldb::SBListener &listener);
46
Greg Clayton0e615682012-02-24 05:03:03 +000047 uint32_t
48 GetNumArguments ();
49
50 const char *
51 GetArgumentAtIndex (uint32_t idx);
52
53 void
54 SetArguments (const char **argv, bool append);
55
56 uint32_t
57 GetNumEnvironmentEntries ();
58
59 const char *
60 GetEnvironmentEntryAtIndex (uint32_t idx);
61
62 void
63 SetEnvironmentEntries (const char **envp, bool append);
64
65 void
66 Clear ();
67
68 const char *
69 GetWorkingDirectory () const;
70
71 void
72 SetWorkingDirectory (const char *working_dir);
73
74 uint32_t
75 GetLaunchFlags ();
76
77 void
78 SetLaunchFlags (uint32_t flags);
79
80 const char *
81 GetProcessPluginName ();
82
83 void
84 SetProcessPluginName (const char *plugin_name);
85
86 const char *
87 GetShell ();
88
89 void
90 SetShell (const char * path);
91
92 uint32_t
93 GetResumeCount ();
94
95 void
96 SetResumeCount (uint32_t c);
97
98 bool
99 AddCloseFileAction (int fd);
100
101 bool
102 AddDuplicateFileAction (int fd, int dup_fd);
103
104 bool
105 AddOpenFileAction (int fd, const char *path, bool read, bool write);
106
107 bool
108 AddSuppressFileAction (int fd, bool read, bool write);
Jason Molendaa3329782014-03-29 18:54:20 +0000109
110 void
111 SetLaunchEventData (const char *data);
112
113 const char *
114 GetLaunchEventData () const;
115
Jim Ingham106d0282014-06-25 02:32:56 +0000116 bool
117 GetDetachOnError() const;
118
119 void
120 SetDetachOnError(bool enable);
Greg Clayton0e615682012-02-24 05:03:03 +0000121};
122
123class SBAttachInfo
124{
125public:
126 SBAttachInfo ();
127
128 SBAttachInfo (lldb::pid_t pid);
129
130 SBAttachInfo (const char *path, bool wait_for);
131
132 SBAttachInfo (const lldb::SBAttachInfo &rhs);
133
134 lldb::pid_t
135 GetProcessID ();
136
137 void
138 SetProcessID (lldb::pid_t pid);
139
140 void
141 SetExecutable (const char *path);
142
143 void
144 SetExecutable (lldb::SBFileSpec exe_file);
145
146 bool
147 GetWaitForLaunch ();
148
149 void
150 SetWaitForLaunch (bool b);
151
Jim Inghamcd16df92012-07-20 21:37:13 +0000152 bool
153 GetIgnoreExisting ();
154
155 void
156 SetIgnoreExisting (bool b);
157
Greg Clayton0e615682012-02-24 05:03:03 +0000158 uint32_t
159 GetResumeCount ();
160
161 void
162 SetResumeCount (uint32_t c);
163
164 const char *
165 GetProcessPluginName ();
166
167 void
168 SetProcessPluginName (const char *plugin_name);
169
170 uint32_t
Greg Clayton41bd8ac2012-02-24 23:56:06 +0000171 GetUserID();
172
173 uint32_t
174 GetGroupID();
175
176 bool
177 UserIDIsValid ();
178
179 bool
180 GroupIDIsValid ();
181
182 void
183 SetUserID (uint32_t uid);
184
185 void
186 SetGroupID (uint32_t gid);
187
188 uint32_t
Greg Clayton0e615682012-02-24 05:03:03 +0000189 GetEffectiveUserID();
190
191 uint32_t
192 GetEffectiveGroupID();
193
194 bool
195 EffectiveUserIDIsValid ();
196
197 bool
198 EffectiveGroupIDIsValid ();
199
200 void
201 SetEffectiveUserID (uint32_t uid);
202
203 void
204 SetEffectiveGroupID (uint32_t gid);
205
206 lldb::pid_t
207 GetParentProcessID ();
208
209 void
210 SetParentProcessID (lldb::pid_t pid);
211
212 bool
213 ParentProcessIDIsValid();
Greg Clayton8012cad2014-11-17 19:39:20 +0000214
215 lldb::SBListener
216 GetListener ();
217
218 void
219 SetListener (lldb::SBListener &listener);
Greg Clayton0e615682012-02-24 05:03:03 +0000220};
221
222
Johnny Chendc7d3c12011-07-16 21:15:39 +0000223%feature("docstring",
224"Represents the target program running under the debugger.
225
Johnny Chen01a67862011-10-14 00:42:25 +0000226SBTarget supports module, breakpoint, and watchpoint iterations. For example,
Johnny Chendc7d3c12011-07-16 21:15:39 +0000227
228 for m in target.module_iter():
229 print m
230
231produces:
232
233(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
234(x86_64) /usr/lib/dyld
235(x86_64) /usr/lib/libstdc++.6.dylib
236(x86_64) /usr/lib/libSystem.B.dylib
237(x86_64) /usr/lib/system/libmathCommon.A.dylib
238(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
239
240and,
241
242 for b in target.breakpoint_iter():
243 print b
244
245produces:
246
247SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
Johnny Chend4dd7992011-09-27 01:19:20 +0000248SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
249
250and,
251
Johnny Chen01a67862011-10-14 00:42:25 +0000252 for wp_loc in target.watchpoint_iter():
Johnny Chend4dd7992011-09-27 01:19:20 +0000253 print wp_loc
254
255produces:
256
Johnny Chen01a67862011-10-14 00:42:25 +0000257Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
Johnny Chend4dd7992011-09-27 01:19:20 +0000258 declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
Johnny Chen01a67862011-10-14 00:42:25 +0000259 hw_index = 0 hit_count = 2 ignore_count = 0"
Johnny Chen357033b2011-07-18 20:13:38 +0000260) SBTarget;
Johnny Chendc7d3c12011-07-16 21:15:39 +0000261class SBTarget
262{
Johnny Chendc7d3c12011-07-16 21:15:39 +0000263public:
264 //------------------------------------------------------------------
265 // Broadcaster bits.
266 //------------------------------------------------------------------
267 enum
268 {
269 eBroadcastBitBreakpointChanged = (1 << 0),
270 eBroadcastBitModulesLoaded = (1 << 1),
Jim Ingham1b5792e2012-12-18 02:03:49 +0000271 eBroadcastBitModulesUnloaded = (1 << 2),
Enrico Granataf15ee4e2013-04-05 18:49:06 +0000272 eBroadcastBitWatchpointChanged = (1 << 3),
273 eBroadcastBitSymbolsLoaded = (1 << 4)
Johnny Chendc7d3c12011-07-16 21:15:39 +0000274 };
275
276 //------------------------------------------------------------------
277 // Constructors
278 //------------------------------------------------------------------
279 SBTarget ();
280
281 SBTarget (const lldb::SBTarget& rhs);
282
Johnny Chendc7d3c12011-07-16 21:15:39 +0000283 //------------------------------------------------------------------
284 // Destructor
285 //------------------------------------------------------------------
286 ~SBTarget();
287
Jim Ingham4bddaeb2012-02-16 06:50:00 +0000288 static const char *
289 GetBroadcasterClassName ();
290
Johnny Chendc7d3c12011-07-16 21:15:39 +0000291 bool
292 IsValid() const;
293
294 lldb::SBProcess
295 GetProcess ();
296
Matthew Gardinerc928de32014-10-22 07:22:56 +0000297
298 %feature("docstring", "
299 //------------------------------------------------------------------
300 /// Return the platform object associated with the target.
301 ///
302 /// After return, the platform object should be checked for
303 /// validity.
304 ///
305 /// @return
306 /// A platform object.
307 //------------------------------------------------------------------
308 ") GetPlatform;
309 lldb::SBPlatform
310 GetPlatform ();
311
Johnny Chendc7d3c12011-07-16 21:15:39 +0000312 %feature("docstring", "
313 //------------------------------------------------------------------
Greg Claytonfbb76342013-11-20 21:07:01 +0000314 /// Install any binaries that need to be installed.
315 ///
316 /// This function does nothing when debugging on the host system.
317 /// When connected to remote platforms, the target's main executable
318 /// and any modules that have their install path set will be
319 /// installed on the remote platform. If the main executable doesn't
320 /// have an install location set, it will be installed in the remote
321 /// platform's working directory.
322 ///
323 /// @return
324 /// An error describing anything that went wrong during
325 /// installation.
326 //------------------------------------------------------------------
327 ") Install;
328 lldb::SBError
329 Install();
330
331 %feature("docstring", "
332 //------------------------------------------------------------------
Johnny Chendc7d3c12011-07-16 21:15:39 +0000333 /// Launch a new process.
334 ///
335 /// Launch a new process by spawning a new process using the
336 /// target object's executable module's file as the file to launch.
337 /// Arguments are given in \a argv, and the environment variables
338 /// are in \a envp. Standard input and output files can be
339 /// optionally re-directed to \a stdin_path, \a stdout_path, and
340 /// \a stderr_path.
341 ///
342 /// @param[in] listener
343 /// An optional listener that will receive all process events.
344 /// If \a listener is valid then \a listener will listen to all
345 /// process events. If not valid, then this target's debugger
346 /// (SBTarget::GetDebugger()) will listen to all process events.
347 ///
348 /// @param[in] argv
349 /// The argument array.
350 ///
351 /// @param[in] envp
352 /// The environment array.
353 ///
354 /// @param[in] launch_flags
355 /// Flags to modify the launch (@see lldb::LaunchFlags)
356 ///
357 /// @param[in] stdin_path
358 /// The path to use when re-directing the STDIN of the new
359 /// process. If all stdXX_path arguments are NULL, a pseudo
360 /// terminal will be used.
361 ///
362 /// @param[in] stdout_path
363 /// The path to use when re-directing the STDOUT of the new
364 /// process. If all stdXX_path arguments are NULL, a pseudo
365 /// terminal will be used.
366 ///
367 /// @param[in] stderr_path
368 /// The path to use when re-directing the STDERR of the new
369 /// process. If all stdXX_path arguments are NULL, a pseudo
370 /// terminal will be used.
371 ///
372 /// @param[in] working_directory
373 /// The working directory to have the child process run in
374 ///
375 /// @param[in] launch_flags
376 /// Some launch options specified by logical OR'ing
377 /// lldb::LaunchFlags enumeration values together.
378 ///
379 /// @param[in] stop_at_endtry
380 /// If false do not stop the inferior at the entry point.
381 ///
382 /// @param[out]
383 /// An error object. Contains the reason if there is some failure.
384 ///
385 /// @return
386 /// A process object for the newly created process.
387 //------------------------------------------------------------------
388
389 For example,
390
391 process = target.Launch(self.dbg.GetListener(), None, None,
392 None, '/tmp/stdout.txt', None,
393 None, 0, False, error)
394
395 launches a new process by passing nothing for both the args and the envs
396 and redirect the standard output of the inferior to the /tmp/stdout.txt
397 file. It does not specify a working directory so that the debug server
398 will use its idea of what the current working directory is for the
399 inferior. Also, we ask the debugger not to stop the inferior at the
400 entry point. If no breakpoint is specified for the inferior, it should
401 run to completion if no user interaction is required.
402 ") Launch;
403 lldb::SBProcess
404 Launch (SBListener &listener,
405 char const **argv,
406 char const **envp,
407 const char *stdin_path,
408 const char *stdout_path,
409 const char *stderr_path,
410 const char *working_directory,
411 uint32_t launch_flags, // See LaunchFlags
412 bool stop_at_entry,
413 lldb::SBError& error);
414
415 %feature("docstring", "
416 //------------------------------------------------------------------
417 /// Launch a new process with sensible defaults.
418 ///
419 /// @param[in] argv
420 /// The argument array.
421 ///
422 /// @param[in] envp
423 /// The environment array.
424 ///
425 /// @param[in] working_directory
426 /// The working directory to have the child process run in
427 ///
428 /// Default: listener
429 /// Set to the target's debugger (SBTarget::GetDebugger())
430 ///
431 /// Default: launch_flags
432 /// Empty launch flags
433 ///
434 /// Default: stdin_path
435 /// Default: stdout_path
436 /// Default: stderr_path
437 /// A pseudo terminal will be used.
438 ///
439 /// @return
440 /// A process object for the newly created process.
441 //------------------------------------------------------------------
442
443 For example,
444
445 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
446
447 launches a new process by passing 'X', 'Y', 'Z' as the args to the
448 executable.
449 ") LaunchSimple;
450 lldb::SBProcess
451 LaunchSimple (const char **argv,
452 const char **envp,
453 const char *working_directory);
454
Greg Clayton0e615682012-02-24 05:03:03 +0000455 lldb::SBProcess
456 Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
Greg Clayton4d8ad552013-03-25 22:40:51 +0000457
458 %feature("docstring", "
459 //------------------------------------------------------------------
460 /// Load a core file
461 ///
462 /// @param[in] core_file
463 /// File path of the core dump.
464 ///
465 /// @return
466 /// A process object for the newly created core file.
467 //------------------------------------------------------------------
468
469 For example,
470
471 process = target.LoadCore('./a.out.core')
472
473 loads a new core file and returns the process object.
474 ") LoadCore;
475 lldb::SBProcess
476 LoadCore(const char *core_file);
Greg Clayton0e615682012-02-24 05:03:03 +0000477
478 lldb::SBProcess
479 Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error);
480
481
Johnny Chendc7d3c12011-07-16 21:15:39 +0000482 %feature("docstring", "
483 //------------------------------------------------------------------
484 /// Attach to process with pid.
485 ///
486 /// @param[in] listener
487 /// An optional listener that will receive all process events.
488 /// If \a listener is valid then \a listener will listen to all
489 /// process events. If not valid, then this target's debugger
490 /// (SBTarget::GetDebugger()) will listen to all process events.
491 ///
492 /// @param[in] pid
493 /// The process ID to attach to.
494 ///
495 /// @param[out]
496 /// An error explaining what went wrong if attach fails.
497 ///
498 /// @return
499 /// A process object for the attached process.
500 //------------------------------------------------------------------
501 ") AttachToProcessWithID;
502 lldb::SBProcess
503 AttachToProcessWithID (SBListener &listener,
504 lldb::pid_t pid,
505 lldb::SBError& error);
506
507 %feature("docstring", "
508 //------------------------------------------------------------------
509 /// Attach to process with name.
510 ///
511 /// @param[in] listener
512 /// An optional listener that will receive all process events.
513 /// If \a listener is valid then \a listener will listen to all
514 /// process events. If not valid, then this target's debugger
515 /// (SBTarget::GetDebugger()) will listen to all process events.
516 ///
517 /// @param[in] name
518 /// Basename of process to attach to.
519 ///
520 /// @param[in] wait_for
521 /// If true wait for a new instance of 'name' to be launched.
522 ///
523 /// @param[out]
524 /// An error explaining what went wrong if attach fails.
525 ///
526 /// @return
527 /// A process object for the attached process.
528 //------------------------------------------------------------------
529 ") AttachToProcessWithName;
530 lldb::SBProcess
531 AttachToProcessWithName (SBListener &listener,
532 const char *name,
533 bool wait_for,
534 lldb::SBError& error);
535
536 %feature("docstring", "
537 //------------------------------------------------------------------
538 /// Connect to a remote debug server with url.
539 ///
540 /// @param[in] listener
541 /// An optional listener that will receive all process events.
542 /// If \a listener is valid then \a listener will listen to all
543 /// process events. If not valid, then this target's debugger
544 /// (SBTarget::GetDebugger()) will listen to all process events.
545 ///
546 /// @param[in] url
547 /// The url to connect to, e.g., 'connect://localhost:12345'.
548 ///
549 /// @param[in] plugin_name
550 /// The plugin name to be used; can be NULL.
551 ///
552 /// @param[out]
553 /// An error explaining what went wrong if the connect fails.
554 ///
555 /// @return
556 /// A process object for the connected process.
557 //------------------------------------------------------------------
558 ") ConnectRemote;
559 lldb::SBProcess
560 ConnectRemote (SBListener &listener,
561 const char *url,
562 const char *plugin_name,
563 SBError& error);
564
565 lldb::SBFileSpec
566 GetExecutable ();
567
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000568 bool
569 AddModule (lldb::SBModule &module);
570
571 lldb::SBModule
572 AddModule (const char *path,
573 const char *triple,
574 const char *uuid);
575
Greg Claytonb210aec2012-04-23 20:23:39 +0000576 lldb::SBModule
577 AddModule (const char *path,
578 const char *triple,
579 const char *uuid_cstr,
580 const char *symfile);
581
Greg Clayton226cce22013-07-08 22:22:41 +0000582 lldb::SBModule
583 AddModule (const SBModuleSpec &module_spec);
584
Johnny Chendc7d3c12011-07-16 21:15:39 +0000585 uint32_t
586 GetNumModules () const;
587
588 lldb::SBModule
589 GetModuleAtIndex (uint32_t idx);
590
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000591 bool
592 RemoveModule (lldb::SBModule module);
593
Johnny Chendc7d3c12011-07-16 21:15:39 +0000594 lldb::SBDebugger
595 GetDebugger() const;
596
597 lldb::SBModule
598 FindModule (const lldb::SBFileSpec &file_spec);
599
Greg Clayton13d19502012-01-29 06:07:39 +0000600 lldb::ByteOrder
601 GetByteOrder ();
602
603 uint32_t
604 GetAddressByteSize();
605
606 const char *
607 GetTriple ();
608
Matthew Gardinerc928de32014-10-22 07:22:56 +0000609 %feature("docstring", "
610 //------------------------------------------------------------------
611 /// Architecture data byte width accessor
612 ///
613 /// @return
614 /// The size in 8-bit (host) bytes of a minimum addressable
615 /// unit from the Architecture's data bus
616 //------------------------------------------------------------------
617 ") GetDataByteSize;
618 uint32_t
619 GetDataByteSize ();
620
621 %feature("docstring", "
622 //------------------------------------------------------------------
623 /// Architecture code byte width accessor
624 ///
625 /// @return
626 /// The size in 8-bit (host) bytes of a minimum addressable
627 /// unit from the Architecture's code bus
628 //------------------------------------------------------------------
629 ") GetCodeByteSize;
630 uint32_t
631 GetCodeByteSize ();
632
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000633 lldb::SBError
634 SetSectionLoadAddress (lldb::SBSection section,
635 lldb::addr_t section_base_addr);
636
637 lldb::SBError
638 ClearSectionLoadAddress (lldb::SBSection section);
639
640 lldb::SBError
641 SetModuleLoadAddress (lldb::SBModule module,
642 int64_t sections_offset);
643
644 lldb::SBError
645 ClearModuleLoadAddress (lldb::SBModule module);
646
Johnny Chendc7d3c12011-07-16 21:15:39 +0000647 %feature("docstring", "
648 //------------------------------------------------------------------
649 /// Find functions by name.
650 ///
651 /// @param[in] name
652 /// The name of the function we are looking for.
653 ///
654 /// @param[in] name_type_mask
655 /// A logical OR of one or more FunctionNameType enum bits that
656 /// indicate what kind of names should be used when doing the
657 /// lookup. Bits include fully qualified names, base names,
658 /// C++ methods, or ObjC selectors.
659 /// See FunctionNameType for more details.
660 ///
Johnny Chendc7d3c12011-07-16 21:15:39 +0000661 /// @return
Greg Clayton5569e642012-02-06 01:44:54 +0000662 /// A lldb::SBSymbolContextList that gets filled in with all of
663 /// the symbol contexts for all the matches.
Johnny Chendc7d3c12011-07-16 21:15:39 +0000664 //------------------------------------------------------------------
665 ") FindFunctions;
Greg Clayton5569e642012-02-06 01:44:54 +0000666 lldb::SBSymbolContextList
Johnny Chendc7d3c12011-07-16 21:15:39 +0000667 FindFunctions (const char *name,
Greg Clayton5569e642012-02-06 01:44:54 +0000668 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000669
670 lldb::SBType
671 FindFirstType (const char* type);
672
673 lldb::SBTypeList
674 FindTypes (const char* type);
Johnny Chendc7d3c12011-07-16 21:15:39 +0000675
Greg Claytonb43165b2012-12-05 21:24:42 +0000676 lldb::SBType
677 GetBasicType(lldb::BasicType type);
678
Jim Inghame37d6052011-09-13 00:29:56 +0000679 lldb::SBSourceManager
680 GetSourceManager ();
681
Johnny Chendc7d3c12011-07-16 21:15:39 +0000682 %feature("docstring", "
683 //------------------------------------------------------------------
684 /// Find global and static variables by name.
685 ///
686 /// @param[in] name
687 /// The name of the global or static variable we are looking
688 /// for.
689 ///
690 /// @param[in] max_matches
691 /// Allow the number of matches to be limited to \a max_matches.
692 ///
693 /// @return
694 /// A list of matched variables in an SBValueList.
695 //------------------------------------------------------------------
696 ") FindGlobalVariables;
697 lldb::SBValueList
698 FindGlobalVariables (const char *name,
699 uint32_t max_matches);
700
Enrico Granatabcd80b42013-01-16 18:53:52 +0000701 %feature("docstring", "
702 //------------------------------------------------------------------
703 /// Find the first global (or static) variable by name.
704 ///
705 /// @param[in] name
706 /// The name of the global or static variable we are looking
707 /// for.
708 ///
709 /// @return
710 /// An SBValue that gets filled in with the found variable (if any).
711 //------------------------------------------------------------------
712 ") FindFirstGlobalVariable;
713 lldb::SBValue
714 FindFirstGlobalVariable (const char* name);
715
Carlo Kokb77aba72014-09-19 20:12:24 +0000716
717 lldb::SBValueList
718 FindGlobalVariables(const char *name,
719 uint32_t max_matches,
720 MatchType matchtype);
721
722 lldb::SBSymbolContextList
723 FindGlobalFunctions(const char *name,
724 uint32_t max_matches,
725 MatchType matchtype);
726
Johnny Chendc7d3c12011-07-16 21:15:39 +0000727 void
728 Clear ();
729
Matthew Gardinerc928de32014-10-22 07:22:56 +0000730 %feature("docstring", "
731 //------------------------------------------------------------------
732 /// Resolve a current file address into a section offset address.
733 ///
734 /// @param[in] file_addr
735 ///
736 /// @return
737 /// An SBAddress which will be valid if...
738 //------------------------------------------------------------------
739 ") ResolveFileAddress;
740 lldb::SBAddress
741 ResolveFileAddress (lldb::addr_t file_addr);
742
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000743 lldb::SBAddress
744 ResolveLoadAddress (lldb::addr_t vm_addr);
Greg Claytond5944cd2013-12-06 01:12:00 +0000745
746 lldb::SBAddress
747 ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr);
Johnny Chendc7d3c12011-07-16 21:15:39 +0000748
749 SBSymbolContext
750 ResolveSymbolContextForAddress (const SBAddress& addr,
751 uint32_t resolve_scope);
752
Matthew Gardinerc928de32014-10-22 07:22:56 +0000753 %feature("docstring", "
754 //------------------------------------------------------------------
755 /// Read target memory. If a target process is running then memory
756 /// is read from here. Otherwise the memory is read from the object
757 /// files. For a target whose bytes are sized as a multiple of host
758 /// bytes, the data read back will preserve the target's byte order.
759 ///
760 /// @param[in] addr
761 /// A target address to read from.
762 ///
763 /// @param[out] buf
764 /// The buffer to read memory into.
765 ///
766 /// @param[in] size
767 /// The maximum number of host bytes to read in the buffer passed
768 /// into this call
769 ///
770 /// @param[out] error
771 /// Error information is written here if the memory read fails.
772 ///
773 /// @return
774 /// The amount of data read in host bytes.
775 //------------------------------------------------------------------
776 ") ReadMemory;
777 size_t
778 ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
779
Johnny Chendc7d3c12011-07-16 21:15:39 +0000780 lldb::SBBreakpoint
781 BreakpointCreateByLocation (const char *file, uint32_t line);
782
783 lldb::SBBreakpoint
784 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
785
786 lldb::SBBreakpoint
787 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
788
789 lldb::SBBreakpoint
Jim Ingham2dd7f7f2011-10-11 01:18:55 +0000790 BreakpointCreateByName (const char *symbol_name,
791 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
792 const SBFileSpecList &module_list,
793 const SBFileSpecList &comp_unit_list);
794
795 lldb::SBBreakpoint
Jim Inghamfab10e82012-03-06 00:37:27 +0000796 BreakpointCreateByNames (const char *symbol_name[],
797 uint32_t num_names,
798 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
799 const SBFileSpecList &module_list,
800 const SBFileSpecList &comp_unit_list);
801
802 lldb::SBBreakpoint
Johnny Chendc7d3c12011-07-16 21:15:39 +0000803 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
804
805 lldb::SBBreakpoint
Jim Ingham969795f2011-09-21 01:17:13 +0000806 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
807
808 lldb::SBBreakpoint
Jim Inghamfab10e82012-03-06 00:37:27 +0000809 BreakpointCreateForException (lldb::LanguageType language,
810 bool catch_bp,
811 bool throw_bp);
812
813 lldb::SBBreakpoint
Johnny Chendc7d3c12011-07-16 21:15:39 +0000814 BreakpointCreateByAddress (addr_t address);
815
816 uint32_t
817 GetNumBreakpoints () const;
818
819 lldb::SBBreakpoint
820 GetBreakpointAtIndex (uint32_t idx) const;
821
822 bool
823 BreakpointDelete (break_id_t break_id);
824
825 lldb::SBBreakpoint
826 FindBreakpointByID (break_id_t break_id);
827
828 bool
829 EnableAllBreakpoints ();
830
831 bool
832 DisableAllBreakpoints ();
833
834 bool
835 DeleteAllBreakpoints ();
836
Johnny Chend4dd7992011-09-27 01:19:20 +0000837 uint32_t
Greg Clayton1b282f92011-10-13 18:08:26 +0000838 GetNumWatchpoints () const;
839
840 lldb::SBWatchpoint
841 GetWatchpointAtIndex (uint32_t idx) const;
842
Johnny Chend4dd7992011-09-27 01:19:20 +0000843 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000844 DeleteWatchpoint (lldb::watch_id_t watch_id);
845
846 lldb::SBWatchpoint
847 FindWatchpointByID (lldb::watch_id_t watch_id);
848
Johnny Chend4dd7992011-09-27 01:19:20 +0000849 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000850 EnableAllWatchpoints ();
851
Johnny Chend4dd7992011-09-27 01:19:20 +0000852 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000853 DisableAllWatchpoints ();
854
Johnny Chend4dd7992011-09-27 01:19:20 +0000855 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000856 DeleteAllWatchpoints ();
857
858 lldb::SBWatchpoint
859 WatchAddress (lldb::addr_t addr,
860 size_t size,
861 bool read,
Johnny Chenb90827e2012-06-04 23:19:54 +0000862 bool write,
863 SBError &error);
Greg Clayton1b282f92011-10-13 18:08:26 +0000864
Johnny Chend4dd7992011-09-27 01:19:20 +0000865
Johnny Chendc7d3c12011-07-16 21:15:39 +0000866 lldb::SBBroadcaster
867 GetBroadcaster () const;
Enrico Granata347c2aa2013-10-08 21:49:02 +0000868
869 lldb::SBValue
870 CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
Jason Molendab2115cf2014-11-18 05:43:11 +0000871
872 %feature("docstring", "
873 Disassemble a specified number of instructions starting at an address.
874 Parameters:
875 base_addr -- the address to start disassembly from
876 count -- the number of instructions to disassemble
877 flavor_string -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly
878 Returns an SBInstructionList.")
879 ReadInstructions;
Sean Callanan50952e92011-12-14 23:49:37 +0000880 lldb::SBInstructionList
Greg Clayton9c766112012-03-06 22:24:44 +0000881 ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
882
883 lldb::SBInstructionList
Jim Ingham0f063ba2013-03-02 00:26:47 +0000884 ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
885
Jason Molendab2115cf2014-11-18 05:43:11 +0000886 %feature("docstring", "
887 Disassemble the bytes in a buffer and return them in an SBInstructionList.
888 Parameters:
889 base_addr -- used for symbolicating the offsets in the byte stream when disassembling
890 buf -- bytes to be disassembled
891 size -- (C++) size of the buffer
892 Returns an SBInstructionList.")
893 GetInstructions;
Jim Ingham0f063ba2013-03-02 00:26:47 +0000894 lldb::SBInstructionList
Sean Callanan50952e92011-12-14 23:49:37 +0000895 GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
Jason Molendab2115cf2014-11-18 05:43:11 +0000896
897 %feature("docstring", "
898 Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor.
899 Parameters:
900 base_addr -- used for symbolicating the offsets in the byte stream when disassembling
901 flavor -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly
902 buf -- bytes to be disassembled
903 size -- (C++) size of the buffer
904 Returns an SBInstructionList.")
905 GetInstructionsWithFlavor;
Jim Ingham0f063ba2013-03-02 00:26:47 +0000906 lldb::SBInstructionList
907 GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
908
Greg Claytone14e1922012-12-04 02:22:16 +0000909 lldb::SBSymbolContextList
910 FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
911
Johnny Chendc7d3c12011-07-16 21:15:39 +0000912 bool
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000913 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
Greg Clayton13d19502012-01-29 06:07:39 +0000914
Greg Clayton13fbb992013-02-01 00:47:49 +0000915 lldb::addr_t
916 GetStackRedZoneSize();
917
Enrico Granatac3387332013-05-03 01:29:27 +0000918 bool
919 operator == (const lldb::SBTarget &rhs) const;
920
921 bool
922 operator != (const lldb::SBTarget &rhs) const;
923
Greg Clayton4b63a5c2013-01-04 18:10:18 +0000924 lldb::SBValue
925 EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
Greg Clayton13d19502012-01-29 06:07:39 +0000926 %pythoncode %{
Greg Clayton6b2bd932012-02-01 08:09:32 +0000927 class modules_access(object):
928 '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
929 def __init__(self, sbtarget):
930 self.sbtarget = sbtarget
931
932 def __len__(self):
933 if self.sbtarget:
Filipe Cabecinhas1a96ef82012-05-11 20:39:42 +0000934 return int(self.sbtarget.GetNumModules())
Greg Clayton6b2bd932012-02-01 08:09:32 +0000935 return 0
936
937 def __getitem__(self, key):
938 num_modules = self.sbtarget.GetNumModules()
939 if type(key) is int:
940 if key < num_modules:
941 return self.sbtarget.GetModuleAtIndex(key)
942 elif type(key) is str:
943 if key.find('/') == -1:
944 for idx in range(num_modules):
945 module = self.sbtarget.GetModuleAtIndex(idx)
946 if module.file.basename == key:
947 return module
948 else:
949 for idx in range(num_modules):
950 module = self.sbtarget.GetModuleAtIndex(idx)
951 if module.file.fullpath == key:
952 return module
953 # See if the string is a UUID
Greg Clayton1fb7c622013-03-07 02:58:47 +0000954 try:
955 the_uuid = uuid.UUID(key)
956 if the_uuid:
957 for idx in range(num_modules):
958 module = self.sbtarget.GetModuleAtIndex(idx)
959 if module.uuid == the_uuid:
960 return module
961 except:
962 return None
Greg Clayton6b2bd932012-02-01 08:09:32 +0000963 elif type(key) is uuid.UUID:
964 for idx in range(num_modules):
965 module = self.sbtarget.GetModuleAtIndex(idx)
966 if module.uuid == key:
967 return module
968 elif type(key) is re.SRE_Pattern:
969 matching_modules = []
970 for idx in range(num_modules):
971 module = self.sbtarget.GetModuleAtIndex(idx)
972 re_match = key.search(module.path.fullpath)
973 if re_match:
974 matching_modules.append(module)
975 return matching_modules
976 else:
977 print "error: unsupported item type: %s" % type(key)
978 return None
979
980 def get_modules_access_object(self):
Greg Claytonb62bb8c2012-02-03 03:22:53 +0000981 '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.'''
Greg Clayton6b2bd932012-02-01 08:09:32 +0000982 return self.modules_access (self)
983
984 def get_modules_array(self):
Greg Claytonb62bb8c2012-02-03 03:22:53 +0000985 '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
Greg Clayton6b2bd932012-02-01 08:09:32 +0000986 modules = []
987 for idx in range(self.GetNumModules()):
988 modules.append(self.GetModuleAtIndex(idx))
989 return modules
990
991 __swig_getmethods__["modules"] = get_modules_array
Greg Clayton5ef31a92012-06-29 22:00:42 +0000992 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 Clayton6b2bd932012-02-01 08:09:32 +0000993
994 __swig_getmethods__["module"] = get_modules_access_object
Greg Clayton5ef31a92012-06-29 22:00:42 +0000995 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 Clayton6b2bd932012-02-01 08:09:32 +0000996
Greg Clayton13d19502012-01-29 06:07:39 +0000997 __swig_getmethods__["process"] = GetProcess
Greg Clayton5ef31a92012-06-29 22:00:42 +0000998 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 Clayton13d19502012-01-29 06:07:39 +0000999
1000 __swig_getmethods__["executable"] = GetExecutable
Greg Clayton5ef31a92012-06-29 22:00:42 +00001001 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 Clayton13d19502012-01-29 06:07:39 +00001002
1003 __swig_getmethods__["debugger"] = GetDebugger
Greg Clayton5ef31a92012-06-29 22:00:42 +00001004 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 Clayton13d19502012-01-29 06:07:39 +00001005
Greg Clayton13d19502012-01-29 06:07:39 +00001006 __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints
Greg Clayton5ef31a92012-06-29 22:00:42 +00001007 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 Clayton13d19502012-01-29 06:07:39 +00001008
1009 __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints
Greg Clayton5ef31a92012-06-29 22:00:42 +00001010 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 Clayton13d19502012-01-29 06:07:39 +00001011
1012 __swig_getmethods__["broadcaster"] = GetBroadcaster
Greg Clayton5ef31a92012-06-29 22:00:42 +00001013 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 Clayton13d19502012-01-29 06:07:39 +00001014
1015 __swig_getmethods__["byte_order"] = GetByteOrder
Greg Clayton5ef31a92012-06-29 22:00:42 +00001016 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 Clayton13d19502012-01-29 06:07:39 +00001017
1018 __swig_getmethods__["addr_size"] = GetAddressByteSize
Greg Clayton5ef31a92012-06-29 22:00:42 +00001019 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 Clayton13d19502012-01-29 06:07:39 +00001020
1021 __swig_getmethods__["triple"] = GetTriple
Greg Clayton5ef31a92012-06-29 22:00:42 +00001022 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.''')
Matthew Gardinerc928de32014-10-22 07:22:56 +00001023
1024 __swig_getmethods__["data_byte_size"] = GetDataByteSize
Enrico Granatad72ffc62014-11-13 01:38:38 +00001025 if _newclass: data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''')
Matthew Gardinerc928de32014-10-22 07:22:56 +00001026
1027 __swig_getmethods__["code_byte_size"] = GetCodeByteSize
Enrico Granatad72ffc62014-11-13 01:38:38 +00001028 if _newclass: code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''')
Matthew Gardinerc928de32014-10-22 07:22:56 +00001029
1030 __swig_getmethods__["platform"] = GetPlatform
1031 if _newclass: platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''')
Greg Clayton13d19502012-01-29 06:07:39 +00001032 %}
1033
Johnny Chendc7d3c12011-07-16 21:15:39 +00001034};
1035
1036} // namespace lldb