[Lldb-commits] [lldb] r152952 - in /lldb/trunk: scripts/Python/interface/SBCompileUnit.i scripts/Python/interface/SBModule.i scripts/Python/modify-python-lldb.py test/python_api/module_section/Makefile test/python_api/module_section/TestModuleAndSection.py test/python_api/module_section/b.cpp test/python_api/module_section/c.cpp
Johnny Chen
johnny.chen at apple.com
Fri Mar 16 14:55:43 PDT 2012
Author: johnny
Date: Fri Mar 16 16:55:42 2012
New Revision: 152952
URL: http://llvm.org/viewvc/llvm-project?rev=152952&view=rev
Log:
Export the APIs submitted by Dawn to the Python bindings. Add a simple test case for the SBModule.compile_unit_iter() API.
Added:
lldb/trunk/test/python_api/module_section/b.cpp
lldb/trunk/test/python_api/module_section/c.cpp
Modified:
lldb/trunk/scripts/Python/interface/SBCompileUnit.i
lldb/trunk/scripts/Python/interface/SBModule.i
lldb/trunk/scripts/Python/modify-python-lldb.py
lldb/trunk/test/python_api/module_section/Makefile
lldb/trunk/test/python_api/module_section/TestModuleAndSection.py
Modified: lldb/trunk/scripts/Python/interface/SBCompileUnit.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCompileUnit.i?rev=152952&r1=152951&r2=152952&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBCompileUnit.i (original)
+++ lldb/trunk/scripts/Python/interface/SBCompileUnit.i Fri Mar 16 16:55:42 2012
@@ -77,6 +77,15 @@
lldb::SBFileSpec *inline_file_spec,
bool exact) const;
+ SBFileSpec
+ GetSupportFileAtIndex (uint32_t idx) const;
+
+ uint32_t
+ GetNumSupportFiles () const;
+
+ uint32_t
+ FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
+
bool
GetDescription (lldb::SBStream &description);
Modified: lldb/trunk/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=152952&r1=152951&r2=152952&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModule.i (original)
+++ lldb/trunk/scripts/Python/interface/SBModule.i Fri Mar 16 16:55:42 2012
@@ -165,6 +165,12 @@
bool
GetDescription (lldb::SBStream &description);
+ uint32_t
+ GetNumCompileUnits();
+
+ lldb::SBCompileUnit
+ GetCompileUnitAtIndex (uint32_t);
+
size_t
GetNumSymbols ();
Modified: lldb/trunk/scripts/Python/modify-python-lldb.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=152952&r1=152951&r2=152952&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/modify-python-lldb.py (original)
+++ lldb/trunk/scripts/Python/modify-python-lldb.py Fri Mar 16 16:55:42 2012
@@ -175,6 +175,7 @@
breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')"
watchpoint_iter = " def watchpoint_iter(self): return lldb_iter(self, '%s', '%s')"
section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')"
+compile_unit_iter = " def compile_unit_iter(self): return lldb_iter(self, '%s', '%s')"
# Called to implement the built-in function len().
# Eligible objects are those containers with unambiguous iteration support.
@@ -227,6 +228,8 @@
# SBModule has an additional section_iter(), see below.
'SBModule-section': ('GetNumSections', 'GetSectionAtIndex'),
+ # And compile_unit_iter().
+ 'SBModule-compile-unit': ('GetNumCompileUnits', 'GetCompileUnitAtIndex'),
# As well as symbol_in_section_iter().
'SBModule-symbol-in-section': symbol_in_section_iter_def
}
@@ -378,9 +381,10 @@
new_content.add_line(eq_def % (cls, list_to_frag(e[cls])))
new_content.add_line(ne_def)
- # SBModule has an extra SBSection iterator and symbol_in_section_iter()!
+ # SBModule has extra SBSection, SBCompileUnit iterators and symbol_in_section_iter()!
if cls == "SBModule":
new_content.add_line(section_iter % d[cls+'-section'])
+ new_content.add_line(compile_unit_iter % d[cls+'-compile-unit'])
new_content.add_line(d[cls+'-symbol-in-section'])
# This special purpose iterator is for SBValue only!!!
Modified: lldb/trunk/test/python_api/module_section/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/Makefile?rev=152952&r1=152951&r2=152952&view=diff
==============================================================================
--- lldb/trunk/test/python_api/module_section/Makefile (original)
+++ lldb/trunk/test/python_api/module_section/Makefile Fri Mar 16 16:55:42 2012
@@ -1,6 +1,6 @@
LEVEL = ../../make
-CXX_SOURCES := main.cpp
+CXX_SOURCES := main.cpp b.cpp c.cpp
MAKE_DSYM :=NO
include $(LEVEL)/Makefile.rules
Modified: lldb/trunk/test/python_api/module_section/TestModuleAndSection.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/TestModuleAndSection.py?rev=152952&r1=152951&r2=152952&view=diff
==============================================================================
--- lldb/trunk/test/python_api/module_section/TestModuleAndSection.py (original)
+++ lldb/trunk/test/python_api/module_section/TestModuleAndSection.py Fri Mar 16 16:55:42 2012
@@ -25,6 +25,12 @@
self.buildDefault()
self.module_and_section_boundary_condition()
+ @python_api_test
+ def test_module_compile_unit_iter(self):
+ """Test module's compile unit iterator APIs."""
+ self.buildDefault()
+ self.module_compile_unit_iter()
+
def module_and_section(self):
exe = os.path.join(os.getcwd(), "a.out")
@@ -100,6 +106,32 @@
if sec1:
sec1.FindSubSection(None)
+ def module_compile_unit_iter(self):
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+ self.assertTrue(target.GetNumModules() > 0)
+
+ # Hide stdout if not running with '-t' option.
+ if not self.TraceOn():
+ self.HideStdout()
+
+ print "Number of modules for the target: %d" % target.GetNumModules()
+ for module in target.module_iter():
+ print module
+
+ # Get the executable module at index 0.
+ exe_module = target.GetModuleAtIndex(0)
+
+ print "Exe module: %s" % str(exe_module)
+ print "Number of compile units: %d" % exe_module.GetNumCompileUnits()
+ INDENT = ' ' * 4
+ INDENT2 = INDENT * 2
+ for cu in exe_module.compile_unit_iter():
+ print cu
+
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
Added: lldb/trunk/test/python_api/module_section/b.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/b.cpp?rev=152952&view=auto
==============================================================================
--- lldb/trunk/test/python_api/module_section/b.cpp (added)
+++ lldb/trunk/test/python_api/module_section/b.cpp Fri Mar 16 16:55:42 2012
@@ -0,0 +1,3 @@
+int b_function(int input) {
+ return input * 2;
+}
Added: lldb/trunk/test/python_api/module_section/c.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/module_section/c.cpp?rev=152952&view=auto
==============================================================================
--- lldb/trunk/test/python_api/module_section/c.cpp (added)
+++ lldb/trunk/test/python_api/module_section/c.cpp Fri Mar 16 16:55:42 2012
@@ -0,0 +1,3 @@
+int c_function(int input) {
+ return input * 3;
+}
More information about the lldb-commits
mailing list