1""" 2Test symbol table access for main.m. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class FoundationSymtabTestCase(TestBase): 12 13 symbols_list = ['-[MyString initWithNSString:]', 14 '-[MyString dealloc]', 15 '-[MyString description]', 16 '-[MyString descriptionPauses]', # synthesized property 17 '-[MyString setDescriptionPauses:]', # synthesized property 18 '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( 35 None, None, self.get_process_working_directory()) 36 self.assertTrue(process, PROCESS_IS_VALID) 37 38 # Create the filespec by which to locate our a.out module. Use the 39 # absolute path to get the module for the current variant. 40 filespec = lldb.SBFileSpec(exe, False) 41 42 module = target.FindModule(filespec) 43 self.assertTrue(module, VALID_MODULE) 44 45 # Create the set of known symbols. As we iterate through the symbol 46 # table, remove the symbol from the set if it is a known symbol. 47 expected_symbols = set(self.symbols_list) 48 for symbol in module: 49 self.assertTrue(symbol, VALID_SYMBOL) 50 self.trace("symbol:", symbol) 51 name = symbol.GetName() 52 if name in expected_symbols: 53 self.trace("Removing %s from known_symbols %s" % (name, expected_symbols)) 54 expected_symbols.remove(name) 55 56 # At this point, the known_symbols set should have become an empty set. 57 # If not, raise an error. 58 self.trace("symbols unaccounted for:", expected_symbols) 59 self.assertEqual(len(expected_symbols), 0, 60 "All the known symbols are accounted for") 61