summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/macosx/debug-info
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-01-06 20:12:03 +0000
commit9e6d35490a6542f9c97607f93c2ef8ca8e03cbcc (patch)
treedd2a1ddf0476664c2b823409c36cbccd52662ca7 /packages/Python/lldbsuite/test/macosx/debug-info
parent3bd2e91faeb9eeec1aae82c64a3253afff551cfd (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/macosx/debug-info')
-rw-r--r--packages/Python/lldbsuite/test/macosx/debug-info/apple_types/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py67
-rw-r--r--packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c27
3 files changed, 100 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/Makefile b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/Makefile
new file mode 100644
index 000000000000..aa3a0fcdcea4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+MAKE_DSYM := NO
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py
new file mode 100644
index 000000000000..fad14db41003
--- /dev/null
+++ b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py
@@ -0,0 +1,67 @@
+"""
+Test that clang produces the __apple accelerator tables, for example, __apple_types, correctly.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbutil import symbol_type_to_str
+
+class AppleTypesTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ #rdar://problem/11166975
+ @skipUnlessDarwin
+ def test_debug_info_for_apple_types(self):
+ """Test that __apple_types section does get produced by clang."""
+
+ if not self.getCompiler().endswith('clang'):
+ self.skipTest("clang compiler only test")
+
+ self.build()
+ if self.debug_info == "dsym":
+ exe = os.path.join(os.getcwd(), "a.out.dSYM/Contents/Resources/DWARF/a.out")
+ else:
+ exe = os.path.join(os.getcwd(), "main.o")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+ self.assertTrue(target.GetNumModules() > 0)
+
+ # Hide stdout if not running with '-t' option.
+ if not self.TraceOn():
+ self.HideStdout()
+
+ print("Number of modules for the target: %d" % target.GetNumModules())
+ for module in target.module_iter():
+ print(module)
+
+ # Get the executable module at index 0.
+ exe_module = target.GetModuleAtIndex(0)
+
+ dwarf_section = exe_module.FindSection("__DWARF")
+ self.assertTrue(dwarf_section)
+ print("__DWARF section:", dwarf_section)
+ print("Number of sub-sections: %d" % dwarf_section.GetNumSubSections())
+ INDENT = ' ' * 4
+ for subsec in dwarf_section:
+ print(INDENT + str(subsec))
+
+ debug_str_sub_section = dwarf_section.FindSubSection("__debug_str")
+ self.assertTrue(debug_str_sub_section)
+ print("__debug_str sub-section:", debug_str_sub_section)
+
+ # Find our __apple_types section by name.
+ apple_types_sub_section = dwarf_section.FindSubSection("__apple_types")
+ self.assertTrue(apple_types_sub_section)
+ print("__apple_types sub-section:", apple_types_sub_section)
+
+ # These other three all important subsections should also be present.
+ self.assertTrue(dwarf_section.FindSubSection("__apple_names") and
+ dwarf_section.FindSubSection("__apple_namespac") and
+ dwarf_section.FindSubSection("__apple_objc"))
diff --git a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c
new file mode 100644
index 000000000000..cb4bdb9c16b4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c
@@ -0,0 +1,27 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+int main (int argc, char const *argv[])
+{
+ struct point_tag {
+ int x;
+ int y;
+ }; // Set break point at this line.
+
+ struct rect_tag {
+ struct point_tag bottom_left;
+ struct point_tag top_right;
+ };
+ struct point_tag pt = { 2, 3 }; // This is the first executable statement.
+ struct rect_tag rect = {{1,2}, {3,4}};
+ pt.x = argc;
+ pt.y = argc * argc;
+ rect.top_right.x = rect.top_right.x + argc;
+ rect.top_right.y = rect.top_right.y + argc;
+ return 0;
+}