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