TestSymbolTable.py [plain text]
"""
Test symbol table access for main.m.
"""
import os, time
import unittest2
import lldb
from lldbtest import *
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
class FoundationSymtabTestCase(TestBase):
mydir = os.path.join("lang", "objc", "foundation")
symbols_list = ['-[MyString initWithNSString:]',
'-[MyString dealloc]',
'-[MyString description]',
'-[MyString descriptionPauses]', '-[MyString setDescriptionPauses:]', 'Test_Selector',
'Test_NSString',
'Test_MyString',
'Test_NSArray',
'main'
]
@python_api_test
@dsym_test
def test_with_dsym_and_python_api(self):
"""Test symbol table access with Python APIs."""
self.buildDsym()
self.symtab_access_python()
@python_api_test
@dwarf_test
def test_with_dwarf_and_python_api(self):
"""Test symbol table access with Python APIs."""
self.buildDwarf()
self.symtab_access_python()
def symtab_access_python(self):
"""Test symbol table access with Python APIs."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
process = target.LaunchSimple(None, None, os.getcwd())
filespec = lldb.SBFileSpec(exe, False)
module = target.FindModule(filespec)
self.assertTrue(module, VALID_MODULE)
expected_symbols = set(self.symbols_list)
for symbol in module:
self.assertTrue(symbol, VALID_SYMBOL)
name = symbol.GetName()
if name in expected_symbols:
expected_symbols.remove(name)
self.assertTrue(len(expected_symbols) == 0,
"All the known symbols are accounted for")
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()