blob: 7a0096c41e362a065eae7727d6895aec39ebabb0 [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 Clayton0e615682012-02-24 05:03:03 +000041 uint32_t
42 GetNumArguments ();
43
44 const char *
45 GetArgumentAtIndex (uint32_t idx);
46
47 void
48 SetArguments (const char **argv, bool append);
49
50 uint32_t
51 GetNumEnvironmentEntries ();
52
53 const char *
54 GetEnvironmentEntryAtIndex (uint32_t idx);
55
56 void
57 SetEnvironmentEntries (const char **envp, bool append);
58
59 void
60 Clear ();
61
62 const char *
63 GetWorkingDirectory () const;
64
65 void
66 SetWorkingDirectory (const char *working_dir);
67
68 uint32_t
69 GetLaunchFlags ();
70
71 void
72 SetLaunchFlags (uint32_t flags);
73
74 const char *
75 GetProcessPluginName ();
76
77 void
78 SetProcessPluginName (const char *plugin_name);
79
80 const char *
81 GetShell ();
82
83 void
84 SetShell (const char * path);
85
86 uint32_t
87 GetResumeCount ();
88
89 void
90 SetResumeCount (uint32_t c);
91
92 bool
93 AddCloseFileAction (int fd);
94
95 bool
96 AddDuplicateFileAction (int fd, int dup_fd);
97
98 bool
99 AddOpenFileAction (int fd, const char *path, bool read, bool write);
100
101 bool
102 AddSuppressFileAction (int fd, bool read, bool write);
Jason Molendaa3329782014-03-29 18:54:20 +0000103
104 void
105 SetLaunchEventData (const char *data);
106
107 const char *
108 GetLaunchEventData () const;
109
Jim Ingham106d0282014-06-25 02:32:56 +0000110 bool
111 GetDetachOnError() const;
112
113 void
114 SetDetachOnError(bool enable);
Greg Clayton0e615682012-02-24 05:03:03 +0000115};
116
117class SBAttachInfo
118{
119public:
120 SBAttachInfo ();
121
122 SBAttachInfo (lldb::pid_t pid);
123
124 SBAttachInfo (const char *path, bool wait_for);
125
126 SBAttachInfo (const lldb::SBAttachInfo &rhs);
127
128 lldb::pid_t
129 GetProcessID ();
130
131 void
132 SetProcessID (lldb::pid_t pid);
133
134 void
135 SetExecutable (const char *path);
136
137 void
138 SetExecutable (lldb::SBFileSpec exe_file);
139
140 bool
141 GetWaitForLaunch ();
142
143 void
144 SetWaitForLaunch (bool b);
145
Jim Inghamcd16df92012-07-20 21:37:13 +0000146 bool
147 GetIgnoreExisting ();
148
149 void
150 SetIgnoreExisting (bool b);
151
Greg Clayton0e615682012-02-24 05:03:03 +0000152 uint32_t
153 GetResumeCount ();
154
155 void
156 SetResumeCount (uint32_t c);
157
158 const char *
159 GetProcessPluginName ();
160
161 void
162 SetProcessPluginName (const char *plugin_name);
163
164 uint32_t
Greg Clayton41bd8ac2012-02-24 23:56:06 +0000165 GetUserID();
166
167 uint32_t
168 GetGroupID();
169
170 bool
171 UserIDIsValid ();
172
173 bool
174 GroupIDIsValid ();
175
176 void
177 SetUserID (uint32_t uid);
178
179 void
180 SetGroupID (uint32_t gid);
181
182 uint32_t
Greg Clayton0e615682012-02-24 05:03:03 +0000183 GetEffectiveUserID();
184
185 uint32_t
186 GetEffectiveGroupID();
187
188 bool
189 EffectiveUserIDIsValid ();
190
191 bool
192 EffectiveGroupIDIsValid ();
193
194 void
195 SetEffectiveUserID (uint32_t uid);
196
197 void
198 SetEffectiveGroupID (uint32_t gid);
199
200 lldb::pid_t
201 GetParentProcessID ();
202
203 void
204 SetParentProcessID (lldb::pid_t pid);
205
206 bool
207 ParentProcessIDIsValid();
208};
209
210
Johnny Chendc7d3c12011-07-16 21:15:39 +0000211%feature("docstring",
212"Represents the target program running under the debugger.
213
Johnny Chen01a67862011-10-14 00:42:25 +0000214SBTarget supports module, breakpoint, and watchpoint iterations. For example,
Johnny Chendc7d3c12011-07-16 21:15:39 +0000215
216 for m in target.module_iter():
217 print m
218
219produces:
220
221(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
222(x86_64) /usr/lib/dyld
223(x86_64) /usr/lib/libstdc++.6.dylib
224(x86_64) /usr/lib/libSystem.B.dylib
225(x86_64) /usr/lib/system/libmathCommon.A.dylib
226(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
227
228and,
229
230 for b in target.breakpoint_iter():
231 print b
232
233produces:
234
235SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
Johnny Chend4dd7992011-09-27 01:19:20 +0000236SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
237
238and,
239
Johnny Chen01a67862011-10-14 00:42:25 +0000240 for wp_loc in target.watchpoint_iter():
Johnny Chend4dd7992011-09-27 01:19:20 +0000241 print wp_loc
242
243produces:
244
Johnny Chen01a67862011-10-14 00:42:25 +0000245Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
Johnny Chend4dd7992011-09-27 01:19:20 +0000246 declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
Johnny Chen01a67862011-10-14 00:42:25 +0000247 hw_index = 0 hit_count = 2 ignore_count = 0"
Johnny Chen357033b2011-07-18 20:13:38 +0000248) SBTarget;
Johnny Chendc7d3c12011-07-16 21:15:39 +0000249class SBTarget
250{
Johnny Chendc7d3c12011-07-16 21:15:39 +0000251public:
252 //------------------------------------------------------------------
253 // Broadcaster bits.
254 //------------------------------------------------------------------
255 enum
256 {
257 eBroadcastBitBreakpointChanged = (1 << 0),
258 eBroadcastBitModulesLoaded = (1 << 1),
Jim Ingham1b5792e2012-12-18 02:03:49 +0000259 eBroadcastBitModulesUnloaded = (1 << 2),
Enrico Granataf15ee4e2013-04-05 18:49:06 +0000260 eBroadcastBitWatchpointChanged = (1 << 3),
261 eBroadcastBitSymbolsLoaded = (1 << 4)
Johnny Chendc7d3c12011-07-16 21:15:39 +0000262 };
263
264 //------------------------------------------------------------------
265 // Constructors
266 //------------------------------------------------------------------
267 SBTarget ();
268
269 SBTarget (const lldb::SBTarget& rhs);
270
Johnny Chendc7d3c12011-07-16 21:15:39 +0000271 //------------------------------------------------------------------
272 // Destructor
273 //------------------------------------------------------------------
274 ~SBTarget();
275
Jim Ingham4bddaeb2012-02-16 06:50:00 +0000276 static const char *
277 GetBroadcasterClassName ();
278
Johnny Chendc7d3c12011-07-16 21:15:39 +0000279 bool
280 IsValid() const;
281
282 lldb::SBProcess
283 GetProcess ();
284
Matthew Gardinerc928de32014-10-22 07:22:56 +0000285
286 %feature("docstring", "
287 //------------------------------------------------------------------
288 /// Return the platform object associated with the target.
289 ///
290 /// After return, the platform object should be checked for
291 /// validity.
292 ///
293 /// @return
294 /// A platform object.
295 //------------------------------------------------------------------
296 ") GetPlatform;
297 lldb::SBPlatform
298 GetPlatform ();
299
Johnny Chendc7d3c12011-07-16 21:15:39 +0000300 %feature("docstring", "
301 //------------------------------------------------------------------
Greg Claytonfbb76342013-11-20 21:07:01 +0000302 /// Install any binaries that need to be installed.
303 ///
304 /// This function does nothing when debugging on the host system.
305 /// When connected to remote platforms, the target's main executable
306 /// and any modules that have their install path set will be
307 /// installed on the remote platform. If the main executable doesn't
308 /// have an install location set, it will be installed in the remote
309 /// platform's working directory.
310 ///
311 /// @return
312 /// An error describing anything that went wrong during
313 /// installation.
314 //------------------------------------------------------------------
315 ") Install;
316 lldb::SBError
317 Install();
318
319 %feature("docstring", "
320 //------------------------------------------------------------------
Johnny Chendc7d3c12011-07-16 21:15:39 +0000321 /// Launch a new process.
322 ///
323 /// Launch a new process by spawning a new process using the
324 /// target object's executable module's file as the file to launch.
325 /// Arguments are given in \a argv, and the environment variables
326 /// are in \a envp. Standard input and output files can be
327 /// optionally re-directed to \a stdin_path, \a stdout_path, and
328 /// \a stderr_path.
329 ///
330 /// @param[in] listener
331 /// An optional listener that will receive all process events.
332 /// If \a listener is valid then \a listener will listen to all
333 /// process events. If not valid, then this target's debugger
334 /// (SBTarget::GetDebugger()) will listen to all process events.
335 ///
336 /// @param[in] argv
337 /// The argument array.
338 ///
339 /// @param[in] envp
340 /// The environment array.
341 ///
342 /// @param[in] launch_flags
343 /// Flags to modify the launch (@see lldb::LaunchFlags)
344 ///
345 /// @param[in] stdin_path
346 /// The path to use when re-directing the STDIN of the new
347 /// process. If all stdXX_path arguments are NULL, a pseudo
348 /// terminal will be used.
349 ///
350 /// @param[in] stdout_path
351 /// The path to use when re-directing the STDOUT of the new
352 /// process. If all stdXX_path arguments are NULL, a pseudo
353 /// terminal will be used.
354 ///
355 /// @param[in] stderr_path
356 /// The path to use when re-directing the STDERR of the new
357 /// process. If all stdXX_path arguments are NULL, a pseudo
358 /// terminal will be used.
359 ///
360 /// @param[in] working_directory
361 /// The working directory to have the child process run in
362 ///
363 /// @param[in] launch_flags
364 /// Some launch options specified by logical OR'ing
365 /// lldb::LaunchFlags enumeration values together.
366 ///
367 /// @param[in] stop_at_endtry
368 /// If false do not stop the inferior at the entry point.
369 ///
370 /// @param[out]
371 /// An error object. Contains the reason if there is some failure.
372 ///
373 /// @return
374 /// A process object for the newly created process.
375 //------------------------------------------------------------------
376
377 For example,
378
379 process = target.Launch(self.dbg.GetListener(), None, None,
380 None, '/tmp/stdout.txt', None,
381 None, 0, False, error)
382
383 launches a new process by passing nothing for both the args and the envs
384 and redirect the standard output of the inferior to the /tmp/stdout.txt
385 file. It does not specify a working directory so that the debug server
386 will use its idea of what the current working directory is for the
387 inferior. Also, we ask the debugger not to stop the inferior at the
388 entry point. If no breakpoint is specified for the inferior, it should
389 run to completion if no user interaction is required.
390 ") Launch;
391 lldb::SBProcess
392 Launch (SBListener &listener,
393 char const **argv,
394 char const **envp,
395 const char *stdin_path,
396 const char *stdout_path,
397 const char *stderr_path,
398 const char *working_directory,
399 uint32_t launch_flags, // See LaunchFlags
400 bool stop_at_entry,
401 lldb::SBError& error);
402
403 %feature("docstring", "
404 //------------------------------------------------------------------
405 /// Launch a new process with sensible defaults.
406 ///
407 /// @param[in] argv
408 /// The argument array.
409 ///
410 /// @param[in] envp
411 /// The environment array.
412 ///
413 /// @param[in] working_directory
414 /// The working directory to have the child process run in
415 ///
416 /// Default: listener
417 /// Set to the target's debugger (SBTarget::GetDebugger())
418 ///
419 /// Default: launch_flags
420 /// Empty launch flags
421 ///
422 /// Default: stdin_path
423 /// Default: stdout_path
424 /// Default: stderr_path
425 /// A pseudo terminal will be used.
426 ///
427 /// @return
428 /// A process object for the newly created process.
429 //------------------------------------------------------------------
430
431 For example,
432
433 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
434
435 launches a new process by passing 'X', 'Y', 'Z' as the args to the
436 executable.
437 ") LaunchSimple;
438 lldb::SBProcess
439 LaunchSimple (const char **argv,
440 const char **envp,
441 const char *working_directory);
442
Greg Clayton0e615682012-02-24 05:03:03 +0000443 lldb::SBProcess
444 Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
Greg Clayton4d8ad552013-03-25 22:40:51 +0000445
446 %feature("docstring", "
447 //------------------------------------------------------------------
448 /// Load a core file
449 ///
450 /// @param[in] core_file
451 /// File path of the core dump.
452 ///
453 /// @return
454 /// A process object for the newly created core file.
455 //------------------------------------------------------------------
456
457 For example,
458
459 process = target.LoadCore('./a.out.core')
460
461 loads a new core file and returns the process object.
462 ") LoadCore;
463 lldb::SBProcess
464 LoadCore(const char *core_file);
Greg Clayton0e615682012-02-24 05:03:03 +0000465
466 lldb::SBProcess
467 Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error);
468
469
Johnny Chendc7d3c12011-07-16 21:15:39 +0000470 %feature("docstring", "
471 //------------------------------------------------------------------
472 /// Attach to process with pid.
473 ///
474 /// @param[in] listener
475 /// An optional listener that will receive all process events.
476 /// If \a listener is valid then \a listener will listen to all
477 /// process events. If not valid, then this target's debugger
478 /// (SBTarget::GetDebugger()) will listen to all process events.
479 ///
480 /// @param[in] pid
481 /// The process ID to attach to.
482 ///
483 /// @param[out]
484 /// An error explaining what went wrong if attach fails.
485 ///
486 /// @return
487 /// A process object for the attached process.
488 //------------------------------------------------------------------
489 ") AttachToProcessWithID;
490 lldb::SBProcess
491 AttachToProcessWithID (SBListener &listener,
492 lldb::pid_t pid,
493 lldb::SBError& error);
494
495 %feature("docstring", "
496 //------------------------------------------------------------------
497 /// Attach to process with name.
498 ///
499 /// @param[in] listener
500 /// An optional listener that will receive all process events.
501 /// If \a listener is valid then \a listener will listen to all
502 /// process events. If not valid, then this target's debugger
503 /// (SBTarget::GetDebugger()) will listen to all process events.
504 ///
505 /// @param[in] name
506 /// Basename of process to attach to.
507 ///
508 /// @param[in] wait_for
509 /// If true wait for a new instance of 'name' to be launched.
510 ///
511 /// @param[out]
512 /// An error explaining what went wrong if attach fails.
513 ///
514 /// @return
515 /// A process object for the attached process.
516 //------------------------------------------------------------------
517 ") AttachToProcessWithName;
518 lldb::SBProcess
519 AttachToProcessWithName (SBListener &listener,
520 const char *name,
521 bool wait_for,
522 lldb::SBError& error);
523
524 %feature("docstring", "
525 //------------------------------------------------------------------
526 /// Connect to a remote debug server with url.
527 ///
528 /// @param[in] listener
529 /// An optional listener that will receive all process events.
530 /// If \a listener is valid then \a listener will listen to all
531 /// process events. If not valid, then this target's debugger
532 /// (SBTarget::GetDebugger()) will listen to all process events.
533 ///
534 /// @param[in] url
535 /// The url to connect to, e.g., 'connect://localhost:12345'.
536 ///
537 /// @param[in] plugin_name
538 /// The plugin name to be used; can be NULL.
539 ///
540 /// @param[out]
541 /// An error explaining what went wrong if the connect fails.
542 ///
543 /// @return
544 /// A process object for the connected process.
545 //------------------------------------------------------------------
546 ") ConnectRemote;
547 lldb::SBProcess
548 ConnectRemote (SBListener &listener,
549 const char *url,
550 const char *plugin_name,
551 SBError& error);
552
553 lldb::SBFileSpec
554 GetExecutable ();
555
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000556 bool
557 AddModule (lldb::SBModule &module);
558
559 lldb::SBModule
560 AddModule (const char *path,
561 const char *triple,
562 const char *uuid);
563
Greg Claytonb210aec2012-04-23 20:23:39 +0000564 lldb::SBModule
565 AddModule (const char *path,
566 const char *triple,
567 const char *uuid_cstr,
568 const char *symfile);
569
Greg Clayton226cce22013-07-08 22:22:41 +0000570 lldb::SBModule
571 AddModule (const SBModuleSpec &module_spec);
572
Johnny Chendc7d3c12011-07-16 21:15:39 +0000573 uint32_t
574 GetNumModules () const;
575
576 lldb::SBModule
577 GetModuleAtIndex (uint32_t idx);
578
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000579 bool
580 RemoveModule (lldb::SBModule module);
581
Johnny Chendc7d3c12011-07-16 21:15:39 +0000582 lldb::SBDebugger
583 GetDebugger() const;
584
585 lldb::SBModule
586 FindModule (const lldb::SBFileSpec &file_spec);
587
Greg Clayton13d19502012-01-29 06:07:39 +0000588 lldb::ByteOrder
589 GetByteOrder ();
590
591 uint32_t
592 GetAddressByteSize();
593
594 const char *
595 GetTriple ();
596
Matthew Gardinerc928de32014-10-22 07:22:56 +0000597 %feature("docstring", "
598 //------------------------------------------------------------------
599 /// Architecture data byte width accessor
600 ///
601 /// @return
602 /// The size in 8-bit (host) bytes of a minimum addressable
603 /// unit from the Architecture's data bus
604 //------------------------------------------------------------------
605 ") GetDataByteSize;
606 uint32_t
607 GetDataByteSize ();
608
609 %feature("docstring", "
610 //------------------------------------------------------------------
611 /// Architecture code byte width accessor
612 ///
613 /// @return
614 /// The size in 8-bit (host) bytes of a minimum addressable
615 /// unit from the Architecture's code bus
616 //------------------------------------------------------------------
617 ") GetCodeByteSize;
618 uint32_t
619 GetCodeByteSize ();
620
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000621 lldb::SBError
622 SetSectionLoadAddress (lldb::SBSection section,
623 lldb::addr_t section_base_addr);
624
625 lldb::SBError
626 ClearSectionLoadAddress (lldb::SBSection section);
627
628 lldb::SBError
629 SetModuleLoadAddress (lldb::SBModule module,
630 int64_t sections_offset);
631
632 lldb::SBError
633 ClearModuleLoadAddress (lldb::SBModule module);
634
Johnny Chendc7d3c12011-07-16 21:15:39 +0000635 %feature("docstring", "
636 //------------------------------------------------------------------
637 /// Find functions by name.
638 ///
639 /// @param[in] name
640 /// The name of the function we are looking for.
641 ///
642 /// @param[in] name_type_mask
643 /// A logical OR of one or more FunctionNameType enum bits that
644 /// indicate what kind of names should be used when doing the
645 /// lookup. Bits include fully qualified names, base names,
646 /// C++ methods, or ObjC selectors.
647 /// See FunctionNameType for more details.
648 ///
Johnny Chendc7d3c12011-07-16 21:15:39 +0000649 /// @return
Greg Clayton5569e642012-02-06 01:44:54 +0000650 /// A lldb::SBSymbolContextList that gets filled in with all of
651 /// the symbol contexts for all the matches.
Johnny Chendc7d3c12011-07-16 21:15:39 +0000652 //------------------------------------------------------------------
653 ") FindFunctions;
Greg Clayton5569e642012-02-06 01:44:54 +0000654 lldb::SBSymbolContextList
Johnny Chendc7d3c12011-07-16 21:15:39 +0000655 FindFunctions (const char *name,
Greg Clayton5569e642012-02-06 01:44:54 +0000656 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000657
658 lldb::SBType
659 FindFirstType (const char* type);
660
661 lldb::SBTypeList
662 FindTypes (const char* type);
Johnny Chendc7d3c12011-07-16 21:15:39 +0000663
Greg Claytonb43165b2012-12-05 21:24:42 +0000664 lldb::SBType
665 GetBasicType(lldb::BasicType type);
666
Jim Inghame37d6052011-09-13 00:29:56 +0000667 lldb::SBSourceManager
668 GetSourceManager ();
669
Johnny Chendc7d3c12011-07-16 21:15:39 +0000670 %feature("docstring", "
671 //------------------------------------------------------------------
672 /// Find global and static variables by name.
673 ///
674 /// @param[in] name
675 /// The name of the global or static variable we are looking
676 /// for.
677 ///
678 /// @param[in] max_matches
679 /// Allow the number of matches to be limited to \a max_matches.
680 ///
681 /// @return
682 /// A list of matched variables in an SBValueList.
683 //------------------------------------------------------------------
684 ") FindGlobalVariables;
685 lldb::SBValueList
686 FindGlobalVariables (const char *name,
687 uint32_t max_matches);
688
Enrico Granatabcd80b42013-01-16 18:53:52 +0000689 %feature("docstring", "
690 //------------------------------------------------------------------
691 /// Find the first global (or static) variable by name.
692 ///
693 /// @param[in] name
694 /// The name of the global or static variable we are looking
695 /// for.
696 ///
697 /// @return
698 /// An SBValue that gets filled in with the found variable (if any).
699 //------------------------------------------------------------------
700 ") FindFirstGlobalVariable;
701 lldb::SBValue
702 FindFirstGlobalVariable (const char* name);
703
Carlo Kokb77aba72014-09-19 20:12:24 +0000704
705 lldb::SBValueList
706 FindGlobalVariables(const char *name,
707 uint32_t max_matches,
708 MatchType matchtype);
709
710 lldb::SBSymbolContextList
711 FindGlobalFunctions(const char *name,
712 uint32_t max_matches,
713 MatchType matchtype);
714
Johnny Chendc7d3c12011-07-16 21:15:39 +0000715 void
716 Clear ();
717
Matthew Gardinerc928de32014-10-22 07:22:56 +0000718 %feature("docstring", "
719 //------------------------------------------------------------------
720 /// Resolve a current file address into a section offset address.
721 ///
722 /// @param[in] file_addr
723 ///
724 /// @return
725 /// An SBAddress which will be valid if...
726 //------------------------------------------------------------------
727 ") ResolveFileAddress;
728 lldb::SBAddress
729 ResolveFileAddress (lldb::addr_t file_addr);
730
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000731 lldb::SBAddress
732 ResolveLoadAddress (lldb::addr_t vm_addr);
Greg Claytond5944cd2013-12-06 01:12:00 +0000733
734 lldb::SBAddress
735 ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr);
Johnny Chendc7d3c12011-07-16 21:15:39 +0000736
737 SBSymbolContext
738 ResolveSymbolContextForAddress (const SBAddress& addr,
739 uint32_t resolve_scope);
740
Matthew Gardinerc928de32014-10-22 07:22:56 +0000741 %feature("docstring", "
742 //------------------------------------------------------------------
743 /// Read target memory. If a target process is running then memory
744 /// is read from here. Otherwise the memory is read from the object
745 /// files. For a target whose bytes are sized as a multiple of host
746 /// bytes, the data read back will preserve the target's byte order.
747 ///
748 /// @param[in] addr
749 /// A target address to read from.
750 ///
751 /// @param[out] buf
752 /// The buffer to read memory into.
753 ///
754 /// @param[in] size
755 /// The maximum number of host bytes to read in the buffer passed
756 /// into this call
757 ///
758 /// @param[out] error
759 /// Error information is written here if the memory read fails.
760 ///
761 /// @return
762 /// The amount of data read in host bytes.
763 //------------------------------------------------------------------
764 ") ReadMemory;
765 size_t
766 ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
767
Johnny Chendc7d3c12011-07-16 21:15:39 +0000768 lldb::SBBreakpoint
769 BreakpointCreateByLocation (const char *file, uint32_t line);
770
771 lldb::SBBreakpoint
772 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
773
774 lldb::SBBreakpoint
775 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
776
777 lldb::SBBreakpoint
Jim Ingham2dd7f7f2011-10-11 01:18:55 +0000778 BreakpointCreateByName (const char *symbol_name,
779 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
780 const SBFileSpecList &module_list,
781 const SBFileSpecList &comp_unit_list);
782
783 lldb::SBBreakpoint
Jim Inghamfab10e82012-03-06 00:37:27 +0000784 BreakpointCreateByNames (const char *symbol_name[],
785 uint32_t num_names,
786 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
787 const SBFileSpecList &module_list,
788 const SBFileSpecList &comp_unit_list);
789
790 lldb::SBBreakpoint
Johnny Chendc7d3c12011-07-16 21:15:39 +0000791 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
792
793 lldb::SBBreakpoint
Jim Ingham969795f2011-09-21 01:17:13 +0000794 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
795
796 lldb::SBBreakpoint
Jim Inghamfab10e82012-03-06 00:37:27 +0000797 BreakpointCreateForException (lldb::LanguageType language,
798 bool catch_bp,
799 bool throw_bp);
800
801 lldb::SBBreakpoint
Johnny Chendc7d3c12011-07-16 21:15:39 +0000802 BreakpointCreateByAddress (addr_t address);
803
804 uint32_t
805 GetNumBreakpoints () const;
806
807 lldb::SBBreakpoint
808 GetBreakpointAtIndex (uint32_t idx) const;
809
810 bool
811 BreakpointDelete (break_id_t break_id);
812
813 lldb::SBBreakpoint
814 FindBreakpointByID (break_id_t break_id);
815
816 bool
817 EnableAllBreakpoints ();
818
819 bool
820 DisableAllBreakpoints ();
821
822 bool
823 DeleteAllBreakpoints ();
824
Johnny Chend4dd7992011-09-27 01:19:20 +0000825 uint32_t
Greg Clayton1b282f92011-10-13 18:08:26 +0000826 GetNumWatchpoints () const;
827
828 lldb::SBWatchpoint
829 GetWatchpointAtIndex (uint32_t idx) const;
830
Johnny Chend4dd7992011-09-27 01:19:20 +0000831 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000832 DeleteWatchpoint (lldb::watch_id_t watch_id);
833
834 lldb::SBWatchpoint
835 FindWatchpointByID (lldb::watch_id_t watch_id);
836
Johnny Chend4dd7992011-09-27 01:19:20 +0000837 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000838 EnableAllWatchpoints ();
839
Johnny Chend4dd7992011-09-27 01:19:20 +0000840 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000841 DisableAllWatchpoints ();
842
Johnny Chend4dd7992011-09-27 01:19:20 +0000843 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000844 DeleteAllWatchpoints ();
845
846 lldb::SBWatchpoint
847 WatchAddress (lldb::addr_t addr,
848 size_t size,
849 bool read,
Johnny Chenb90827e2012-06-04 23:19:54 +0000850 bool write,
851 SBError &error);
Greg Clayton1b282f92011-10-13 18:08:26 +0000852
Johnny Chend4dd7992011-09-27 01:19:20 +0000853
Johnny Chendc7d3c12011-07-16 21:15:39 +0000854 lldb::SBBroadcaster
855 GetBroadcaster () const;
Enrico Granata347c2aa2013-10-08 21:49:02 +0000856
857 lldb::SBValue
858 CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
Sean Callanan50952e92011-12-14 23:49:37 +0000859
860 lldb::SBInstructionList
Greg Clayton9c766112012-03-06 22:24:44 +0000861 ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
862
863 lldb::SBInstructionList
Jim Ingham0f063ba2013-03-02 00:26:47 +0000864 ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
865
866 lldb::SBInstructionList
Sean Callanan50952e92011-12-14 23:49:37 +0000867 GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
868
Jim Ingham0f063ba2013-03-02 00:26:47 +0000869 lldb::SBInstructionList
870 GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
871
Greg Claytone14e1922012-12-04 02:22:16 +0000872 lldb::SBSymbolContextList
873 FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
874
Johnny Chendc7d3c12011-07-16 21:15:39 +0000875 bool
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000876 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
Greg Clayton13d19502012-01-29 06:07:39 +0000877
Greg Clayton13fbb992013-02-01 00:47:49 +0000878 lldb::addr_t
879 GetStackRedZoneSize();
880
Enrico Granatac3387332013-05-03 01:29:27 +0000881 bool
882 operator == (const lldb::SBTarget &rhs) const;
883
884 bool
885 operator != (const lldb::SBTarget &rhs) const;
886
Greg Clayton4b63a5c2013-01-04 18:10:18 +0000887 lldb::SBValue
888 EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
Greg Clayton13d19502012-01-29 06:07:39 +0000889 %pythoncode %{
Greg Clayton6b2bd932012-02-01 08:09:32 +0000890 class modules_access(object):
891 '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
892 def __init__(self, sbtarget):
893 self.sbtarget = sbtarget
894
895 def __len__(self):
896 if self.sbtarget:
Filipe Cabecinhas1a96ef82012-05-11 20:39:42 +0000897 return int(self.sbtarget.GetNumModules())
Greg Clayton6b2bd932012-02-01 08:09:32 +0000898 return 0
899
900 def __getitem__(self, key):
901 num_modules = self.sbtarget.GetNumModules()
902 if type(key) is int:
903 if key < num_modules:
904 return self.sbtarget.GetModuleAtIndex(key)
905 elif type(key) is str:
906 if key.find('/') == -1:
907 for idx in range(num_modules):
908 module = self.sbtarget.GetModuleAtIndex(idx)
909 if module.file.basename == key:
910 return module
911 else:
912 for idx in range(num_modules):
913 module = self.sbtarget.GetModuleAtIndex(idx)
914 if module.file.fullpath == key:
915 return module
916 # See if the string is a UUID
Greg Clayton1fb7c622013-03-07 02:58:47 +0000917 try:
918 the_uuid = uuid.UUID(key)
919 if the_uuid:
920 for idx in range(num_modules):
921 module = self.sbtarget.GetModuleAtIndex(idx)
922 if module.uuid == the_uuid:
923 return module
924 except:
925 return None
Greg Clayton6b2bd932012-02-01 08:09:32 +0000926 elif type(key) is uuid.UUID:
927 for idx in range(num_modules):
928 module = self.sbtarget.GetModuleAtIndex(idx)
929 if module.uuid == key:
930 return module
931 elif type(key) is re.SRE_Pattern:
932 matching_modules = []
933 for idx in range(num_modules):
934 module = self.sbtarget.GetModuleAtIndex(idx)
935 re_match = key.search(module.path.fullpath)
936 if re_match:
937 matching_modules.append(module)
938 return matching_modules
939 else:
940 print "error: unsupported item type: %s" % type(key)
941 return None
942
943 def get_modules_access_object(self):
Greg Claytonb62bb8c2012-02-03 03:22:53 +0000944 '''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 +0000945 return self.modules_access (self)
946
947 def get_modules_array(self):
Greg Claytonb62bb8c2012-02-03 03:22:53 +0000948 '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
Greg Clayton6b2bd932012-02-01 08:09:32 +0000949 modules = []
950 for idx in range(self.GetNumModules()):
951 modules.append(self.GetModuleAtIndex(idx))
952 return modules
953
954 __swig_getmethods__["modules"] = get_modules_array
Greg Clayton5ef31a92012-06-29 22:00:42 +0000955 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 +0000956
957 __swig_getmethods__["module"] = get_modules_access_object
Greg Clayton5ef31a92012-06-29 22:00:42 +0000958 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 +0000959
Greg Clayton13d19502012-01-29 06:07:39 +0000960 __swig_getmethods__["process"] = GetProcess
Greg Clayton5ef31a92012-06-29 22:00:42 +0000961 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 +0000962
963 __swig_getmethods__["executable"] = GetExecutable
Greg Clayton5ef31a92012-06-29 22:00:42 +0000964 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 +0000965
966 __swig_getmethods__["debugger"] = GetDebugger
Greg Clayton5ef31a92012-06-29 22:00:42 +0000967 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 +0000968
Greg Clayton13d19502012-01-29 06:07:39 +0000969 __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints
Greg Clayton5ef31a92012-06-29 22:00:42 +0000970 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 +0000971
972 __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints
Greg Clayton5ef31a92012-06-29 22:00:42 +0000973 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 +0000974
975 __swig_getmethods__["broadcaster"] = GetBroadcaster
Greg Clayton5ef31a92012-06-29 22:00:42 +0000976 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 +0000977
978 __swig_getmethods__["byte_order"] = GetByteOrder
Greg Clayton5ef31a92012-06-29 22:00:42 +0000979 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 +0000980
981 __swig_getmethods__["addr_size"] = GetAddressByteSize
Greg Clayton5ef31a92012-06-29 22:00:42 +0000982 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 +0000983
984 __swig_getmethods__["triple"] = GetTriple
Greg Clayton5ef31a92012-06-29 22:00:42 +0000985 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 +0000986
987 __swig_getmethods__["data_byte_size"] = GetDataByteSize
988 if _newclass: addr_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.''')
989
990 __swig_getmethods__["code_byte_size"] = GetCodeByteSize
991 if _newclass: addr_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.''')
992
993 __swig_getmethods__["platform"] = GetPlatform
994 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 +0000995 %}
996
Johnny Chendc7d3c12011-07-16 21:15:39 +0000997};
998
999} // namespace lldb