From da0c081f7e363497a150f3bb14b9460bfc495a6d Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Tue, 3 Jul 2018 14:22:44 +0000 Subject: 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 --- .../test/python_api/target/TestTargetAPI.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lldb/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py') 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 @@ -45,6 +45,14 @@ class TargetAPITestCase(TestBase): self.setTearDownCleanup(dictionary=d) 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): @@ -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) -- cgit v1.2.3