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 argv: The argument array.
212     :param envp: The environment array.
213     :param working_directory: The working directory to have the child process run in
214     :return: The newly created process.
215     :rtype: SBProcess
216 
217     A pseudo terminal will be used as stdin/stdout/stderr.
218     No launch flags are passed and the target's debuger is used as a listener.
219 
220     For example, ::
221 
222         process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
223 
224     launches a new process by passing 'X', 'Y', 'Z' as the args to the
225     executable.") LaunchSimple;
226     lldb::SBProcess
227     LaunchSimple (const char **argv,
228                   const char **envp,
229                   const char *working_directory);
230 
231     lldb::SBProcess
232     Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
233 
234     %feature("docstring", "
235     Load a core file
236 
237     @param[in] core_file
238         File path of the core dump.
239 
240     @param[out] error
241         An error explaining what went wrong if the operation fails.
242         (Optional)
243 
244     @return
245          A process object for the newly created core file.
246 
247     For example,
248 
249         process = target.LoadCore('./a.out.core')
250 
251     loads a new core file and returns the process object.") LoadCore;
252     lldb::SBProcess
253     LoadCore(const char *core_file);
254 
255     lldb::SBProcess
256     LoadCore(const char *core_file, lldb::SBError &error);
257 
258     lldb::SBProcess
259     Attach(lldb::SBAttachInfo &attach_info, lldb::SBError& error);
260 
261     %feature("docstring", "
262     Attach to process with pid.
263 
264     @param[in] listener
265         An optional listener that will receive all process events.
266         If listener is valid then listener will listen to all
267         process events. If not valid, then this target's debugger
268         (SBTarget::GetDebugger()) will listen to all process events.
269 
270     @param[in] pid
271         The process ID to attach to.
272 
273     @param[out]
274         An error explaining what went wrong if attach fails.
275 
276     @return
277          A process object for the attached process.") AttachToProcessWithID;
278     lldb::SBProcess
279     AttachToProcessWithID (SBListener &listener,
280                            lldb::pid_t pid,
281                            lldb::SBError& error);
282 
283     %feature("docstring", "
284     Attach to process with name.
285 
286     @param[in] listener
287         An optional listener that will receive all process events.
288         If listener is valid then listener will listen to all
289         process events. If not valid, then this target's debugger
290         (SBTarget::GetDebugger()) will listen to all process events.
291 
292     @param[in] name
293         Basename of process to attach to.
294 
295     @param[in] wait_for
296         If true wait for a new instance of 'name' to be launched.
297 
298     @param[out]
299         An error explaining what went wrong if attach fails.
300 
301     @return
302          A process object for the attached process.") AttachToProcessWithName;
303     lldb::SBProcess
304     AttachToProcessWithName (SBListener &listener,
305                              const char *name,
306                              bool wait_for,
307                              lldb::SBError& error);
308 
309     %feature("docstring", "
310     Connect to a remote debug server with url.
311 
312     @param[in] listener
313         An optional listener that will receive all process events.
314         If listener is valid then listener will listen to all
315         process events. If not valid, then this target's debugger
316         (SBTarget::GetDebugger()) will listen to all process events.
317 
318     @param[in] url
319         The url to connect to, e.g., 'connect://localhost:12345'.
320 
321     @param[in] plugin_name
322         The plugin name to be used; can be NULL.
323 
324     @param[out]
325         An error explaining what went wrong if the connect fails.
326 
327     @return
328          A process object for the connected process.") ConnectRemote;
329     lldb::SBProcess
330     ConnectRemote (SBListener &listener,
331                    const char *url,
332                    const char *plugin_name,
333                    SBError& error);
334 
335     lldb::SBFileSpec
336     GetExecutable ();
337 
338     %feature("docstring", "
339     Append the path mapping (from -> to) to the target's paths mapping list.") AppendImageSearchPath;
340     void
341     AppendImageSearchPath (const char *from,
342                            const char *to,
343                            SBError &error);
344 
345     bool
346     AddModule (lldb::SBModule &module);
347 
348     lldb::SBModule
349     AddModule (const char *path,
350                const char *triple,
351                const char *uuid);
352 
353     lldb::SBModule
354     AddModule (const char *path,
355                const char *triple,
356                const char *uuid_cstr,
357                const char *symfile);
358 
359     lldb::SBModule
360     AddModule (const SBModuleSpec &module_spec);
361 
362     uint32_t
363     GetNumModules () const;
364 
365     lldb::SBModule
366     GetModuleAtIndex (uint32_t idx);
367 
368     bool
369     RemoveModule (lldb::SBModule module);
370 
371     lldb::SBDebugger
372     GetDebugger() const;
373 
374     lldb::SBModule
375     FindModule (const lldb::SBFileSpec &file_spec);
376 
377     %feature("docstring", "
378     Find compile units related to this target and passed source
379     file.
380 
381     :param sb_file_spec: A :py:class:`lldb::SBFileSpec` object that contains source file
382         specification.
383     :return: The symbol contexts for all the matches.
384     :rtype: SBSymbolContextList") FindCompileUnits;
385     lldb::SBSymbolContextList
386     FindCompileUnits (const lldb::SBFileSpec &sb_file_spec);
387 
388     lldb::ByteOrder
389     GetByteOrder ();
390 
391     uint32_t
392     GetAddressByteSize();
393 
394     const char *
395     GetTriple ();
396 
397     const char *
398     GetABIName();
399 
400     %feature("docstring", "
401     Architecture data byte width accessor
402 
403     :return: The size in 8-bit (host) bytes of a minimum addressable unit from the Architecture's data bus.
404 
405     ") GetDataByteSize;
406     uint32_t
407     GetDataByteSize ();
408 
409     %feature("docstring", "
410     Architecture code byte width accessor.
411 
412     :return: The size in 8-bit (host) bytes of a minimum addressable unit from the Architecture's code bus.
413 
414     ") GetCodeByteSize;
415     uint32_t
416     GetCodeByteSize ();
417 
418     uint32_t
419     GetMaximumNumberOfChildrenToDisplay() const;
420 
421     lldb::SBError
422     SetSectionLoadAddress (lldb::SBSection section,
423                            lldb::addr_t section_base_addr);
424 
425     lldb::SBError
426     ClearSectionLoadAddress (lldb::SBSection section);
427 
428     lldb::SBError
429     SetModuleLoadAddress (lldb::SBModule module,
430                           int64_t sections_offset);
431 
432     lldb::SBError
433     ClearModuleLoadAddress (lldb::SBModule module);
434 
435     %feature("docstring", "
436     Find functions by name.
437 
438     :param name: The name of the function we are looking for.
439 
440     :param name_type_mask:
441         A logical OR of one or more FunctionNameType enum bits that
442         indicate what kind of names should be used when doing the
443         lookup. Bits include fully qualified names, base names,
444         C++ methods, or ObjC selectors.
445         See FunctionNameType for more details.
446 
447     :return:
448         A lldb::SBSymbolContextList that gets filled in with all of
449         the symbol contexts for all the matches.") FindFunctions;
450     lldb::SBSymbolContextList
451     FindFunctions (const char *name,
452                    uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
453 
454     lldb::SBType
455     FindFirstType (const char* type);
456 
457     lldb::SBTypeList
458     FindTypes (const char* type);
459 
460     lldb::SBType
461     GetBasicType(lldb::BasicType type);
462 
463     lldb::SBSourceManager
464     GetSourceManager ();
465 
466     %feature("docstring", "
467     Find global and static variables by name.
468 
469     @param[in] name
470         The name of the global or static variable we are looking
471         for.
472 
473     @param[in] max_matches
474         Allow the number of matches to be limited to max_matches.
475 
476     @return
477         A list of matched variables in an SBValueList.") FindGlobalVariables;
478     lldb::SBValueList
479     FindGlobalVariables (const char *name,
480                          uint32_t max_matches);
481 
482      %feature("docstring", "
483     Find the first global (or static) variable by name.
484 
485     @param[in] name
486         The name of the global or static variable we are looking
487         for.
488 
489     @return
490         An SBValue that gets filled in with the found variable (if any).") FindFirstGlobalVariable;
491     lldb::SBValue
492     FindFirstGlobalVariable (const char* name);
493 
494 
495     lldb::SBValueList
496     FindGlobalVariables(const char *name,
497                         uint32_t max_matches,
498                         MatchType matchtype);
499 
500     lldb::SBSymbolContextList
501     FindGlobalFunctions(const char *name,
502                         uint32_t max_matches,
503                         MatchType matchtype);
504 
505     void
506     Clear ();
507 
508      %feature("docstring", "
509     Resolve a current file address into a section offset address.
510 
511     @param[in] file_addr
512 
513     @return
514         An SBAddress which will be valid if...") ResolveFileAddress;
515     lldb::SBAddress
516     ResolveFileAddress (lldb::addr_t file_addr);
517 
518     lldb::SBAddress
519     ResolveLoadAddress (lldb::addr_t vm_addr);
520 
521     lldb::SBAddress
522     ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr);
523 
524     SBSymbolContext
525     ResolveSymbolContextForAddress (const SBAddress& addr,
526                                     uint32_t resolve_scope);
527 
528      %feature("docstring", "
529     Read target memory. If a target process is running then memory
530     is read from here. Otherwise the memory is read from the object
531     files. For a target whose bytes are sized as a multiple of host
532     bytes, the data read back will preserve the target's byte order.
533 
534     @param[in] addr
535         A target address to read from.
536 
537     @param[out] buf
538         The buffer to read memory into.
539 
540     @param[in] size
541         The maximum number of host bytes to read in the buffer passed
542         into this call
543 
544     @param[out] error
545         Error information is written here if the memory read fails.
546 
547     @return
548         The amount of data read in host bytes.") ReadMemory;
549     size_t
550     ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
551 
552     lldb::SBBreakpoint
553     BreakpointCreateByLocation (const char *file, uint32_t line);
554 
555     lldb::SBBreakpoint
556     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
557 
558     lldb::SBBreakpoint
559     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset);
560 
561     lldb::SBBreakpoint
562     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
563                                 lldb::addr_t offset, SBFileSpecList &module_list);
564 
565     lldb::SBBreakpoint
566     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
567                                 uint32_t column, lldb::addr_t offset,
568                                 SBFileSpecList &module_list);
569 
570     lldb::SBBreakpoint
571     BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
572                                 uint32_t column, lldb::addr_t offset,
573                                 SBFileSpecList &module_list,
574                                 bool move_to_nearest_code);
575 
576     lldb::SBBreakpoint
577     BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
578 
579     lldb::SBBreakpoint
580     BreakpointCreateByName (const char *symbol_name,
581                             uint32_t func_name_type,           // Logical OR one or more FunctionNameType enum bits
582                             const SBFileSpecList &module_list,
583                             const SBFileSpecList &comp_unit_list);
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                             lldb::LanguageType symbol_language,
589                             const SBFileSpecList &module_list,
590                             const SBFileSpecList &comp_unit_list);
591 
592 #ifdef SWIGPYTHON
593 %typemap(in) (const char **symbol_name, uint32_t num_names) {
594   using namespace lldb_private;
595   /* Check if is a list  */
596   if (PythonList::Check($input)) {
597     PythonList list(PyRefType::Borrowed, $input);
598     $2 = list.GetSize();
599     int i = 0;
600     $1 = (char**)malloc(($2+1)*sizeof(char*));
601     for (i = 0; i < $2; i++) {
602       PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>();
603       if (!py_str.IsAllocated()) {
604         PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby");
605         free($1);
606         return nullptr;
607       }
608 
609       $1[i] = const_cast<char*>(py_str.GetString().data());
610     }
611     $1[i] = 0;
612   } else if ($input == Py_None) {
613     $1 =  NULL;
614   } else {
615     PyErr_SetString(PyExc_TypeError,"not a list");
616     return NULL;
617   }
618 }
619 #endif
620 
621     lldb::SBBreakpoint
622     BreakpointCreateByNames (const char **symbol_name,
623                              uint32_t num_names,
624                              uint32_t name_type_mask,           // Logical OR one or more FunctionNameType enum bits
625                              const SBFileSpecList &module_list,
626                              const SBFileSpecList &comp_unit_list);
627 
628     lldb::SBBreakpoint
629     BreakpointCreateByNames (const char **symbol_name,
630                              uint32_t num_names,
631                              uint32_t name_type_mask,           // Logical OR one or more FunctionNameType enum bits
632                              lldb::LanguageType symbol_language,
633                              const SBFileSpecList &module_list,
634                              const SBFileSpecList &comp_unit_list);
635 
636     lldb::SBBreakpoint
637     BreakpointCreateByNames (const char **symbol_name,
638                              uint32_t num_names,
639                              uint32_t name_type_mask,           // Logical OR one or more FunctionNameType enum bits
640                              lldb::LanguageType symbol_language,
641                              lldb::addr_t offset,
642                              const SBFileSpecList &module_list,
643                              const SBFileSpecList &comp_unit_list);
644 
645     lldb::SBBreakpoint
646     BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
647 
648     lldb::SBBreakpoint
649     BreakpointCreateByRegex (const char *symbol_name_regex,
650                              lldb::LanguageType symbol_language,
651                              const SBFileSpecList &module_list,
652                              const SBFileSpecList &comp_unit_list);
653 
654     lldb::SBBreakpoint
655     BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
656 
657     lldb::SBBreakpoint
658     BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list);
659 
660     lldb::SBBreakpoint
661     BreakpointCreateBySourceRegex (const char *source_regex,
662                                    const SBFileSpecList &module_list,
663                                    const SBFileSpecList &source_file,
664                                    const SBStringList  &func_names);
665 
666     lldb::SBBreakpoint
667     BreakpointCreateForException  (lldb::LanguageType language,
668                                    bool catch_bp,
669                                    bool throw_bp);
670 
671     lldb::SBBreakpoint
672     BreakpointCreateByAddress (addr_t address);
673 
674     lldb::SBEnvironment
675     GetEnvironment();
676 
677     lldb::SBBreakpoint
678     BreakpointCreateBySBAddress (SBAddress &sb_address);
679 
680     %feature("docstring", "
681     Create a breakpoint using a scripted resolver.
682 
683     @param[in] class_name
684        This is the name of the class that implements a scripted resolver.
685        The class should have the following signature: ::
686 
687            class Resolver:
688                def __init__(self, bkpt, extra_args):
689                    # bkpt - the breakpoint for which this is the resolver.  When
690                    # the resolver finds an interesting address, call AddLocation
691                    # on this breakpoint to add it.
692                    #
693                    # extra_args - an SBStructuredData that can be used to
694                    # parametrize this instance.  Same as the extra_args passed
695                    # to BreakpointCreateFromScript.
696 
697                def __get_depth__ (self):
698                    # This is optional, but if defined, you should return the
699                    # depth at which you want the callback to be called.  The
700                    # available options are:
701                    #    lldb.eSearchDepthModule
702                    #    lldb.eSearchDepthCompUnit
703                    # The default if you don't implement this method is
704                    # eSearchDepthModule.
705 
706                def __callback__(self, sym_ctx):
707                    # sym_ctx - an SBSymbolContext that is the cursor in the
708                    # search through the program to resolve breakpoints.
709                    # The sym_ctx will be filled out to the depth requested in
710                    # __get_depth__.
711                    # Look in this sym_ctx for new breakpoint locations,
712                    # and if found use bkpt.AddLocation to add them.
713                    # Note, you will only get called for modules/compile_units that
714                    # pass the SearchFilter provided by the module_list & file_list
715                    # passed into BreakpointCreateFromScript.
716 
717                def get_short_help(self):
718                    # Optional, but if implemented return a short string that will
719                    # be printed at the beginning of the break list output for the
720                    # breakpoint.
721 
722     @param[in] extra_args
723        This is an SBStructuredData object that will get passed to the
724        constructor of the class in class_name.  You can use this to
725        reuse the same class, parametrizing it with entries from this
726        dictionary.
727 
728     @param module_list
729        If this is non-empty, this will be used as the module filter in the
730        SearchFilter created for this breakpoint.
731 
732     @param file_list
733        If this is non-empty, this will be used as the comp unit filter in the
734        SearchFilter created for this breakpoint.
735 
736     @return
737         An SBBreakpoint that will set locations based on the logic in the
738         resolver's search callback.") BreakpointCreateFromScript;
739     lldb::SBBreakpoint BreakpointCreateFromScript(
740       const char *class_name,
741       SBStructuredData &extra_args,
742       const SBFileSpecList &module_list,
743       const SBFileSpecList &file_list,
744       bool request_hardware = false);
745 
746     uint32_t
747     GetNumBreakpoints () const;
748 
749     lldb::SBBreakpoint
750     GetBreakpointAtIndex (uint32_t idx) const;
751 
752     bool
753     BreakpointDelete (break_id_t break_id);
754 
755     lldb::SBBreakpoint
756     FindBreakpointByID (break_id_t break_id);
757 
758 
759     bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
760 
761     void DeleteBreakpointName(const char *name);
762 
763     void GetBreakpointNames(SBStringList &names);
764 
765     bool
766     EnableAllBreakpoints ();
767 
768     bool
769     DisableAllBreakpoints ();
770 
771     bool
772     DeleteAllBreakpoints ();
773 
774      %feature("docstring", "
775     Read breakpoints from source_file and return the newly created
776     breakpoints in bkpt_list.
777 
778     @param[in] source_file
779        The file from which to read the breakpoints
780 
781     @param[out] bkpt_list
782        A list of the newly created breakpoints.
783 
784     @return
785         An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile;
786     lldb::SBError
787     BreakpointsCreateFromFile(SBFileSpec &source_file,
788                               SBBreakpointList &bkpt_list);
789 
790      %feature("docstring", "
791     Read breakpoints from source_file and return the newly created
792     breakpoints in bkpt_list.
793 
794     @param[in] source_file
795        The file from which to read the breakpoints
796 
797     @param[in] matching_names
798        Only read in breakpoints whose names match one of the names in this
799        list.
800 
801     @param[out] bkpt_list
802        A list of the newly created breakpoints.
803 
804     @return
805         An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile;
806     lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
807                                           SBStringList &matching_names,
808                                           SBBreakpointList &new_bps);
809 
810      %feature("docstring", "
811     Write breakpoints to dest_file.
812 
813     @param[in] dest_file
814        The file to which to write the breakpoints.
815 
816     @return
817         An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile;
818     lldb::SBError
819     BreakpointsWriteToFile(SBFileSpec &dest_file);
820 
821      %feature("docstring", "
822     Write breakpoints listed in bkpt_list to dest_file.
823 
824     @param[in] dest_file
825        The file to which to write the breakpoints.
826 
827     @param[in] bkpt_list
828        Only write breakpoints from this list.
829 
830     @param[in] append
831        If true, append the breakpoints in bkpt_list to the others
832        serialized in dest_file.  If dest_file doesn't exist, then a new
833        file will be created and the breakpoints in bkpt_list written to it.
834 
835     @return
836         An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile;
837     lldb::SBError
838     BreakpointsWriteToFile(SBFileSpec &dest_file,
839                            SBBreakpointList &bkpt_list,
840                            bool append = false);
841 
842     uint32_t
843     GetNumWatchpoints () const;
844 
845     lldb::SBWatchpoint
846     GetWatchpointAtIndex (uint32_t idx) const;
847 
848     bool
849     DeleteWatchpoint (lldb::watch_id_t watch_id);
850 
851     lldb::SBWatchpoint
852     FindWatchpointByID (lldb::watch_id_t watch_id);
853 
854     bool
855     EnableAllWatchpoints ();
856 
857     bool
858     DisableAllWatchpoints ();
859 
860     bool
861     DeleteAllWatchpoints ();
862 
863     lldb::SBWatchpoint
864     WatchAddress (lldb::addr_t addr,
865                   size_t size,
866                   bool read,
867                   bool write,
868                   SBError &error);
869 
870 
871     lldb::SBBroadcaster
872     GetBroadcaster () const;
873 
874      %feature("docstring", "
875     Create an SBValue with the given name by treating the memory starting at addr as an entity of type.
876 
877     @param[in] name
878         The name of the resultant SBValue
879 
880     @param[in] addr
881         The address of the start of the memory region to be used.
882 
883     @param[in] type
884         The type to use to interpret the memory starting at addr.
885 
886     @return
887         An SBValue of the given type, may be invalid if there was an error reading
888         the underlying memory.") CreateValueFromAddress;
889     lldb::SBValue
890     CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
891 
892     lldb::SBValue
893     CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type);
894 
895     lldb::SBValue
896     CreateValueFromExpression (const char *name, const char* expr);
897 
898     %feature("docstring", "
899     Disassemble a specified number of instructions starting at an address.
900 
901     :param base_addr: the address to start disassembly from.
902     :param count: the number of instructions to disassemble.
903     :param flavor_string: may be 'intel' or 'att' on x86 targets to specify that style of disassembly.
904     :rtype: SBInstructionList
905     ")
906     ReadInstructions;
907     lldb::SBInstructionList
908     ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
909 
910     lldb::SBInstructionList
911     ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
912 
913     %feature("docstring", "
914     Disassemble the bytes in a buffer and return them in an SBInstructionList.
915 
916     :param base_addr: used for symbolicating the offsets in the byte stream when disassembling.
917     :param buf: bytes to be disassembled.
918     :param size: (C++) size of the buffer.
919     :rtype: SBInstructionList
920     ")
921     GetInstructions;
922     lldb::SBInstructionList
923     GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
924 
925     %feature("docstring", "
926     Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor.
927 
928     :param base_addr: used for symbolicating the offsets in the byte stream when disassembling.
929     :param flavor:  may be 'intel' or 'att' on x86 targets to specify that style of disassembly.
930     :param buf: bytes to be disassembled.
931     :param size: (C++) size of the buffer.
932     :rtype: SBInstructionList
933     ")
934     GetInstructionsWithFlavor;
935     lldb::SBInstructionList
936     GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
937 
938     lldb::SBSymbolContextList
939     FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
940 
941     bool
942     GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
943 
944     lldb::addr_t
945     GetStackRedZoneSize();
946 
947     %feature("docstring", "
948     Returns true if the module has been loaded in this `SBTarget`.
949     A module can be loaded either by the dynamic loader or by being manually
950     added to the target (see `SBTarget.AddModule` and the ``target module add`` command).
951 
952     :rtype: bool
953     ") IsLoaded;
954     bool
955     IsLoaded (const lldb::SBModule &module) const;
956 
957     lldb::SBLaunchInfo
958     GetLaunchInfo () const;
959 
960     void
961     SetLaunchInfo (const lldb::SBLaunchInfo &launch_info);
962 
963     void SetCollectingStats(bool v);
964 
965     bool GetCollectingStats();
966 
967     lldb::SBStructuredData GetStatistics();
968 
969     bool
970     operator == (const lldb::SBTarget &rhs) const;
971 
972     bool
973     operator != (const lldb::SBTarget &rhs) const;
974 
975     lldb::SBValue
976     EvaluateExpression (const char *expr);
977 
978     lldb::SBValue
979     EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
980 
981     STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief)
982 
983     lldb::SBTrace
984     GetTrace ();
985 
986     lldb::SBTrace
987     CreateTrace (lldb::SBError &error);
988 
989 #ifdef SWIGPYTHON
990     %pythoncode %{
991         class modules_access(object):
992             '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
993             def __init__(self, sbtarget):
994                 self.sbtarget = sbtarget
995 
996             def __len__(self):
997                 if self.sbtarget:
998                     return int(self.sbtarget.GetNumModules())
999                 return 0
1000 
1001             def __getitem__(self, key):
1002                 num_modules = self.sbtarget.GetNumModules()
1003                 if type(key) is int:
1004                     if key < num_modules:
1005                         return self.sbtarget.GetModuleAtIndex(key)
1006                 elif type(key) is str:
1007                     if key.find('/') == -1:
1008                         for idx in range(num_modules):
1009                             module = self.sbtarget.GetModuleAtIndex(idx)
1010                             if module.file.basename == key:
1011                                 return module
1012                     else:
1013                         for idx in range(num_modules):
1014                             module = self.sbtarget.GetModuleAtIndex(idx)
1015                             if module.file.fullpath == key:
1016                                 return module
1017                     # See if the string is a UUID
1018                     try:
1019                         the_uuid = uuid.UUID(key)
1020                         if the_uuid:
1021                             for idx in range(num_modules):
1022                                 module = self.sbtarget.GetModuleAtIndex(idx)
1023                                 if module.uuid == the_uuid:
1024                                     return module
1025                     except:
1026                         return None
1027                 elif type(key) is uuid.UUID:
1028                     for idx in range(num_modules):
1029                         module = self.sbtarget.GetModuleAtIndex(idx)
1030                         if module.uuid == key:
1031                             return module
1032                 elif type(key) is re.SRE_Pattern:
1033                     matching_modules = []
1034                     for idx in range(num_modules):
1035                         module = self.sbtarget.GetModuleAtIndex(idx)
1036                         re_match = key.search(module.path.fullpath)
1037                         if re_match:
1038                             matching_modules.append(module)
1039                     return matching_modules
1040                 else:
1041                     print("error: unsupported item type: %s" % type(key))
1042                 return None
1043 
1044         def get_modules_access_object(self):
1045             '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.'''
1046             return self.modules_access (self)
1047 
1048         def get_modules_array(self):
1049             '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
1050             modules = []
1051             for idx in range(self.GetNumModules()):
1052                 modules.append(self.GetModuleAtIndex(idx))
1053             return modules
1054 
1055         def module_iter(self):
1056             '''Returns an iterator over all modules in a lldb.SBTarget
1057             object.'''
1058             return lldb_iter(self, 'GetNumModules', 'GetModuleAtIndex')
1059 
1060         def breakpoint_iter(self):
1061             '''Returns an iterator over all breakpoints in a lldb.SBTarget
1062             object.'''
1063             return lldb_iter(self, 'GetNumBreakpoints', 'GetBreakpointAtIndex')
1064 
1065         def watchpoint_iter(self):
1066             '''Returns an iterator over all watchpoints in a lldb.SBTarget
1067             object.'''
1068             return lldb_iter(self, 'GetNumWatchpoints', 'GetWatchpointAtIndex')
1069 
1070         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).''')
1071         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.''')
1072         process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''')
1073         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.''')
1074         debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''')
1075         num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''')
1076         num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''')
1077         broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''')
1078         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.''')
1079         addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''')
1080         triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''')
1081         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.''')
1082         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.''')
1083         platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''')
1084     %}
1085 #endif
1086 };
1087 } // namespace lldb
1088