diff options
author | Alexander Polyakov <polyakov.alx@gmail.com> | 2018-07-03 14:22:44 +0000 |
---|---|---|
committer | Alexander Polyakov <polyakov.alx@gmail.com> | 2018-07-03 14:22:44 +0000 |
commit | da0c081f7e363497a150f3bb14b9460bfc495a6d (patch) | |
tree | 0cb7bc7a67f0979577219aefe84b8abaf1a0f84b /lldb/packages/Python/lldbsuite/test/python_api | |
parent | b5d6e76bb7baba6885e92d0f8d639bf2b1da379d (diff) | |
download | bcm5719-llvm-da0c081f7e363497a150f3bb14b9460bfc495a6d.tar.gz bcm5719-llvm-da0c081f7e363497a150f3bb14b9460bfc495a6d.zip |
Add new API to SBTarget and SBModule classes.
Summary: The new API allows to find a list of compile units related to target/module.
Reviewers: aprantl, clayborg
Reviewed By: aprantl
Subscribers: jingham, lldb-commits
Differential Revision: https://reviews.llvm.org/D48801
llvm-svn: 336200
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py | 26 | ||||
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py | 22 |
2 files changed, 48 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py b/lldb/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py index 654387fdf87..65b159974c0 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py @@ -141,3 +141,29 @@ class ModuleAndSectionAPIsTestCase(TestBase): INDENT2 = INDENT * 2 for cu in exe_module.compile_unit_iter(): print(cu) + + @add_test_categories(['pyapi']) + def test_find_compile_units(self): + """Exercise SBModule.FindCompileUnits() API.""" + d = {'EXE': 'b.out'} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.find_compile_units(self.getBuildArtifact('b.out')) + + def find_compile_units(self, exe): + """Exercise SBModule.FindCompileUnits() API.""" + source_name_list = ["main.cpp", "b.cpp", "c.cpp"] + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + num_modules = target.GetNumModules() + for i in range(num_modules): + module = target.GetModuleAtIndex(i) + for source_name in source_name_list: + list = module.FindCompileUnits(lldb.SBFileSpec(source_name, False)) + for sc in list: + self.assertTrue( + sc.GetCompileUnit().GetFileSpec().GetFilename() == + source_name) diff --git a/lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py index 3787f55f233..224dca77daa 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py @@ -46,6 +46,14 @@ class TargetAPITestCase(TestBase): self.find_global_variables('b.out') @add_test_categories(['pyapi']) + def test_find_compile_units(self): + """Exercise SBTarget.FindCompileUnits() API.""" + d = {'EXE': 'b.out'} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.find_compile_units(self.getBuildArtifact('b.out')) + + @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_find_functions(self): """Exercise SBTarget.FindFunctions() API.""" @@ -219,6 +227,20 @@ class TargetAPITestCase(TestBase): value_list.GetValueAtIndex(0).GetValue() == "'X'") break + def find_compile_units(self, exe): + """Exercise SBTarget.FindCompileUnits() API.""" + source_name = "main.c" + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + list = target.FindCompileUnits(lldb.SBFileSpec(source_name, False)) + # Executable has been built just from one source file 'main.c', + # so we may check only the first element of list. + self.assertTrue( + list[0].GetCompileUnit().GetFileSpec().GetFilename() == source_name) + def find_functions(self, exe_name): """Exercise SBTaget.FindFunctions() API.""" exe = self.getBuildArtifact(exe_name) |