diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-12-19 20:16:22 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-12-19 20:16:22 +0000 |
commit | 4efffd9ae5aa7bd00edb8f19f4cc895bd5213f5b (patch) | |
tree | 3f84bb3bd42aad6b6b665ddaceed185496386895 /lldb/test/python_api/module_section/TestModuleAndSection.py | |
parent | 61221b72ee9ef0af516ec6387e0d1d21b3530734 (diff) | |
download | bcm5719-llvm-4efffd9ae5aa7bd00edb8f19f4cc895bd5213f5b.tar.gz bcm5719-llvm-4efffd9ae5aa7bd00edb8f19f4cc895bd5213f5b.zip |
Work in progress for:
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check
Add NULL checks for SBModule and SBSection APIs.
llvm-svn: 146899
Diffstat (limited to 'lldb/test/python_api/module_section/TestModuleAndSection.py')
-rw-r--r-- | lldb/test/python_api/module_section/TestModuleAndSection.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lldb/test/python_api/module_section/TestModuleAndSection.py b/lldb/test/python_api/module_section/TestModuleAndSection.py index efd5f0c5686..1ebe9d33433 100644 --- a/lldb/test/python_api/module_section/TestModuleAndSection.py +++ b/lldb/test/python_api/module_section/TestModuleAndSection.py @@ -19,6 +19,12 @@ class ModuleAndSectionAPIsTestCase(TestBase): self.buildDefault() self.module_and_section() + @python_api_test + def test_module_and_section_boundary_condition(self): + """Test module and section APIs by passing None when it expects a Python string.""" + self.buildDefault() + self.module_and_section_boundary_condition() + def module_and_section(self): exe = os.path.join(os.getcwd(), "a.out") @@ -56,6 +62,43 @@ class ModuleAndSectionAPIsTestCase(TestBase): print INDENT2 + repr(sym) print INDENT2 + "symbol type: %s" % symbol_type_to_str(sym.GetType()) + def module_and_section_boundary_condition(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" % repr(exe_module) + print "Number of sections: %d" % exe_module.GetNumSections() + + # Boundary condition testings. Should not crash lldb! + exe_module.FindFirstType(None) + exe_module.FindTypes(None) + exe_module.FindGlobalVariables(target, None, 1) + exe_module.FindFunctions(None, 0, True, lldb.SBSymbolContextList()) + exe_module.FindSection(None) + + # Get the section at index 1. + if exe_module.GetNumSections() > 1: + sec1 = exe_module.GetSectionAtIndex(1) + print sec1 + else: + sec1 = None + + if sec1: + sec1.FindSubSection(None) if __name__ == '__main__': import atexit |