summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-07-18 21:30:21 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-07-18 21:30:21 +0000
commit5de6a790f25f1ffd30d77008cf1d3ffa2db22e4d (patch)
tree4bc9c65a6a16721da15fcef91e71147c3714ab99
parent22c52d9a982313c5896f3ba0d9e8ba009ed51e88 (diff)
downloadbcm5719-llvm-5de6a790f25f1ffd30d77008cf1d3ffa2db22e4d.tar.gz
bcm5719-llvm-5de6a790f25f1ffd30d77008cf1d3ffa2db22e4d.zip
Add SWIG Python interface files for SBAddress, SBBlock, SBBreakpoint, and SBBreakpointLocation.
llvm-svn: 135430
-rw-r--r--lldb/include/lldb/API/SBAddress.h39
-rw-r--r--lldb/include/lldb/API/SBBlock.h46
-rw-r--r--lldb/include/lldb/API/SBBreakpoint.h68
-rw-r--r--lldb/include/lldb/API/SBBreakpointLocation.h16
-rw-r--r--lldb/scripts/Python/interface/SBAddress.i80
-rw-r--r--lldb/scripts/Python/interface/SBBlock.i78
-rw-r--r--lldb/scripts/Python/interface/SBBreakpoint.i176
-rw-r--r--lldb/scripts/Python/interface/SBBreakpointLocation.i90
-rw-r--r--lldb/scripts/lldb.swig8
9 files changed, 428 insertions, 173 deletions
diff --git a/lldb/include/lldb/API/SBAddress.h b/lldb/include/lldb/API/SBAddress.h
index 195b03538aa..3b45a154e37 100644
--- a/lldb/include/lldb/API/SBAddress.h
+++ b/lldb/include/lldb/API/SBAddress.h
@@ -15,47 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"A section + offset based address class.
-
-The SBAddress class allows addresses to be relative to a section
-that can move during runtime due to images (executables, shared
-libraries, bundles, frameworks) being loaded at different
-addresses than the addresses found in the object file that
-represents them on disk. There are currently two types of addresses
-for a section:
- o file addresses
- o load addresses
-
-File addresses represents the virtual addresses that are in the 'on
-disk' object files. These virtual addresses are converted to be
-relative to unique sections scoped to the object file so that
-when/if the addresses slide when the images are loaded/unloaded
-in memory, we can easily track these changes without having to
-update every object (compile unit ranges, line tables, function
-address ranges, lexical block and inlined subroutine address
-ranges, global and static variables) each time an image is loaded or
-unloaded.
-
-Load addresses represents the virtual addresses where each section
-ends up getting loaded at runtime. Before executing a program, it
-is common for all of the load addresses to be unresolved. When a
-DynamicLoader plug-in receives notification that shared libraries
-have been loaded/unloaded, the load addresses of the main executable
-and any images (shared libraries) will be resolved/unresolved. When
-this happens, breakpoints that are in one of these sections can be
-set/cleared.
-
-See docstring of SBFunction for example usage of SBAddress.
-"
- ) SBAddress;
-#endif
class SBAddress
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBAddress ();
diff --git a/lldb/include/lldb/API/SBBlock.h b/lldb/include/lldb/API/SBBlock.h
index 331b540222c..7a3b2a61ce8 100644
--- a/lldb/include/lldb/API/SBBlock.h
+++ b/lldb/include/lldb/API/SBBlock.h
@@ -14,16 +14,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
- "Represents a lexical block. SBFunction contains SBBlock(s)."
- ) SBBlock;
-#endif
class SBBlock
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBBlock ();
@@ -37,68 +29,30 @@ public:
operator = (const lldb::SBBlock &rhs);
#endif
-#ifdef SWIG
- %feature("docstring",
- "Does this block represent an inlined function?"
- ) IsInlined;
-#endif
bool
IsInlined () const;
bool
IsValid () const;
-#ifdef SWIG
- %feature("autodoc",
- "Get the function name if this block represents an inlined function;\n"
- "otherwise, return None."
- ) GetInlinedName;
-#endif
const char *
GetInlinedName () const;
-#ifdef SWIG
- %feature("docstring",
- "Get the call site file if this block represents an inlined function;\n"
- "otherwise, return an invalid file spec."
- ) GetInlinedCallSiteFile;
-#endif
lldb::SBFileSpec
GetInlinedCallSiteFile () const;
-#ifdef SWIG
- %feature("docstring",
- "Get the call site line if this block represents an inlined function;\n"
- "otherwise, return 0."
- ) GetInlinedCallSiteLine;
-#endif
uint32_t
GetInlinedCallSiteLine () const;
-#ifdef SWIG
- %feature("docstring",
- "Get the call site column if this block represents an inlined function;\n"
- "otherwise, return 0."
- ) GetInlinedCallSiteColumn;
-#endif
uint32_t
GetInlinedCallSiteColumn () const;
-#ifdef SWIG
- %feature("docstring", "Get the parent block.") GetParent;
-#endif
lldb::SBBlock
GetParent ();
-#ifdef SWIG
- %feature("docstring", "Get the sibling block for this block.") GetSibling;
-#endif
lldb::SBBlock
GetSibling ();
-#ifdef SWIG
- %feature("docstring", "Get the first child block.") GetFirstChild;
-#endif
lldb::SBBlock
GetFirstChild ();
diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h
index 96bd2cff4ea..faa970ab4b5 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -15,76 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents a logical breakpoint and its associated settings.
-
-For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
-TestBreakpointIgnoreCount.py),
-
- def breakpoint_ignore_count_python(self):
- '''Use Python APIs to set breakpoint ignore count.'''
- exe = os.path.join(os.getcwd(), 'a.out')
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- # Now create a breakpoint on main.c by name 'c'.
- breakpoint = target.BreakpointCreateByName('c', 'a.out')
- self.assertTrue(breakpoint and
- breakpoint.GetNumLocations() == 1,
- VALID_BREAKPOINT)
-
- # Get the breakpoint location from breakpoint after we verified that,
- # indeed, it has one location.
- location = breakpoint.GetLocationAtIndex(0)
- self.assertTrue(location and
- location.IsEnabled(),
- VALID_BREAKPOINT_LOCATION)
-
- # Set the ignore count on the breakpoint location.
- location.SetIgnoreCount(2)
- self.assertTrue(location.GetIgnoreCount() == 2,
- 'SetIgnoreCount() works correctly')
-
- # Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple(None, None, os.getcwd())
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
- # frame#2 should be on main.c:48.
- #lldbutil.print_stacktraces(process)
- from lldbutil import get_stopped_thread
- thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
- frame0 = thread.GetFrameAtIndex(0)
- frame1 = thread.GetFrameAtIndex(1)
- frame2 = thread.GetFrameAtIndex(2)
- self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
- frame1.GetLineEntry().GetLine() == self.line3 and
- frame2.GetLineEntry().GetLine() == self.line4,
- STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
-
- # The hit count for the breakpoint should be 3.
- self.assertTrue(breakpoint.GetHitCount() == 3)
-
- process.Continue()
-
-SBBreakpoint supports breakpoint location iteration. For example,
-
- for bl in breakpoint:
- print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
- print 'breakpoint location condition: %s' % hex(bl.GetCondition())
-
-"
- ) SBBreakpoint;
-#endif
class SBBreakpoint
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
typedef bool (*BreakpointHitCallback) (void *baton,
diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h
index 29cbf2e76e2..0865952dd91 100644
--- a/lldb/include/lldb/API/SBBreakpointLocation.h
+++ b/lldb/include/lldb/API/SBBreakpointLocation.h
@@ -15,24 +15,8 @@
namespace lldb {
-#ifdef SWIG
-%feature("docstring",
-"Represents one unique instance (by address) of a logical breakpoint.
-
-A breakpoint location is defined by the breakpoint that produces it,
-and the address that resulted in this particular instantiation.
-Each breakpoint location has its settable options.
-
-SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint
-for retrieval of an SBBreakpointLocation from an SBBreakpoint.
-"
- ) SBBreakpointLocation;
-#endif
class SBBreakpointLocation
{
-#ifdef SWIG
- %feature("autodoc", "1");
-#endif
public:
SBBreakpointLocation ();
diff --git a/lldb/scripts/Python/interface/SBAddress.i b/lldb/scripts/Python/interface/SBAddress.i
new file mode 100644
index 00000000000..83d624fb927
--- /dev/null
+++ b/lldb/scripts/Python/interface/SBAddress.i
@@ -0,0 +1,80 @@
+//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"A section + offset based address class.
+
+The SBAddress class allows addresses to be relative to a section
+that can move during runtime due to images (executables, shared
+libraries, bundles, frameworks) being loaded at different
+addresses than the addresses found in the object file that
+represents them on disk. There are currently two types of addresses
+for a section:
+ o file addresses
+ o load addresses
+
+File addresses represents the virtual addresses that are in the 'on
+disk' object files. These virtual addresses are converted to be
+relative to unique sections scoped to the object file so that
+when/if the addresses slide when the images are loaded/unloaded
+in memory, we can easily track these changes without having to
+update every object (compile unit ranges, line tables, function
+address ranges, lexical block and inlined subroutine address
+ranges, global and static variables) each time an image is loaded or
+unloaded.
+
+Load addresses represents the virtual addresses where each section
+ends up getting loaded at runtime. Before executing a program, it
+is common for all of the load addresses to be unresolved. When a
+DynamicLoader plug-in receives notification that shared libraries
+have been loaded/unloaded, the load addresses of the main executable
+and any images (shared libraries) will be resolved/unresolved. When
+this happens, breakpoints that are in one of these sections can be
+set/cleared.
+
+See docstring of SBFunction for example usage of SBAddress."
+) SBAddress;
+class SBAddress
+{
+public:
+
+ SBAddress ();
+
+ SBAddress (const lldb::SBAddress &rhs);
+
+ ~SBAddress ();
+
+ bool
+ IsValid () const;
+
+ void
+ Clear ();
+
+ addr_t
+ GetFileAddress () const;
+
+ addr_t
+ GetLoadAddress (const lldb::SBTarget &target) const;
+
+ bool
+ OffsetAddress (addr_t offset);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ SectionType
+ GetSectionType ();
+
+ lldb::SBModule
+ GetModule ();
+};
+
+} // namespace lldb
diff --git a/lldb/scripts/Python/interface/SBBlock.i b/lldb/scripts/Python/interface/SBBlock.i
new file mode 100644
index 00000000000..ec11fc1f00c
--- /dev/null
+++ b/lldb/scripts/Python/interface/SBBlock.i
@@ -0,0 +1,78 @@
+//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a lexical block. SBFunction contains SBBlock(s)."
+) SBBlock;
+class SBBlock
+{
+public:
+
+ SBBlock ();
+
+ SBBlock (const lldb::SBBlock &rhs);
+
+ ~SBBlock ();
+
+ %feature("docstring",
+ "Does this block represent an inlined function?"
+ ) IsInlined;
+ bool
+ IsInlined () const;
+
+ bool
+ IsValid () const;
+
+ %feature("docstring", "
+ Get the function name if this block represents an inlined function;
+ otherwise, return None.
+ ") GetInlinedName;
+ const char *
+ GetInlinedName () const;
+
+ %feature("docstring", "
+ Get the call site file if this block represents an inlined function;
+ otherwise, return an invalid file spec.
+ ") GetInlinedCallSiteFile;
+ lldb::SBFileSpec
+ GetInlinedCallSiteFile () const;
+
+ %feature("docstring", "
+ Get the call site line if this block represents an inlined function;
+ otherwise, return 0.
+ ") GetInlinedCallSiteLine;
+ uint32_t
+ GetInlinedCallSiteLine () const;
+
+ %feature("docstring", "
+ Get the call site column if this block represents an inlined function;
+ otherwise, return 0.
+ ") GetInlinedCallSiteColumn;
+ uint32_t
+ GetInlinedCallSiteColumn () const;
+
+ %feature("docstring", "Get the parent block.") GetParent;
+ lldb::SBBlock
+ GetParent ();
+
+ %feature("docstring", "Get the sibling block for this block.") GetSibling;
+ lldb::SBBlock
+ GetSibling ();
+
+ %feature("docstring", "Get the first child block.") GetFirstChild;
+ lldb::SBBlock
+ GetFirstChild ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+};
+
+} // namespace lldb
diff --git a/lldb/scripts/Python/interface/SBBreakpoint.i b/lldb/scripts/Python/interface/SBBreakpoint.i
new file mode 100644
index 00000000000..3c2920a5f41
--- /dev/null
+++ b/lldb/scripts/Python/interface/SBBreakpoint.i
@@ -0,0 +1,176 @@
+//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a logical breakpoint and its associated settings.
+
+For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
+TestBreakpointIgnoreCount.py),
+
+ def breakpoint_ignore_count_python(self):
+ '''Use Python APIs to set breakpoint ignore count.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Get the breakpoint location from breakpoint after we verified that,
+ # indeed, it has one location.
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location and
+ location.IsEnabled(),
+ VALID_BREAKPOINT_LOCATION)
+
+ # Set the ignore count on the breakpoint location.
+ location.SetIgnoreCount(2)
+ self.assertTrue(location.GetIgnoreCount() == 2,
+ 'SetIgnoreCount() works correctly')
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
+ # frame#2 should be on main.c:48.
+ #lldbutil.print_stacktraces(process)
+ from lldbutil import get_stopped_thread
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
+ frame0 = thread.GetFrameAtIndex(0)
+ frame1 = thread.GetFrameAtIndex(1)
+ frame2 = thread.GetFrameAtIndex(2)
+ self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
+ frame1.GetLineEntry().GetLine() == self.line3 and
+ frame2.GetLineEntry().GetLine() == self.line4,
+ STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
+
+ # The hit count for the breakpoint should be 3.
+ self.assertTrue(breakpoint.GetHitCount() == 3)
+
+ process.Continue()
+
+SBBreakpoint supports breakpoint location iteration. For example,
+
+ for bl in breakpoint:
+ print 'breakpoint location load addr: %s' % hex(bl.GetLoadAddress())
+ print 'breakpoint location condition: %s' % hex(bl.GetCondition())
+") SBBreakpoint;
+class SBBreakpoint
+{
+public:
+
+ typedef bool (*BreakpointHitCallback) (void *baton,
+ SBProcess &process,
+ SBThread &thread,
+ lldb::SBBreakpointLocation &location);
+
+ SBBreakpoint ();
+
+ SBBreakpoint (const lldb::SBBreakpoint& rhs);
+
+ ~SBBreakpoint();
+
+ break_id_t
+ GetID () const;
+
+ bool
+ IsValid() const;
+
+ void
+ ClearAllBreakpointSites ();
+
+ lldb::SBBreakpointLocation
+ FindLocationByAddress (lldb::addr_t vm_addr);
+
+ lldb::break_id_t
+ FindLocationIDByAddress (lldb::addr_t vm_addr);
+
+ lldb::SBBreakpointLocation
+ FindLocationByID (lldb::break_id_t bp_loc_id);
+
+ lldb::SBBreakpointLocation
+ GetLocationAtIndex (uint32_t index);
+
+ void
+ SetEnabled (bool enable);
+
+ bool
+ IsEnabled ();
+
+ uint32_t
+ GetHitCount () const;
+
+ void
+ SetIgnoreCount (uint32_t count);
+
+ uint32_t
+ GetIgnoreCount () const;
+
+ void
+ SetCondition (const char *condition);
+
+ const char *
+ GetCondition ();
+
+ void
+ SetThreadID (lldb::tid_t sb_thread_id);
+
+ lldb::tid_t
+ GetThreadID ();
+
+ void
+ SetThreadIndex (uint32_t index);
+
+ uint32_t
+ GetThreadIndex() const;
+
+ void
+ SetThreadName (const char *thread_name);
+
+ const char *
+ GetThreadName () const;
+
+ void
+ SetQueueName (const char *queue_name);
+
+ const char *
+ GetQueueName () const;
+
+ void
+ SetCallback (BreakpointHitCallback callback, void *baton);
+
+ size_t
+ GetNumResolvedLocations() const;
+
+ size_t
+ GetNumLocations() const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ static lldb::BreakpointEventType
+ GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBBreakpoint
+ GetBreakpointFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBBreakpointLocation
+ GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
+};
+
+} // namespace lldb
diff --git a/lldb/scripts/Python/interface/SBBreakpointLocation.i b/lldb/scripts/Python/interface/SBBreakpointLocation.i
new file mode 100644
index 00000000000..51e9389bf87
--- /dev/null
+++ b/lldb/scripts/Python/interface/SBBreakpointLocation.i
@@ -0,0 +1,90 @@
+//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents one unique instance (by address) of a logical breakpoint.
+
+A breakpoint location is defined by the breakpoint that produces it,
+and the address that resulted in this particular instantiation.
+Each breakpoint location has its settable options.
+
+SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint
+for retrieval of an SBBreakpointLocation from an SBBreakpoint."
+) SBBreakpointLocation;
+class SBBreakpointLocation
+{
+public:
+
+ SBBreakpointLocation ();
+
+ SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs);
+
+ ~SBBreakpointLocation ();
+
+ bool
+ IsValid() const;
+
+ lldb::addr_t
+ GetLoadAddress ();
+
+ void
+ SetEnabled(bool enabled);
+
+ bool
+ IsEnabled ();
+
+ uint32_t
+ GetIgnoreCount ();
+
+ void
+ SetIgnoreCount (uint32_t n);
+
+ void
+ SetCondition (const char *condition);
+
+ const char *
+ GetCondition ();
+
+ void
+ SetThreadID (lldb::tid_t sb_thread_id);
+
+ lldb::tid_t
+ GetThreadID ();
+
+ void
+ SetThreadIndex (uint32_t index);
+
+ uint32_t
+ GetThreadIndex() const;
+
+ void
+ SetThreadName (const char *thread_name);
+
+ const char *
+ GetThreadName () const;
+
+ void
+ SetQueueName (const char *queue_name);
+
+ const char *
+ GetQueueName () const;
+
+ bool
+ IsResolved ();
+
+ bool
+ GetDescription (lldb::SBStream &description, DescriptionLevel level);
+
+ SBBreakpoint
+ GetBreakpoint ();
+};
+
+} // namespace lldb
diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig
index 103ee020605..b5823c6738e 100644
--- a/lldb/scripts/lldb.swig
+++ b/lldb/scripts/lldb.swig
@@ -196,10 +196,10 @@ o SBLineEntry: Specifies an association with a contiguous range of instructions
%include "lldb/lldb-forward.h"
%include "lldb/lldb-forward-rtti.h"
%include "lldb/lldb-types.h"
-%include "lldb/API/SBAddress.h"
-%include "lldb/API/SBBlock.h"
-%include "lldb/API/SBBreakpoint.h"
-%include "lldb/API/SBBreakpointLocation.h"
+%include "./Python/interface/SBAddress.i"
+%include "./Python/interface/SBBlock.i"
+%include "./Python/interface/SBBreakpoint.i"
+%include "./Python/interface/SBBreakpointLocation.i"
%include "lldb/API/SBBroadcaster.h"
%include "lldb/API/SBCommandInterpreter.h"
%include "lldb/API/SBCommandReturnObject.h"
OpenPOWER on IntegriCloud