brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · b2e1db0 Raw
63 lines · python
1"""2Test symbol table access for main.m.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class FoundationSymtabTestCase(TestBase):12    symbols_list = [13        "-[MyString initWithNSString:]",14        "-[MyString dealloc]",15        "-[MyString description]",16        "-[MyString descriptionPauses]",  # synthesized property17        "-[MyString setDescriptionPauses:]",  # synthesized property18        "Test_Selector",19        "Test_NSString",20        "Test_MyString",21        "Test_NSArray",22        "main",23    ]24 25    @add_test_categories(["pyapi"])26    def test_with_python_api(self):27        """Test symbol table access with Python APIs."""28        self.build()29        exe = self.getBuildArtifact("a.out")30        target = self.dbg.CreateTarget(exe)31        self.assertTrue(target, VALID_TARGET)32 33        # Launch the process, and do not stop at the entry point.34        process = target.LaunchSimple(None, None, self.get_process_working_directory())35        self.assertTrue(process, PROCESS_IS_VALID)36 37        # Create the filespec by which to locate our a.out module. Use the38        # absolute path to get the module for the current variant.39        filespec = lldb.SBFileSpec(exe, False)40 41        module = target.FindModule(filespec)42        self.assertTrue(module, VALID_MODULE)43 44        # Create the set of known symbols.  As we iterate through the symbol45        # table, remove the symbol from the set if it is a known symbol.46        expected_symbols = set(self.symbols_list)47        for symbol in module:48            self.assertTrue(symbol, VALID_SYMBOL)49            self.trace("symbol:", symbol)50            name = symbol.GetName()51            if name in expected_symbols:52                self.trace(53                    "Removing %s from known_symbols %s" % (name, expected_symbols)54                )55                expected_symbols.remove(name)56 57        # At this point, the known_symbols set should have become an empty set.58        # If not, raise an error.59        self.trace("symbols unaccounted for:", expected_symbols)60        self.assertEqual(61            len(expected_symbols), 0, "All the known symbols are accounted for"62        )63