2 Test that clang produces the __apple accelerator tables, for example, __apple_types, correctly.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14 from lldbsuite.test.lldbutil import symbol_type_to_str
16 class AppleTypesTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
20 #rdar://problem/11166975
22 def test_debug_info_for_apple_types(self):
23 """Test that __apple_types section does get produced by clang."""
25 if not self.getCompiler().endswith('clang'):
26 self.skipTest("clang compiler only test")
29 if self.debug_info == "dsym":
30 exe = os.path.join(os.getcwd(), "a.out.dSYM/Contents/Resources/DWARF/a.out")
32 exe = os.path.join(os.getcwd(), "main.o")
34 target = self.dbg.CreateTarget(exe)
35 self.assertTrue(target, VALID_TARGET)
36 self.assertTrue(target.GetNumModules() > 0)
38 # Hide stdout if not running with '-t' option.
39 if not self.TraceOn():
42 print("Number of modules for the target: %d" % target.GetNumModules())
43 for module in target.module_iter():
46 # Get the executable module at index 0.
47 exe_module = target.GetModuleAtIndex(0)
49 dwarf_section = exe_module.FindSection("__DWARF")
50 self.assertTrue(dwarf_section)
51 print("__DWARF section:", dwarf_section)
52 print("Number of sub-sections: %d" % dwarf_section.GetNumSubSections())
54 for subsec in dwarf_section:
55 print(INDENT + str(subsec))
57 debug_str_sub_section = dwarf_section.FindSubSection("__debug_str")
58 self.assertTrue(debug_str_sub_section)
59 print("__debug_str sub-section:", debug_str_sub_section)
61 # Find our __apple_types section by name.
62 apple_types_sub_section = dwarf_section.FindSubSection("__apple_types")
63 self.assertTrue(apple_types_sub_section)
64 print("__apple_types sub-section:", apple_types_sub_section)
66 # These other three all important subsections should also be present.
67 self.assertTrue(dwarf_section.FindSubSection("__apple_names") and
68 dwarf_section.FindSubSection("__apple_namespac") and
69 dwarf_section.FindSubSection("__apple_objc"))