blob: e7dba2a7a00c441daefc283eaf07848a6116b8a6 [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 Clayton0e615682012-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 Inghamcd16df92012-07-20 21:37:13 +0000128 bool
129 GetIgnoreExisting ();
130
131 void
132 SetIgnoreExisting (bool b);
133
Greg Clayton0e615682012-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 Clayton41bd8ac2012-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 Clayton0e615682012-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 Chendc7d3c12011-07-16 21:15:39 +0000193%feature("docstring",
194"Represents the target program running under the debugger.
195
Johnny Chen01a67862011-10-14 00:42:25 +0000196SBTarget supports module, breakpoint, and watchpoint iterations. For example,
Johnny Chendc7d3c12011-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 Chend4dd7992011-09-27 01:19:20 +0000218SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
219
220and,
221
Johnny Chen01a67862011-10-14 00:42:25 +0000222 for wp_loc in target.watchpoint_iter():
Johnny Chend4dd7992011-09-27 01:19:20 +0000223 print wp_loc
224
225produces:
226
Johnny Chen01a67862011-10-14 00:42:25 +0000227Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
Johnny Chend4dd7992011-09-27 01:19:20 +0000228 declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
Johnny Chen01a67862011-10-14 00:42:25 +0000229 hw_index = 0 hit_count = 2 ignore_count = 0"
Johnny Chen357033b2011-07-18 20:13:38 +0000230) SBTarget;
Johnny Chendc7d3c12011-07-16 21:15:39 +0000231class SBTarget
232{
Johnny Chendc7d3c12011-07-16 21:15:39 +0000233public:
234 //------------------------------------------------------------------
235 // Broadcaster bits.
236 //------------------------------------------------------------------
237 enum
238 {
239 eBroadcastBitBreakpointChanged = (1 << 0),
240 eBroadcastBitModulesLoaded = (1 << 1),
Jim Ingham1b5792e2012-12-18 02:03:49 +0000241 eBroadcastBitModulesUnloaded = (1 << 2),
Enrico Granataf15ee4e2013-04-05 18:49:06 +0000242 eBroadcastBitWatchpointChanged = (1 << 3),
243 eBroadcastBitSymbolsLoaded = (1 << 4)
Johnny Chendc7d3c12011-07-16 21:15:39 +0000244 };
245
246 //------------------------------------------------------------------
247 // Constructors
248 //------------------------------------------------------------------
249 SBTarget ();
250
251 SBTarget (const lldb::SBTarget& rhs);
252
Johnny Chendc7d3c12011-07-16 21:15:39 +0000253 //------------------------------------------------------------------
254 // Destructor
255 //------------------------------------------------------------------
256 ~SBTarget();
257
Jim Ingham4bddaeb2012-02-16 06:50:00 +0000258 static const char *
259 GetBroadcasterClassName ();
260
Johnny Chendc7d3c12011-07-16 21:15:39 +0000261 bool
262 IsValid() const;
263
264 lldb::SBProcess
265 GetProcess ();
266
267 %feature("docstring", "
268 //------------------------------------------------------------------
269 /// Launch a new process.
270 ///
271 /// Launch a new process by spawning a new process using the
272 /// target object's executable module's file as the file to launch.
273 /// Arguments are given in \a argv, and the environment variables
274 /// are in \a envp. Standard input and output files can be
275 /// optionally re-directed to \a stdin_path, \a stdout_path, and
276 /// \a stderr_path.
277 ///
278 /// @param[in] listener
279 /// An optional listener that will receive all process events.
280 /// If \a listener is valid then \a listener will listen to all
281 /// process events. If not valid, then this target's debugger
282 /// (SBTarget::GetDebugger()) will listen to all process events.
283 ///
284 /// @param[in] argv
285 /// The argument array.
286 ///
287 /// @param[in] envp
288 /// The environment array.
289 ///
290 /// @param[in] launch_flags
291 /// Flags to modify the launch (@see lldb::LaunchFlags)
292 ///
293 /// @param[in] stdin_path
294 /// The path to use when re-directing the STDIN of the new
295 /// process. If all stdXX_path arguments are NULL, a pseudo
296 /// terminal will be used.
297 ///
298 /// @param[in] stdout_path
299 /// The path to use when re-directing the STDOUT of the new
300 /// process. If all stdXX_path arguments are NULL, a pseudo
301 /// terminal will be used.
302 ///
303 /// @param[in] stderr_path
304 /// The path to use when re-directing the STDERR of the new
305 /// process. If all stdXX_path arguments are NULL, a pseudo
306 /// terminal will be used.
307 ///
308 /// @param[in] working_directory
309 /// The working directory to have the child process run in
310 ///
311 /// @param[in] launch_flags
312 /// Some launch options specified by logical OR'ing
313 /// lldb::LaunchFlags enumeration values together.
314 ///
315 /// @param[in] stop_at_endtry
316 /// If false do not stop the inferior at the entry point.
317 ///
318 /// @param[out]
319 /// An error object. Contains the reason if there is some failure.
320 ///
321 /// @return
322 /// A process object for the newly created process.
323 //------------------------------------------------------------------
324
325 For example,
326
327 process = target.Launch(self.dbg.GetListener(), None, None,
328 None, '/tmp/stdout.txt', None,
329 None, 0, False, error)
330
331 launches a new process by passing nothing for both the args and the envs
332 and redirect the standard output of the inferior to the /tmp/stdout.txt
333 file. It does not specify a working directory so that the debug server
334 will use its idea of what the current working directory is for the
335 inferior. Also, we ask the debugger not to stop the inferior at the
336 entry point. If no breakpoint is specified for the inferior, it should
337 run to completion if no user interaction is required.
338 ") Launch;
339 lldb::SBProcess
340 Launch (SBListener &listener,
341 char const **argv,
342 char const **envp,
343 const char *stdin_path,
344 const char *stdout_path,
345 const char *stderr_path,
346 const char *working_directory,
347 uint32_t launch_flags, // See LaunchFlags
348 bool stop_at_entry,
349 lldb::SBError& error);
350
351 %feature("docstring", "
352 //------------------------------------------------------------------
353 /// Launch a new process with sensible defaults.
354 ///
355 /// @param[in] argv
356 /// The argument array.
357 ///
358 /// @param[in] envp
359 /// The environment array.
360 ///
361 /// @param[in] working_directory
362 /// The working directory to have the child process run in
363 ///
364 /// Default: listener
365 /// Set to the target's debugger (SBTarget::GetDebugger())
366 ///
367 /// Default: launch_flags
368 /// Empty launch flags
369 ///
370 /// Default: stdin_path
371 /// Default: stdout_path
372 /// Default: stderr_path
373 /// A pseudo terminal will be used.
374 ///
375 /// @return
376 /// A process object for the newly created process.
377 //------------------------------------------------------------------
378
379 For example,
380
381 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
382
383 launches a new process by passing 'X', 'Y', 'Z' as the args to the
384 executable.
385 ") LaunchSimple;
386 lldb::SBProcess
387 LaunchSimple (const char **argv,
388 const char **envp,
389 const char *working_directory);
390
Greg Clayton0e615682012-02-24 05:03:03 +0000391 lldb::SBProcess
392 Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
Greg Clayton4d8ad552013-03-25 22:40:51 +0000393
394 %feature("docstring", "
395 //------------------------------------------------------------------
396 /// Load a core file
397 ///
398 /// @param[in] core_file
399 /// File path of the core dump.
400 ///
401 /// @return
402 /// A process object for the newly created core file.
403 //------------------------------------------------------------------
404
405 For example,
406
407 process = target.LoadCore('./a.out.core')
408
409 loads a new core file and returns the process object.
410 ") LoadCore;
411 lldb::SBProcess
412 LoadCore(const char *core_file);
Greg Clayton0e615682012-02-24 05:03:03 +0000413
414 lldb::SBProcess
415 Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error);
416
417
Johnny Chendc7d3c12011-07-16 21:15:39 +0000418 %feature("docstring", "
419 //------------------------------------------------------------------
420 /// Attach to process with pid.
421 ///
422 /// @param[in] listener
423 /// An optional listener that will receive all process events.
424 /// If \a listener is valid then \a listener will listen to all
425 /// process events. If not valid, then this target's debugger
426 /// (SBTarget::GetDebugger()) will listen to all process events.
427 ///
428 /// @param[in] pid
429 /// The process ID to attach to.
430 ///
431 /// @param[out]
432 /// An error explaining what went wrong if attach fails.
433 ///
434 /// @return
435 /// A process object for the attached process.
436 //------------------------------------------------------------------
437 ") AttachToProcessWithID;
438 lldb::SBProcess
439 AttachToProcessWithID (SBListener &listener,
440 lldb::pid_t pid,
441 lldb::SBError& error);
442
443 %feature("docstring", "
444 //------------------------------------------------------------------
445 /// Attach to process with name.
446 ///
447 /// @param[in] listener
448 /// An optional listener that will receive all process events.
449 /// If \a listener is valid then \a listener will listen to all
450 /// process events. If not valid, then this target's debugger
451 /// (SBTarget::GetDebugger()) will listen to all process events.
452 ///
453 /// @param[in] name
454 /// Basename of process to attach to.
455 ///
456 /// @param[in] wait_for
457 /// If true wait for a new instance of 'name' to be launched.
458 ///
459 /// @param[out]
460 /// An error explaining what went wrong if attach fails.
461 ///
462 /// @return
463 /// A process object for the attached process.
464 //------------------------------------------------------------------
465 ") AttachToProcessWithName;
466 lldb::SBProcess
467 AttachToProcessWithName (SBListener &listener,
468 const char *name,
469 bool wait_for,
470 lldb::SBError& error);
471
472 %feature("docstring", "
473 //------------------------------------------------------------------
474 /// Connect to a remote debug server with url.
475 ///
476 /// @param[in] listener
477 /// An optional listener that will receive all process events.
478 /// If \a listener is valid then \a listener will listen to all
479 /// process events. If not valid, then this target's debugger
480 /// (SBTarget::GetDebugger()) will listen to all process events.
481 ///
482 /// @param[in] url
483 /// The url to connect to, e.g., 'connect://localhost:12345'.
484 ///
485 /// @param[in] plugin_name
486 /// The plugin name to be used; can be NULL.
487 ///
488 /// @param[out]
489 /// An error explaining what went wrong if the connect fails.
490 ///
491 /// @return
492 /// A process object for the connected process.
493 //------------------------------------------------------------------
494 ") ConnectRemote;
495 lldb::SBProcess
496 ConnectRemote (SBListener &listener,
497 const char *url,
498 const char *plugin_name,
499 SBError& error);
500
501 lldb::SBFileSpec
502 GetExecutable ();
503
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000504 bool
505 AddModule (lldb::SBModule &module);
506
507 lldb::SBModule
508 AddModule (const char *path,
509 const char *triple,
510 const char *uuid);
511
Greg Claytonb210aec2012-04-23 20:23:39 +0000512 lldb::SBModule
513 AddModule (const char *path,
514 const char *triple,
515 const char *uuid_cstr,
516 const char *symfile);
517
Johnny Chendc7d3c12011-07-16 21:15:39 +0000518 uint32_t
519 GetNumModules () const;
520
521 lldb::SBModule
522 GetModuleAtIndex (uint32_t idx);
523
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000524 bool
525 RemoveModule (lldb::SBModule module);
526
Johnny Chendc7d3c12011-07-16 21:15:39 +0000527 lldb::SBDebugger
528 GetDebugger() const;
529
530 lldb::SBModule
531 FindModule (const lldb::SBFileSpec &file_spec);
532
Greg Clayton13d19502012-01-29 06:07:39 +0000533 lldb::ByteOrder
534 GetByteOrder ();
535
536 uint32_t
537 GetAddressByteSize();
538
539 const char *
540 GetTriple ();
541
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000542 lldb::SBError
543 SetSectionLoadAddress (lldb::SBSection section,
544 lldb::addr_t section_base_addr);
545
546 lldb::SBError
547 ClearSectionLoadAddress (lldb::SBSection section);
548
549 lldb::SBError
550 SetModuleLoadAddress (lldb::SBModule module,
551 int64_t sections_offset);
552
553 lldb::SBError
554 ClearModuleLoadAddress (lldb::SBModule module);
555
Johnny Chendc7d3c12011-07-16 21:15:39 +0000556 %feature("docstring", "
557 //------------------------------------------------------------------
558 /// Find functions by name.
559 ///
560 /// @param[in] name
561 /// The name of the function we are looking for.
562 ///
563 /// @param[in] name_type_mask
564 /// A logical OR of one or more FunctionNameType enum bits that
565 /// indicate what kind of names should be used when doing the
566 /// lookup. Bits include fully qualified names, base names,
567 /// C++ methods, or ObjC selectors.
568 /// See FunctionNameType for more details.
569 ///
Johnny Chendc7d3c12011-07-16 21:15:39 +0000570 /// @return
Greg Clayton5569e642012-02-06 01:44:54 +0000571 /// A lldb::SBSymbolContextList that gets filled in with all of
572 /// the symbol contexts for all the matches.
Johnny Chendc7d3c12011-07-16 21:15:39 +0000573 //------------------------------------------------------------------
574 ") FindFunctions;
Greg Clayton5569e642012-02-06 01:44:54 +0000575 lldb::SBSymbolContextList
Johnny Chendc7d3c12011-07-16 21:15:39 +0000576 FindFunctions (const char *name,
Greg Clayton5569e642012-02-06 01:44:54 +0000577 uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000578
579 lldb::SBType
580 FindFirstType (const char* type);
581
582 lldb::SBTypeList
583 FindTypes (const char* type);
Johnny Chendc7d3c12011-07-16 21:15:39 +0000584
Greg Claytonb43165b2012-12-05 21:24:42 +0000585 lldb::SBType
586 GetBasicType(lldb::BasicType type);
587
Jim Inghame37d6052011-09-13 00:29:56 +0000588 lldb::SBSourceManager
589 GetSourceManager ();
590
Johnny Chendc7d3c12011-07-16 21:15:39 +0000591 %feature("docstring", "
592 //------------------------------------------------------------------
593 /// Find global and static variables by name.
594 ///
595 /// @param[in] name
596 /// The name of the global or static variable we are looking
597 /// for.
598 ///
599 /// @param[in] max_matches
600 /// Allow the number of matches to be limited to \a max_matches.
601 ///
602 /// @return
603 /// A list of matched variables in an SBValueList.
604 //------------------------------------------------------------------
605 ") FindGlobalVariables;
606 lldb::SBValueList
607 FindGlobalVariables (const char *name,
608 uint32_t max_matches);
609
Enrico Granatabcd80b42013-01-16 18:53:52 +0000610 %feature("docstring", "
611 //------------------------------------------------------------------
612 /// Find the first global (or static) variable by name.
613 ///
614 /// @param[in] name
615 /// The name of the global or static variable we are looking
616 /// for.
617 ///
618 /// @return
619 /// An SBValue that gets filled in with the found variable (if any).
620 //------------------------------------------------------------------
621 ") FindFirstGlobalVariable;
622 lldb::SBValue
623 FindFirstGlobalVariable (const char* name);
624
Johnny Chendc7d3c12011-07-16 21:15:39 +0000625 void
626 Clear ();
627
Greg Clayton00e6fbf2011-07-22 16:46:35 +0000628 lldb::SBAddress
629 ResolveLoadAddress (lldb::addr_t vm_addr);
Johnny Chendc7d3c12011-07-16 21:15:39 +0000630
631 SBSymbolContext
632 ResolveSymbolContextForAddress (const SBAddress& addr,
633 uint32_t resolve_scope);
634
635 lldb::SBBreakpoint
636 BreakpointCreateByLocation (const char *file, uint32_t line);
637
638 lldb::SBBreakpoint
639 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
640
641 lldb::SBBreakpoint
642 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
643
644 lldb::SBBreakpoint
Jim Ingham2dd7f7f2011-10-11 01:18:55 +0000645 BreakpointCreateByName (const char *symbol_name,
646 uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
647 const SBFileSpecList &module_list,
648 const SBFileSpecList &comp_unit_list);
649
650 lldb::SBBreakpoint
Jim Inghamfab10e82012-03-06 00:37:27 +0000651 BreakpointCreateByNames (const char *symbol_name[],
652 uint32_t num_names,
653 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
654 const SBFileSpecList &module_list,
655 const SBFileSpecList &comp_unit_list);
656
657 lldb::SBBreakpoint
Johnny Chendc7d3c12011-07-16 21:15:39 +0000658 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
659
660 lldb::SBBreakpoint
Jim Ingham969795f2011-09-21 01:17:13 +0000661 BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
662
663 lldb::SBBreakpoint
Jim Inghamfab10e82012-03-06 00:37:27 +0000664 BreakpointCreateForException (lldb::LanguageType language,
665 bool catch_bp,
666 bool throw_bp);
667
668 lldb::SBBreakpoint
Johnny Chendc7d3c12011-07-16 21:15:39 +0000669 BreakpointCreateByAddress (addr_t address);
670
671 uint32_t
672 GetNumBreakpoints () const;
673
674 lldb::SBBreakpoint
675 GetBreakpointAtIndex (uint32_t idx) const;
676
677 bool
678 BreakpointDelete (break_id_t break_id);
679
680 lldb::SBBreakpoint
681 FindBreakpointByID (break_id_t break_id);
682
683 bool
684 EnableAllBreakpoints ();
685
686 bool
687 DisableAllBreakpoints ();
688
689 bool
690 DeleteAllBreakpoints ();
691
Johnny Chend4dd7992011-09-27 01:19:20 +0000692 uint32_t
Greg Clayton1b282f92011-10-13 18:08:26 +0000693 GetNumWatchpoints () const;
694
695 lldb::SBWatchpoint
696 GetWatchpointAtIndex (uint32_t idx) const;
697
Johnny Chend4dd7992011-09-27 01:19:20 +0000698 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000699 DeleteWatchpoint (lldb::watch_id_t watch_id);
700
701 lldb::SBWatchpoint
702 FindWatchpointByID (lldb::watch_id_t watch_id);
703
Johnny Chend4dd7992011-09-27 01:19:20 +0000704 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000705 EnableAllWatchpoints ();
706
Johnny Chend4dd7992011-09-27 01:19:20 +0000707 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000708 DisableAllWatchpoints ();
709
Johnny Chend4dd7992011-09-27 01:19:20 +0000710 bool
Greg Clayton1b282f92011-10-13 18:08:26 +0000711 DeleteAllWatchpoints ();
712
713 lldb::SBWatchpoint
714 WatchAddress (lldb::addr_t addr,
715 size_t size,
716 bool read,
Johnny Chenb90827e2012-06-04 23:19:54 +0000717 bool write,
718 SBError &error);
Greg Clayton1b282f92011-10-13 18:08:26 +0000719
Johnny Chend4dd7992011-09-27 01:19:20 +0000720
Johnny Chendc7d3c12011-07-16 21:15:39 +0000721 lldb::SBBroadcaster
722 GetBroadcaster () const;
Sean Callanan50952e92011-12-14 23:49:37 +0000723
724 lldb::SBInstructionList
Greg Clayton9c766112012-03-06 22:24:44 +0000725 ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
726
727 lldb::SBInstructionList
Jim Ingham0f063ba2013-03-02 00:26:47 +0000728 ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
729
730 lldb::SBInstructionList
Sean Callanan50952e92011-12-14 23:49:37 +0000731 GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
732
Jim Ingham0f063ba2013-03-02 00:26:47 +0000733 lldb::SBInstructionList
734 GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
735
Greg Claytone14e1922012-12-04 02:22:16 +0000736 lldb::SBSymbolContextList
737 FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
738
Johnny Chendc7d3c12011-07-16 21:15:39 +0000739 bool
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000740 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
Greg Clayton13d19502012-01-29 06:07:39 +0000741
Greg Clayton13fbb992013-02-01 00:47:49 +0000742 lldb::addr_t
743 GetStackRedZoneSize();
744
Enrico Granatac3387332013-05-03 01:29:27 +0000745 bool
746 operator == (const lldb::SBTarget &rhs) const;
747
748 bool
749 operator != (const lldb::SBTarget &rhs) const;
750
Greg Clayton4b63a5c2013-01-04 18:10:18 +0000751 lldb::SBValue
752 EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
Greg Clayton13d19502012-01-29 06:07:39 +0000753 %pythoncode %{
Greg Clayton6b2bd932012-02-01 08:09:32 +0000754 class modules_access(object):
755 '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
756 def __init__(self, sbtarget):
757 self.sbtarget = sbtarget
758
759 def __len__(self):
760 if self.sbtarget:
Filipe Cabecinhas1a96ef82012-05-11 20:39:42 +0000761 return int(self.sbtarget.GetNumModules())
Greg Clayton6b2bd932012-02-01 08:09:32 +0000762 return 0
763
764 def __getitem__(self, key):
765 num_modules = self.sbtarget.GetNumModules()
766 if type(key) is int:
767 if key < num_modules:
768 return self.sbtarget.GetModuleAtIndex(key)
769 elif type(key) is str:
770 if key.find('/') == -1:
771 for idx in range(num_modules):
772 module = self.sbtarget.GetModuleAtIndex(idx)
773 if module.file.basename == key:
774 return module
775 else:
776 for idx in range(num_modules):
777 module = self.sbtarget.GetModuleAtIndex(idx)
778 if module.file.fullpath == key:
779 return module
780 # See if the string is a UUID
Greg Clayton1fb7c622013-03-07 02:58:47 +0000781 try:
782 the_uuid = uuid.UUID(key)
783 if the_uuid:
784 for idx in range(num_modules):
785 module = self.sbtarget.GetModuleAtIndex(idx)
786 if module.uuid == the_uuid:
787 return module
788 except:
789 return None
Greg Clayton6b2bd932012-02-01 08:09:32 +0000790 elif type(key) is uuid.UUID:
791 for idx in range(num_modules):
792 module = self.sbtarget.GetModuleAtIndex(idx)
793 if module.uuid == key:
794 return module
795 elif type(key) is re.SRE_Pattern:
796 matching_modules = []
797 for idx in range(num_modules):
798 module = self.sbtarget.GetModuleAtIndex(idx)
799 re_match = key.search(module.path.fullpath)
800 if re_match:
801 matching_modules.append(module)
802 return matching_modules
803 else:
804 print "error: unsupported item type: %s" % type(key)
805 return None
806
807 def get_modules_access_object(self):
Greg Claytonb62bb8c2012-02-03 03:22:53 +0000808 '''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 +0000809 return self.modules_access (self)
810
811 def get_modules_array(self):
Greg Claytonb62bb8c2012-02-03 03:22:53 +0000812 '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
Greg Clayton6b2bd932012-02-01 08:09:32 +0000813 modules = []
814 for idx in range(self.GetNumModules()):
815 modules.append(self.GetModuleAtIndex(idx))
816 return modules
817
818 __swig_getmethods__["modules"] = get_modules_array
Greg Clayton5ef31a92012-06-29 22:00:42 +0000819 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 +0000820
821 __swig_getmethods__["module"] = get_modules_access_object
Greg Clayton5ef31a92012-06-29 22:00:42 +0000822 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 +0000823
Greg Clayton13d19502012-01-29 06:07:39 +0000824 __swig_getmethods__["process"] = GetProcess
Greg Clayton5ef31a92012-06-29 22:00:42 +0000825 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 +0000826
827 __swig_getmethods__["executable"] = GetExecutable
Greg Clayton5ef31a92012-06-29 22:00:42 +0000828 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 +0000829
830 __swig_getmethods__["debugger"] = GetDebugger
Greg Clayton5ef31a92012-06-29 22:00:42 +0000831 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 +0000832
Greg Clayton13d19502012-01-29 06:07:39 +0000833 __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints
Greg Clayton5ef31a92012-06-29 22:00:42 +0000834 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 +0000835
836 __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints
Greg Clayton5ef31a92012-06-29 22:00:42 +0000837 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 +0000838
839 __swig_getmethods__["broadcaster"] = GetBroadcaster
Greg Clayton5ef31a92012-06-29 22:00:42 +0000840 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 +0000841
842 __swig_getmethods__["byte_order"] = GetByteOrder
Greg Clayton5ef31a92012-06-29 22:00:42 +0000843 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 +0000844
845 __swig_getmethods__["addr_size"] = GetAddressByteSize
Greg Clayton5ef31a92012-06-29 22:00:42 +0000846 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 +0000847
848 __swig_getmethods__["triple"] = GetTriple
Greg Clayton5ef31a92012-06-29 22:00:42 +0000849 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 Clayton13d19502012-01-29 06:07:39 +0000850 %}
851
Johnny Chendc7d3c12011-07-16 21:15:39 +0000852};
853
854} // namespace lldb