[Lldb-commits] [lldb] r185455 - Add split symbol support to test makefile & add linux split symbol test case.
Michael Sartain
mikesart at valvesoftware.com
Tue Jul 2 11:13:13 PDT 2013
Author: mikesart
Date: Tue Jul 2 13:13:13 2013
New Revision: 185455
URL: http://llvm.org/viewvc/llvm-project?rev=185455&view=rev
Log:
Add split symbol support to test makefile & add linux split symbol test case.
Added:
lldb/trunk/test/lang/c/shared_lib_stripped_symbols/
lldb/trunk/test/lang/c/shared_lib_stripped_symbols/Makefile
lldb/trunk/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.c
lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.h
lldb/trunk/test/lang/c/shared_lib_stripped_symbols/main.c
Modified:
lldb/trunk/test/make/Makefile.rules
Added: lldb/trunk/test/lang/c/shared_lib_stripped_symbols/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib_stripped_symbols/Makefile?rev=185455&view=auto
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib_stripped_symbols/Makefile (added)
+++ lldb/trunk/test/lang/c/shared_lib_stripped_symbols/Makefile Tue Jul 2 13:13:13 2013
@@ -0,0 +1,10 @@
+LEVEL = ../../../make
+
+DYLIB_NAME := libfoo
+DYLIB_C_SOURCES := foo.c
+C_SOURCES := main.c
+CFLAGS_EXTRAS += -fPIC
+
+SPLIT_DEBUG_SYMBOLS = YES
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py?rev=185455&view=auto
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py (added)
+++ lldb/trunk/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py Tue Jul 2 13:13:13 2013
@@ -0,0 +1,90 @@
+"""Test that types defined in shared libraries with stripped symbols work correctly."""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+import lldbutil
+
+class SharedLibTestCase(TestBase):
+
+ mydir = os.path.join("lang", "c", "shared_lib")
+
+ @dsym_test
+ def test_expr_with_dsym(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.buildDsym()
+ self.expr()
+
+ @dwarf_test
+ def test_expr_with_dwarf(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.buildDwarf()
+ self.expr()
+
+ @dsym_test
+ def test_frame_variable_with_dsym(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.buildDsym()
+ self.frame_var()
+
+ @dwarf_test
+ def test_frame_variable_with_dwarf(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.buildDwarf()
+ self.frame_var()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', '// Set breakpoint 0 here.')
+ if sys.platform.startswith("linux"):
+ self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.getcwd())
+ self.addTearDownHook(lambda: self.runCmd("settings remove target.env-vars " + self.dylibPath))
+
+ def common_setup(self):
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the foo function which takes a bar_ptr argument.
+ lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
+
+ def expr(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+
+ if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
+ self.skipTest("llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
+
+ self.common_setup()
+
+ # This should display correctly.
+ self.expect("expression --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ["(foo)", "(sub_foo)", "other_element = 3"])
+
+ @unittest2.expectedFailure
+ # rdar://problem/10381325
+ def frame_var(self):
+ """Test that types work when defined in a shared library and forward-declared in the main executable"""
+ self.common_setup()
+
+ # This should display correctly.
+ self.expect("frame variable --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+ substrs = ["(foo)", "(sub_foo)", "other_element = 3"])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.c?rev=185455&view=auto
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.c (added)
+++ lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.c Tue Jul 2 13:13:13 2013
@@ -0,0 +1,22 @@
+#include "foo.h"
+#include <stdlib.h>
+
+struct foo
+{
+ struct sub_foo sub_element;
+ int other_element;
+};
+
+struct foo *
+GetMeAFoo()
+{
+ struct foo *ret_val = (struct foo *) malloc (sizeof (struct foo));
+ ret_val->other_element = 3;
+ return ret_val;
+}
+
+struct sub_foo *
+GetMeASubFoo (struct foo *in_foo)
+{
+ return &(in_foo->sub_element);
+}
Added: lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.h?rev=185455&view=auto
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.h (added)
+++ lldb/trunk/test/lang/c/shared_lib_stripped_symbols/foo.h Tue Jul 2 13:13:13 2013
@@ -0,0 +1,12 @@
+struct foo;
+
+struct sub_foo
+{
+ int sub_1;
+ char *sub_2;
+};
+
+struct foo *GetMeAFoo();
+struct sub_foo *GetMeASubFoo (struct foo *in_foo);
+
+
Added: lldb/trunk/test/lang/c/shared_lib_stripped_symbols/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib_stripped_symbols/main.c?rev=185455&view=auto
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib_stripped_symbols/main.c (added)
+++ lldb/trunk/test/lang/c/shared_lib_stripped_symbols/main.c Tue Jul 2 13:13:13 2013
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "foo.h"
+
+int
+main ()
+{
+ struct foo *my_foo_ptr;
+ my_foo_ptr = GetMeAFoo();
+
+ printf ("My sub foo has: %d.\n", GetMeASubFoo(my_foo_ptr)->sub_1); // Set breakpoint 0 here.
+
+ return 0;
+}
Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=185455&r1=185454&r2=185455&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Tue Jul 2 13:13:13 2013
@@ -16,6 +16,7 @@
# FRAMEWORK_INCLUDES (Darwin only) :=
# CFLAGS_EXTRAS :=
# LD_EXTRAS :=
+# SPLIT_DEBUG_SYMBOLS := YES
#
# And test/functionalities/archives/Makefile:
# MAKE_DSYM := NO
@@ -79,6 +80,10 @@ else
ifeq "$(ARCH)" "i386"
override ARCH := $(subst i386,32,$(ARCH))
endif
+
+ ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+ DSYM = $(EXE).debug
+ endif
endif
CFLAGS ?= -g -O0
@@ -229,13 +234,20 @@ endif
#----------------------------------------------------------------------
# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO"
#----------------------------------------------------------------------
+$(DSYM) : $(EXE)
ifeq "$(OS)" "Darwin"
ifneq "$(MAKE_DSYM)" "NO"
ifeq "$(DYLIB_ONLY)" ""
-$(DSYM) : $(EXE)
$(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
endif
endif
+else
+ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+ifeq "$(DYLIB_ONLY)" ""
+ objcopy --only-keep-debug "$(EXE)" "$(DSYM)"
+ objcopy --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
+endif
+endif
endif
#----------------------------------------------------------------------
@@ -279,6 +291,10 @@ endif
endif
else
$(LD) $(LDFLAGS) $(DYLIB_OBJECTS) -shared -o "$(DYLIB_FILENAME)"
+ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+ objcopy --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
+ objcopy --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
+endif
endif
#----------------------------------------------------------------------
@@ -342,7 +358,7 @@ clean::
ifeq "$(DYLIB_NAME)" ""
rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) *.d.[0-9] *.d.[0-9][0-9] *.d.[0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9][0-9]
else
- rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).dSYM *.d.[0-9] *.d.[0-9][0-9] *.d.[0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9][0-9]
+ rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).dSYM $(DYLIB_FILENAME).debug *.d.[0-9] *.d.[0-9][0-9] *.d.[0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9] *.d.[0-9][0-9][0-9][0-9][0-9]
endif
#----------------------------------------------------------------------
More information about the lldb-commits
mailing list