Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / objc / foundation / TestSymbolTable.py
blobb2e1db0fe82244d5bd60c6cf1391a4ced7b6394a
1 """
2 Test symbol table access for main.m.
3 """
5 import lldb
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test import lldbutil
11 class FoundationSymtabTestCase(TestBase):
12 symbols_list = [
13 "-[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",
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)
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)
37 # Create the filespec by which to locate our a.out module. Use the
38 # absolute path to get the module for the current variant.
39 filespec = lldb.SBFileSpec(exe, False)
41 module = target.FindModule(filespec)
42 self.assertTrue(module, VALID_MODULE)
44 # Create the set of known symbols. As we iterate through the symbol
45 # 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)
55 expected_symbols.remove(name)
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"