diff options
author | Johnny Chen <johnny.chen@apple.com> | 2012-03-16 21:55:42 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2012-03-16 21:55:42 +0000 |
commit | 1b72f09150b1333e33773882e9c035ac896acc5e (patch) | |
tree | 2d03ba33e15db13fdbd92fb68812690f937f9ed6 /lldb/test/python_api/module_section/TestModuleAndSection.py | |
parent | f6af30f4c7d91d61d2ccb7cdb450872c11eef214 (diff) | |
download | bcm5719-llvm-1b72f09150b1333e33773882e9c035ac896acc5e.tar.gz bcm5719-llvm-1b72f09150b1333e33773882e9c035ac896acc5e.zip |
Export the APIs submitted by Dawn to the Python bindings. Add a simple test case for the SBModule.compile_unit_iter() API.
llvm-svn: 152952
Diffstat (limited to 'lldb/test/python_api/module_section/TestModuleAndSection.py')
-rw-r--r-- | lldb/test/python_api/module_section/TestModuleAndSection.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lldb/test/python_api/module_section/TestModuleAndSection.py b/lldb/test/python_api/module_section/TestModuleAndSection.py index ebd0ea04909..7038d6e7109 100644 --- a/lldb/test/python_api/module_section/TestModuleAndSection.py +++ b/lldb/test/python_api/module_section/TestModuleAndSection.py @@ -25,6 +25,12 @@ class ModuleAndSectionAPIsTestCase(TestBase): 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 @@ class ModuleAndSectionAPIsTestCase(TestBase): 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() |