summaryrefslogtreecommitdiff
path: root/libbacktrace/Makefile.am
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2019-01-29 16:25:46 +0000
committerTom de Vries <vries@gcc.gnu.org>2019-01-29 16:25:46 +0000
commitfddbc19325a3e93a5f72668baa4e4bdeea9ebc7f (patch)
tree080a4c5201ecf818750ce6e5e53ed87a00a4bc75 /libbacktrace/Makefile.am
parent7e574f68fa82e7c5f879fd468291ec8b5ebecc83 (diff)
[libbacktrace] Add test-cases exercising build-id and dwz
Add test-cases b2test_buildid and b3test_dwz_buildid. The last one triggers the segfault fixed by "[backtrace] Avoid segfault" ( r268275 ). 2019-01-29 Tom de Vries <tdevries@suse.de> * install-debuginfo-for-buildid.sh.in: New script. * Makefile.am (check_PROGRAMS): Add b2test and b3test. (TESTS): Add b2test_buildid and b3test_dwz_buildid. * Makefile.in: Regenerate. * configure.ac (HAVE_ELF): Set with AM_CONDITIONAL. (READELF): Set with AC_CHECK_PROG. (install-debuginfo-for-buildid.sh): Generate with AC_CONFIG_FILES. * configure: Regenerate. * elf.c (SYSTEM_BUILD_ID_DIR): Factor out of ... (elf_open_debugfile_by_buildid): ... here. From-SVN: r268369
Diffstat (limited to 'libbacktrace/Makefile.am')
-rw-r--r--libbacktrace/Makefile.am50
1 files changed, 50 insertions, 0 deletions
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 1c4ab07aa19..71a2ed478cc 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -108,6 +108,28 @@ libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
+if HAVE_ELF
+if HAVE_OBJCOPY_DEBUGLINK
+
+TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/
+
+check_LTLIBRARIES += libbacktrace_elf_for_test.la
+
+libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES)
+libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
+ $(VIEW_FILE) $(ALLOC_FILE)
+
+elf_for_test.c: elf.c
+ SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
+ REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
+ $(SED) "s%$$SEARCH%$$REPLACE%" \
+ $< \
+ > $@.tmp
+ mv $@.tmp $@
+
+endif HAVE_OBJCOPY_DEBUGLINK
+endif HAVE_ELF
+
xcoff_%.c: xcoff.c
SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
REPLACE='#undef BACKTRACE_XCOFF_SIZE\
@@ -172,6 +194,28 @@ allocfail.sh: allocfail
TESTS += allocfail.sh
+if HAVE_ELF
+if HAVE_OBJCOPY_DEBUGLINK
+
+b2test_SOURCES = $(btest_SOURCES)
+b2test_CFLAGS = $(btest_CFLAGS)
+b2test_LDFLAGS = -Wl,--build-id
+b2test_LDADD = libbacktrace_elf_for_test.la
+
+check_PROGRAMS += b2test
+TESTS += b2test_buildid
+
+b3test_SOURCES = $(btest_SOURCES)
+b3test_CFLAGS = $(btest_CFLAGS)
+b3test_LDFLAGS = -Wl,--build-id
+b3test_LDADD = libbacktrace_elf_for_test.la
+
+check_PROGRAMS += b3test
+TESTS += b3test_dwz_buildid
+
+endif HAVE_OBJCOPY_DEBUGLINK
+endif HAVE_ELF
+
btest_SOURCES = btest.c testlib.c
btest_CFLAGS = $(AM_CFLAGS) -g -O
btest_LDADD = libbacktrace.la
@@ -275,6 +319,12 @@ TESTS += btest_gnudebuglink
endif HAVE_OBJCOPY_DEBUGLINK
+%_buildid: %
+ ./install-debuginfo-for-buildid.sh \
+ "$(TEST_BUILD_ID_DIR)" \
+ $<
+ $(OBJCOPY) --strip-debug $< $@
+
if HAVE_COMPRESSED_DEBUG
ctestg_SOURCES = btest.c testlib.c