]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / macosx / debug-info / apple_types / TestAppleTypesIsProduced.py
1 """
2 Test that clang produces the __apple accelerator tables, for example, __apple_types, correctly.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
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
15
16 class AppleTypesTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     #rdar://problem/11166975
21     @skipUnlessDarwin
22     def test_debug_info_for_apple_types(self):
23         """Test that __apple_types section does get produced by clang."""
24
25         if not self.getCompiler().endswith('clang'):
26             self.skipTest("clang compiler only test")
27
28         self.build()
29         if self.debug_info == "dsym":
30             exe = os.path.join(os.getcwd(), "a.out.dSYM/Contents/Resources/DWARF/a.out")
31         else:
32             exe = os.path.join(os.getcwd(), "main.o")
33
34         target = self.dbg.CreateTarget(exe)
35         self.assertTrue(target, VALID_TARGET)
36         self.assertTrue(target.GetNumModules() > 0)
37
38         # Hide stdout if not running with '-t' option.
39         if not self.TraceOn():
40             self.HideStdout()
41
42         print("Number of modules for the target: %d" % target.GetNumModules())
43         for module in target.module_iter():
44             print(module)
45
46         # Get the executable module at index 0.
47         exe_module = target.GetModuleAtIndex(0)
48
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())
53         INDENT = ' ' * 4
54         for subsec in dwarf_section:
55             print(INDENT + str(subsec))
56
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)
60
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)
65
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"))