1 //===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 namespace lldb {
10 
11 %feature("docstring",
12 "Represents the target program running under the debugger.
13 
14 SBTarget supports module, breakpoint, and watchpoint iterations. For example,
15 
16     for m in target.module_iter():
17         print m
18 
19 produces:
20 
21 (x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
22 (x86_64) /usr/lib/dyld
23 (x86_64) /usr/lib/libstdc++.6.dylib
24 (x86_64) /usr/lib/libSystem.B.dylib
25 (x86_64) /usr/lib/system/libmathCommon.A.dylib
26 (x86_64) /usr/lib/libSystem.B.dylib(__commpage)
27 
28 and,
29 
30     for b in target.breakpoint_iter():
31         print b
32 
33 produces:
34 
35 SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
36 SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
37 
38 and,
39 
40     for wp_loc in target.watchpoint_iter():
41         print wp_loc
42 
43 produces:
44 
45 Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
46     declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
47     hw_index = 0  hit_count = 2     ignore_count = 0"
48 ) SBTarget;
49 class SBTarget
50 {
51 public:
52     //------------------------------------------------------------------
53     // Broadcaster bits.
54     //------------------------------------------------------------------
55     enum
56     {
57         eBroadcastBitBreakpointChanged  = (1 << 0),
58         eBroadcastBitModulesLoaded      = (1 << 1),
59         eBroadcastBitModulesUnloaded    = (1 << 2),
60         eBroadcastBitWatchpointChanged  = (1 << 3),
61         eBroadcastBitSymbolsLoaded      = (1 << 4)
62     };
63 
64     //------------------------------------------------------------------
65     // Constructors
66     //------------------------------------------------------------------
67     SBTarget ();
68 
69     SBTarget (const lldb::SBTarget& rhs);
70 
71     //------------------------------------------------------------------
72     // Destructor
73     //------------------------------------------------------------------
74     ~SBTarget();
75 
76     static const char *
77     GetBroadcasterClassName ();
78 
79     bool
80     IsValid() const;
81 
82     explicit operator bool() const;
83 
84     static bool
85     EventIsTargetEvent (const lldb::SBEvent &event);
86 
87     static lldb::SBTarget
88     GetTargetFromEvent (const lldb::SBEvent &event);
89 
90     static uint32_t
91     GetNumModulesFromEvent (const lldb::SBEvent &event);
92 
93     static lldb::SBModule
94     GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event);
95 
96     lldb::SBProcess
97     GetProcess ();
98 
99 
100     %feature("docstring", "
101     Return the platform object associated with the target.
102 
103     After return, the platform object should be checked for
104     validity.
105 
106     @return
107         A platform object.") GetPlatform;
108     lldb::SBPlatform
109     GetPlatform ();
110 
111     %feature("docstring", "
112     Install any binaries that need to be installed.
113 
114     This function does nothing when debugging on the host system.
115     When connected to remote platforms, the target's main executable
116     and any modules that have their install path set will be
117     installed on the remote platform. If the main executable doesn't
118     have an install location set, it will be installed in the remote
119     platform's working directory.
120 
121     @return
122         An error describing anything that went wrong during
123         installation.") Install;
124     lldb::SBError
125     Install();
126 
127     %feature("docstring", "
128     Launch a new process.
129 
130     Launch a new process by spawning a new process using the
131     target object's executable module's file as the file to launch.
132     Arguments are given in argv, and the environment variables
133     are in envp. Standard input and output files can be
134     optionally re-directed to stdin_path, stdout_path, and
135     stderr_path.
136 
137     @param[in] listener
138         An optional listener that will receive all process events.
139         If listener is valid then listener will listen to all
140         process events. If not valid, then this target's debugger
141         (SBTarget::GetDebugger()) will listen to all process events.
142 
143     @param[in] argv
144         The argument array.
145 
146     @param[in] envp
147         The environment array.
148 
149     @param[in] launch_flags
150         Flags to modify the launch (@see lldb::LaunchFlags)
151 
152     @param[in] stdin_path
153         The path to use when re-directing the STDIN of the new
154         process. If all stdXX_path arguments are NULL, a pseudo
155         terminal will be used.
156 
157     @param[in] stdout_path
158         The path to use when re-directing the STDOUT of the new
159         process. If all stdXX_path arguments are NULL, a pseudo
160         terminal will be used.
161 
162     @param[in] stderr_path
163         The path to use when re-directing the STDERR of the new
164         process. If all stdXX_path arguments are NULL, a pseudo
165         terminal will be used.
166 
167     @param[in] working_directory
168         The working directory to have the child process run in
169 
170     @param[in] launch_flags
171         Some launch options specified by logical OR'ing
172         lldb::LaunchFlags enumeration values together.
173 
174     @param[in] stop_at_entry
175         If false do not stop the inferior at the entry point.
176 
177     @param[out]
178         An error object. Contains the reason if there is some failure.
179 
180     @return
181          A process object for the newly created process.
182 
183     For example,
184 
185         process = target.Launch(self.dbg.GetListener(), None, None,
186                                 None, '/tmp/stdout.txt', None,
187                                 None, 0, False, error)
188 
189     launches a new process by passing nothing for both the args and the envs
190     and redirect the standard output of the inferior to the /tmp/stdout.txt
191     file. It does not specify a working directory so that the debug server
192     will use its idea of what the current working directory is for the
193     inferior. Also, we ask the debugger not to stop the inferior at the
194     entry point. If no breakpoint is specified for the inferior, it should
195     run to completion if no user interaction is required.") Launch;
196     lldb::SBProcess
197     Launch (SBListener &listener,
198             char const **argv,
199             char const **envp,
200             const char *stdin_path,
201             const char *stdout_path,
202             const char *stderr_path,
203             const char *working_directory,
204             uint32_t launch_flags,   // See LaunchFlags
205             bool stop_at_entry,
206             lldb::SBError& error);
207 
208     %feature("docstring", "
209     Launch a new process with sensible defaults.
210 
211     @param[in] argv
212         The argument array.
213 
214     @param[in] envp
215         The environment array.
216 
217     @param[in] working_directory
218         The working directory to have the child process run in
219 
220     Default: listener
221         Set to the target's debugger (SBTarget::GetDebugger())
222 
223     Default: launch_flags
224         Empty launch flags
225 
226     Default: stdin_path
227     Default: stdout_path
228     Default: stderr_path
229         A pseudo terminal will be used.
230 
231     @return
232          A process object for the newly created process.
233 
234     For example,
235 
236         process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
237 
238     launches a new process by passing 'X', 'Y', 'Z' as the args to the
239     executable.") LaunchSimple;
240     lldb::SBProcess
241     LaunchSimple (const char **argv,
242                   const char **envp,
243                   const char *working_directory);
244 
245     lldb::SBProcess
246     Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
247 
248     %feature("docstring", "
249     Load a core file
250 
251     @param[in] core_file
252         File path of the core dump.
253 
254     @param[out] error
255         An error explaining what went wrong if the operation fails.
256         (Optional)
257 
258     @return
259          A process object for the newly created core file.
260 
261     For example,
262 
263         process = target.LoadCore('./a.out.core')
264 
265     loads a new core file and returns the process object.") LoadCore;
266     lldb::SBProcess
267     LoadCore(const char *core_file);
268 
269     lldb::SBProcess
270     LoadCore(const char *core_file, lldb::SBError &error);
271 
272     lldb::SBProcess
273     Attach(lldb::SBAttachInfo &attach_info, lldb::SBError& error);
274 
275     %feature("docstring", "
276     Attach to process with pid.
277 
278     @param[in] listener
279         An optional listener that will receive all process events.
280         If listener is valid then 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] pid
285         The process ID to attach to.
286 
287     @param[out]
288         An error explaining what went wrong if attach fails.
289 
290     @return
291          A process object for the attached process.") AttachToProcessWithID;
292     lldb::SBProcess
293     AttachToProcessWithID (SBListener &listener,
294                            lldb::pid_t pid,
295                            lldb::SBError& error);
296 
297     %feature("docstring", "
298     Attach to process with name.
299 
300     @param[in] listener
301         An optional listener that will receive all process events.
302         If listener is valid then listener will listen to all
303         process events. If not valid, then this target's debugger
304         (SBTarget::GetDebugger()) will listen to all process events.
305 
306     @param[in] name
307         Basename of process to attach to.
308 
309     @param[in] wait_for
310         If true wait for a new instance of 'name' to be launched.
311 
312     @param[out]
313         An error explaining what went wrong if attach fails.
314 
315     @return
316          A process object for the attached process.") AttachToProcessWithName;
317     lldb::SBProcess
318     AttachToProcessWithName (SBListener &listener,
319                              const char *name,
320                              bool wait_for,
321                              lldb::SBError& error);
322 
323     %feature("docstring", "
324     Connect to a remote debug server with url.
325 
326     @param[in] listener
327         An optional listener that will receive all process events.
328         If listener is valid then listener will listen to all
329         process events. If not valid, then this target's debugger
330         (SBTarget::GetDebugger()) will listen to all process events.
331 
332     @param[in] url
333         The url to connect to, e.g., 'connect://localhost:12345'.
334 
335     @param[in] plugin_name
336         The plugin name to be used; can be NULL.
337 
338     @param[out]
339         An error explaining what went wrong if the connect fails.
340 
341     @return
342          A process object for the connected process.") ConnectRemote;
343     lldb::SBProcess
344     ConnectRemote (SBListener &listener,
345                    const char *url,
346                    const char *plugin_name,
347                    SBError& error);
348 
349     lldb::SBFileSpec
350     GetExecutable ();
351 
352     %feature("docstring", "
353     Append the path mapping (from -> to) to the target's paths mapping list.") AppendImageSearchPath;
354     void
355     AppendImageSearchPath (const char *from,
356                            const char *to,
357                            SBError &error);
358 
359     bool
360     AddModule (lldb::SBModule &module);
361 
362     lldb::SBModule
363     AddModule (const char *path,
364                const char *triple,
365                const char *uuid);
366 
367     lldb::SBModule
368     AddModule (const char *path,
369                const char *triple,
370                const char *uuid_cstr,
371                const char *symfile);
372 
373     lldb::SBModule
374     AddModule (const SBModuleSpec &module_spec);
375 
376     uint32_t
377     GetNumModules () const;
378 
379     lldb::SBModule
380     GetModuleAtIndex (uint32_t idx);
381 
382     bool
383     RemoveModule (lldb::SBModule module);
384 
385     lldb::SBDebugger
386     GetDebugger() const;
387 
388     lldb::SBModule
389     FindModule (const lldb::SBFileSpec &file_spec);
390 
391     %feature("docstring", "
392     Find compile units related to *this target and passed source
393     file.
394 
395     @param[in] sb_file_spec
396         A lldb::SBFileSpec object that contains source file
397         specification.
398 
399     @return
400         A lldb::SBSymbolContextList that gets filled in with all of
401         the symbol contexts for all the matches.") FindCompileUnits;
402     lldb::SBSymbolContextList
403     FindCompileUnits (const lldb::SBFileSpec &sb_file_spec);
404 
405     lldb::ByteOrder
406     GetByteOrder ();
407 
408     uint32_t
409     GetAddressByteSize();
410 
411     const char *
412     GetTriple ();
413 
414     %feature("docstring", "
415     Architecture data byte width accessor
416 
417     @return
418     The size in 8-bit (host) bytes of a minimum addressable
419     unit from the Architecture's data bus") GetDataByteSize;
420     uint32_t
421     GetDataByteSize ();
422 
423     %feature("docstring", "
424     Architecture code byte width accessor
425 
426     @return
427     The size in 8-bit (host) bytes of a minimum addressable
428     unit from the Architecture's code bus") GetCodeByteSize;
429     uint32_t
430     GetCodeByteSize ();
431 
432     lldb::SBError
433     SetSectionLoadAddress (lldb::SBSection section,
434                            lldb::addr_t section_base_addr);
435 
436     lldb::SBError
437     ClearSectionLoadAddress (lldb::SBSection section);
438 
439     lldb::SBError
440     SetModuleLoadAddress (lldb::SBModule module,
441                           int64_t sections_offset);
442 
443     lldb::SBError
444     ClearModuleLoadAddress (lldb::SBModule module);
445 
446     %feature("docstring", "
447     Find functions by name.
448 
449     @param[in] name
450         The name of the function we are looking for.
451 
452     @param[in] name_type_mask
453         A logical OR of one or more FunctionNameType enum bits that
454         indicate what kind of names should be used when doing the
455         lookup. Bits include fully qualified names, base names,
456         C++ methods, or ObjC selectors.
457         See FunctionNameType for more details.
458 
459     @return
460         A lldb::SBSymbolContextList that gets filled in with all of
461         the symbol contexts for all the matches.") FindFunctions;
462     lldb::SBSymbolContextList
463     FindFunctions (const char *name,
464                    uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
465 
466     lldb::SBType
467     FindFirstType (const char* type);
468 
469     lldb::SBTypeList
470     FindTypes (const char* type);
471 
472     lldb::SBType
473     GetBasicType(lldb::BasicType type);
474 
475     lldb::SBSourceManager
476     GetSourceManager ();
477 
478     %feature("docstring", "
479     Find global and static variables by name.
480 
481     @param[in] name
482         The name of the global or static variable we are looking
483         for.
484 
485     @param[in] max_matches
486         Allow the number of matches to be limited to max_matches.
487 
488     @return
489         A list of matched variables in an SBValueList.") FindGlobalVariables;
490     lldb::SBValueList
491     FindGlobalVariables (const char *name,
492                          uint32_t max_matches);
493 
494      %feature("docstring", "
495     Find the first global (or static) variable by name.
496 
497     @param[in] name
498         The name of the global or static variable we are looking
499         for.
500 
501     @return
502         An SBValue that gets filled in with the found variable (if any).") FindFirstGlobalVariable;
503     lldb::SBValue
504     FindFirstGlobalVariable (const char* name);
505 
506 
507     lldb::SBValueList
508     FindGlobalVariables(const char *name,
509                         uint32_t max_matches,
510                         MatchType matchtype);
511 
512     lldb::SBSymbolContextList
513     FindGlobalFunctions(const char *name,
514                         uint32_t max_matches,
515                         MatchType matchtype);
516 
517     void
518     Clear ();
519 
520      %feature("docstring", "
521     Resolve a current file address into a section offset address.
522 
523     @param[in] file_addr
524 
525     @return
526         An SBAddress which will be valid if...") ResolveFileAddress;
527     lldb::SBAddress
528     ResolveFileAddress (lldb::addr_t file_addr);
529 
530     lldb::SBAddress
531     ResolveLoadAddress (lldb::addr_t vm_addr);
532 
533     lldb::SBAddress
534     ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr);
535 
536     SBSymbolContext
537     ResolveSymbolContextForAddress (const SBAddress& addr,
538                                     uint32_t resolve_scope);
539 
540      %feature("docstring", "
541     Read target memory. If a target process is running then memory
542     is read from here. Otherwise the memory is read from the object
543     files. For a target whose bytes are sized as a multiple of host
544     bytes, the data read back will preserve the target's byte order.
545 
546     @param[in] addr
547         A target address to read from.
548 
549     @param[out] buf
550         The buffer to read memory into.
551 
552     @param[in] size
553         The maximum number of host bytes to read in the buffer passed
554         into this call
555 
556     @param[out] error
557         Error information is written here if the memory read fails.
558 
559     @return
560         The amount of data read in host bytes.") ReadMemory;
561     size_t
562     ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
563 
564     lldb::SBBreakpoint
565     BreakpointCreateByLocation (const char *file, uint32_t line);
566 
567     lldb::SBBreakpoint
568     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
569 
570     lldb::SBBreakpoint
571     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset);
572 
573     lldb::SBBreakpoint
574     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
575                                 lldb::addr_t offset, SBFileSpecList &module_list);
576 
577     lldb::SBBreakpoint
578     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
579                                 uint32_t column, lldb::addr_t offset,
580                                 SBFileSpecList &module_list);
581 
582     lldb::SBBreakpoint
583     BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
584 
585     lldb::SBBreakpoint
586     BreakpointCreateByName (const char *symbol_name,
587                             uint32_t func_name_type,           // Logical OR one or more FunctionNameType enum bits
588                             const SBFileSpecList &module_list,
589                             const SBFileSpecList &comp_unit_list);
590 
591     lldb::SBBreakpoint
592     BreakpointCreateByName (const char *symbol_name,
593                             uint32_t func_name_type,           // Logical OR one or more FunctionNameType enum bits
594                             lldb::LanguageType symbol_language,
595                             const SBFileSpecList &module_list,
596                             const SBFileSpecList &comp_unit_list);
597 
598 #ifdef SWIGPYTHON
599 %typemap(in) (const char **symbol_name, uint32_t num_names) {
600   using namespace lldb_private;
601   /* Check if is a list  */
602   if (PythonList::Check($input)) {
603     PythonList list(PyRefType::Borrowed, $input);
604     $2 = list.GetSize();
605     int i = 0;
606     $1 = (char**)malloc(($2+1)*sizeof(char*));
607     for (i = 0; i < $2; i++) {
608       PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>();
609       if (!py_str.IsAllocated()) {
610         PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby");
611         free($1);
612         return nullptr;
613       }
614 
615       $1[i] = const_cast<char*>(py_str.GetString().data());
616     }
617     $1[i] = 0;
618   } else if ($input == Py_None) {
619     $1 =  NULL;
620   } else {
621     PyErr_SetString(PyExc_TypeError,"not a list");
622     return NULL;
623   }
624 }
625 #endif
626 
627     lldb::SBBreakpoint
628     BreakpointCreateByNames (const char **symbol_name,
629                              uint32_t num_names,
630                              uint32_t name_type_mask,           // Logical OR one or more FunctionNameType enum bits
631                              const SBFileSpecList &module_list,
632                              const SBFileSpecList &comp_unit_list);
633 
634     lldb::SBBreakpoint
635     BreakpointCreateByNames (const char **symbol_name,
636                              uint32_t num_names,
637                              uint32_t name_type_mask,           // Logical OR one or more FunctionNameType enum bits
638                              lldb::LanguageType symbol_language,
639                              const SBFileSpecList &module_list,
640                              const SBFileSpecList &comp_unit_list);
641 
642     lldb::SBBreakpoint
643     BreakpointCreateByNames (const char **symbol_name,
644                              uint32_t num_names,
645                              uint32_t name_type_mask,           // Logical OR one or more FunctionNameType enum bits
646                              lldb::LanguageType symbol_language,
647                              lldb::addr_t offset,
648                              const SBFileSpecList &module_list,
649                              const SBFileSpecList &comp_unit_list);
650 
651     lldb::SBBreakpoint
652     BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
653 
654     lldb::SBBreakpoint
655     BreakpointCreateByRegex (const char *symbol_name_regex,
656                              lldb::LanguageType symbol_language,
657                              const SBFileSpecList &module_list,
658                              const SBFileSpecList &comp_unit_list);
659 
660     lldb::SBBreakpoint
661     BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
662 
663     lldb::SBBreakpoint
664     BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list);
665 
666     lldb::SBBreakpoint
667     BreakpointCreateBySourceRegex (const char *source_regex,
668                                    const SBFileSpecList &module_list,
669                                    const SBFileSpecList &source_file,
670                                    const SBStringList  &func_names);
671 
672     lldb::SBBreakpoint
673     BreakpointCreateForException  (lldb::LanguageType language,
674                                    bool catch_bp,
675                                    bool throw_bp);
676 
677     lldb::SBBreakpoint
678     BreakpointCreateByAddress (addr_t address);
679 
680     lldb::SBEnvironment
681     GetEnvironment();
682 
683     lldb::SBBreakpoint
684     BreakpointCreateBySBAddress (SBAddress &sb_address);
685 
686     %feature("docstring", "
687     Create a breakpoint using a scripted resolver.
688 
689     @param[in] class_name
690        This is the name of the class that implements a scripted resolver.
691        The class should have the following signature:
692        class Resolver:
693            def __init__(self, bkpt, extra_args):
694                # bkpt - the breakpoint for which this is the resolver.  When
695                # the resolver finds an interesting address, call AddLocation
696                # on this breakpoint to add it.
697                #
698                # extra_args - an SBStructuredData that can be used to
699                # parametrize this instance.  Same as the extra_args passed
700                # to BreakpointCreateFromScript.
701 
702            def __get_depth__ (self):
703                # This is optional, but if defined, you should return the
704                # depth at which you want the callback to be called.  The
705                # available options are:
706                #    lldb.eSearchDepthModule
707                #    lldb.eSearchDepthCompUnit
708                # The default if you don't implement this method is
709                # eSearchDepthModule.
710 
711            def __callback__(self, sym_ctx):
712                # sym_ctx - an SBSymbolContext that is the cursor in the
713                # search through the program to resolve breakpoints.
714                # The sym_ctx will be filled out to the depth requested in
715                # __get_depth__.
716                # Look in this sym_ctx for new breakpoint locations,
717                # and if found use bkpt.AddLocation to add them.
718                # Note, you will only get called for modules/compile_units that
719                # pass the SearchFilter provided by the module_list & file_list
720                # passed into BreakpointCreateFromScript.
721 
722            def get_short_help(self):
723                # Optional, but if implemented return a short string that will
724                # be printed at the beginning of the break list output for the
725                # breakpoint.
726 
727     @param[in] extra_args
728        This is an SBStructuredData object that will get passed to the
729        constructor of the class in class_name.  You can use this to
730        reuse the same class, parametrizing it with entries from this
731        dictionary.
732 
733     @param module_list
734        If this is non-empty, this will be used as the module filter in the
735        SearchFilter created for this breakpoint.
736 
737     @param file_list
738        If this is non-empty, this will be used as the comp unit filter in the
739        SearchFilter created for this breakpoint.
740 
741     @return
742         An SBBreakpoint that will set locations based on the logic in the
743         resolver's search callback.") BreakpointCreateFromScript;
744     lldb::SBBreakpoint BreakpointCreateFromScript(
745       const char *class_name,
746       SBStructuredData &extra_args,
747       const SBFileSpecList &module_list,
748       const SBFileSpecList &file_list,
749       bool request_hardware = false);
750 
751     uint32_t
752     GetNumBreakpoints () const;
753 
754     lldb::SBBreakpoint
755     GetBreakpointAtIndex (uint32_t idx) const;
756 
757     bool
758     BreakpointDelete (break_id_t break_id);
759 
760     lldb::SBBreakpoint
761     FindBreakpointByID (break_id_t break_id);
762 
763 
764     bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
765 
766     void DeleteBreakpointName(const char *name);
767 
768     void GetBreakpointNames(SBStringList &names);
769 
770     bool
771     EnableAllBreakpoints ();
772 
773     bool
774     DisableAllBreakpoints ();
775 
776     bool
777     DeleteAllBreakpoints ();
778 
779      %feature("docstring", "
780     Read breakpoints from source_file and return the newly created
781     breakpoints in bkpt_list.
782 
783     @param[in] source_file
784        The file from which to read the breakpoints
785 
786     @param[out] bkpt_list
787        A list of the newly created breakpoints.
788 
789     @return
790         An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile;
791     lldb::SBError
792     BreakpointsCreateFromFile(SBFileSpec &source_file,
793                               SBBreakpointList &bkpt_list);
794 
795      %feature("docstring", "
796     Read breakpoints from source_file and return the newly created
797     breakpoints in bkpt_list.
798 
799     @param[in] source_file
800        The file from which to read the breakpoints
801 
802     @param[in] matching_names
803        Only read in breakpoints whose names match one of the names in this
804        list.
805 
806     @param[out] bkpt_list
807        A list of the newly created breakpoints.
808 
809     @return
810         An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile;
811     lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
812                                           SBStringList &matching_names,
813                                           SBBreakpointList &new_bps);
814 
815      %feature("docstring", "
816     Write breakpoints to dest_file.
817 
818     @param[in] dest_file
819        The file to which to write the breakpoints.
820 
821     @return
822         An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile;
823     lldb::SBError
824     BreakpointsWriteToFile(SBFileSpec &dest_file);
825 
826      %feature("docstring", "
827     Write breakpoints listed in bkpt_list to dest_file.
828 
829     @param[in] dest_file
830        The file to which to write the breakpoints.
831 
832     @param[in] bkpt_list
833        Only write breakpoints from this list.
834 
835     @param[in] append
836        If true, append the breakpoints in bkpt_list to the others
837        serialized in dest_file.  If dest_file doesn't exist, then a new
838        file will be created and the breakpoints in bkpt_list written to it.
839 
840     @return
841         An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile;
842     lldb::SBError
843     BreakpointsWriteToFile(SBFileSpec &dest_file,
844                            SBBreakpointList &bkpt_list,
845                            bool append = false);
846 
847     uint32_t
848     GetNumWatchpoints () const;
849 
850     lldb::SBWatchpoint
851     GetWatchpointAtIndex (uint32_t idx) const;
852 
853     bool
854     DeleteWatchpoint (lldb::watch_id_t watch_id);
855 
856     lldb::SBWatchpoint
857     FindWatchpointByID (lldb::watch_id_t watch_id);
858 
859     bool
860     EnableAllWatchpoints ();
861 
862     bool
863     DisableAllWatchpoints ();
864 
865     bool
866     DeleteAllWatchpoints ();
867 
868     lldb::SBWatchpoint
869     WatchAddress (lldb::addr_t addr,
870                   size_t size,
871                   bool read,
872                   bool write,
873                   SBError &error);
874 
875 
876     lldb::SBBroadcaster
877     GetBroadcaster () const;
878 
879      %feature("docstring", "
880     Create an SBValue with the given name by treating the memory starting at addr as an entity of type.
881 
882     @param[in] name
883         The name of the resultant SBValue
884 
885     @param[in] addr
886         The address of the start of the memory region to be used.
887 
888     @param[in] type
889         The type to use to interpret the memory starting at addr.
890 
891     @return
892         An SBValue of the given type, may be invalid if there was an error reading
893         the underlying memory.") CreateValueFromAddress;
894     lldb::SBValue
895     CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
896 
897     lldb::SBValue
898     CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type);
899 
900     lldb::SBValue
901     CreateValueFromExpression (const char *name, const char* expr);
902 
903     %feature("docstring", "
904     Disassemble a specified number of instructions starting at an address.
905     Parameters:
906        base_addr       -- the address to start disassembly from
907        count           -- the number of instructions to disassemble
908        flavor_string   -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly
909     Returns an SBInstructionList.")
910     ReadInstructions;
911     lldb::SBInstructionList
912     ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
913 
914     lldb::SBInstructionList
915     ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
916 
917     %feature("docstring", "
918     Disassemble the bytes in a buffer and return them in an SBInstructionList.
919     Parameters:
920        base_addr -- used for symbolicating the offsets in the byte stream when disassembling
921        buf       -- bytes to be disassembled
922        size      -- (C++) size of the buffer
923     Returns an SBInstructionList.")
924     GetInstructions;
925     lldb::SBInstructionList
926     GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
927 
928     %feature("docstring", "
929     Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor.
930     Parameters:
931        base_addr -- used for symbolicating the offsets in the byte stream when disassembling
932        flavor    -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly
933        buf       -- bytes to be disassembled
934        size      -- (C++) size of the buffer
935     Returns an SBInstructionList.")
936     GetInstructionsWithFlavor;
937     lldb::SBInstructionList
938     GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
939 
940     lldb::SBSymbolContextList
941     FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
942 
943     bool
944     GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
945 
946     lldb::addr_t
947     GetStackRedZoneSize();
948 
949     lldb::SBLaunchInfo
950     GetLaunchInfo () const;
951 
952     void
953     SetLaunchInfo (const lldb::SBLaunchInfo &launch_info);
954 
955     void SetCollectingStats(bool v);
956 
957     bool GetCollectingStats();
958 
959     lldb::SBStructuredData GetStatistics();
960 
961     bool
962     operator == (const lldb::SBTarget &rhs) const;
963 
964     bool
965     operator != (const lldb::SBTarget &rhs) const;
966 
967     lldb::SBValue
968     EvaluateExpression (const char *expr);
969 
970     lldb::SBValue
971     EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
972 
973     STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief)
974 
975 #ifdef SWIGPYTHON
976     %pythoncode %{
977         class modules_access(object):
978             '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
979             def __init__(self, sbtarget):
980                 self.sbtarget = sbtarget
981 
982             def __len__(self):
983                 if self.sbtarget:
984                     return int(self.sbtarget.GetNumModules())
985                 return 0
986 
987             def __getitem__(self, key):
988                 num_modules = self.sbtarget.GetNumModules()
989                 if type(key) is int:
990                     if key < num_modules:
991                         return self.sbtarget.GetModuleAtIndex(key)
992                 elif type(key) is str:
993                     if key.find('/') == -1:
994                         for idx in range(num_modules):
995                             module = self.sbtarget.GetModuleAtIndex(idx)
996                             if module.file.basename == key:
997                                 return module
998                     else:
999                         for idx in range(num_modules):
1000                             module = self.sbtarget.GetModuleAtIndex(idx)
1001                             if module.file.fullpath == key:
1002                                 return module
1003                     # See if the string is a UUID
1004                     try:
1005                         the_uuid = uuid.UUID(key)
1006                         if the_uuid:
1007                             for idx in range(num_modules):
1008                                 module = self.sbtarget.GetModuleAtIndex(idx)
1009                                 if module.uuid == the_uuid:
1010                                     return module
1011                     except:
1012                         return None
1013                 elif type(key) is uuid.UUID:
1014                     for idx in range(num_modules):
1015                         module = self.sbtarget.GetModuleAtIndex(idx)
1016                         if module.uuid == key:
1017                             return module
1018                 elif type(key) is re.SRE_Pattern:
1019                     matching_modules = []
1020                     for idx in range(num_modules):
1021                         module = self.sbtarget.GetModuleAtIndex(idx)
1022                         re_match = key.search(module.path.fullpath)
1023                         if re_match:
1024                             matching_modules.append(module)
1025                     return matching_modules
1026                 else:
1027                     print("error: unsupported item type: %s" % type(key))
1028                 return None
1029 
1030         def get_modules_access_object(self):
1031             '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.'''
1032             return self.modules_access (self)
1033 
1034         def get_modules_array(self):
1035             '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
1036             modules = []
1037             for idx in range(self.GetNumModules()):
1038                 modules.append(self.GetModuleAtIndex(idx))
1039             return modules
1040 
1041         def module_iter(self):
1042             '''Returns an iterator over all modules in a lldb.SBTarget
1043             object.'''
1044             return lldb_iter(self, 'GetNumModules', 'GetModuleAtIndex')
1045 
1046         def breakpoint_iter(self):
1047             '''Returns an iterator over all breakpoints in a lldb.SBTarget
1048             object.'''
1049             return lldb_iter(self, 'GetNumBreakpoints', 'GetBreakpointAtIndex')
1050 
1051         def watchpoint_iter(self):
1052             '''Returns an iterator over all watchpoints in a lldb.SBTarget
1053             object.'''
1054             return lldb_iter(self, 'GetNumWatchpoints', 'GetWatchpointAtIndex')
1055 
1056         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).''')
1057         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.''')
1058         process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''')
1059         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.''')
1060         debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''')
1061         num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''')
1062         num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''')
1063         broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''')
1064         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.''')
1065         addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''')
1066         triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''')
1067         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.''')
1068         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.''')
1069         platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''')
1070     %}
1071 #endif
1072 };
1073 } // namespace lldb
1074