[libbacktrace] Add test-cases exercising build-id and dwz
authorTom de Vries <tdevries@suse.de>
Tue, 29 Jan 2019 16:25:46 +0000 (16:25 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Tue, 29 Jan 2019 16:25:46 +0000 (16:25 +0000)
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

libbacktrace/ChangeLog
libbacktrace/Makefile.am
libbacktrace/Makefile.in
libbacktrace/configure
libbacktrace/configure.ac
libbacktrace/elf.c
libbacktrace/install-debuginfo-for-buildid.sh.in [new file with mode: 0644]

index 3726c899c8ae6a39503330367ecf9aa6e7a701f9..811489e31b9908331dbc33622f18e234d05ce436 100644 (file)
@@ -1,3 +1,16 @@
+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.
+
 2019-01-29  Tom de Vries  <tdevries@suse.de>
 
        * Makefile.am: Replace check_PROGRAMS with BUILDTESTS, except for
index 1c4ab07aa1925a70d0758ab24532ac7de9cb145f..71a2ed478cca2d5e420bfe78b3a0f8bbbb37116c 100644 (file)
@@ -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
index 862fc8ca314f32fe9875b7e31a9acb327928029f..a2b595e9bb0550b1ca981291bb6a071c63ae086b 100644 (file)
@@ -120,22 +120,27 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_5)
-TESTS = $(am__append_3) $(am__append_4) $(am__append_5) \
-       $(am__append_9) $(am__EXEEXT_5)
-@NATIVE_TRUE@am__append_1 = test_elf test_xcoff_32 test_xcoff_64 \
+check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_6)
+TESTS = $(am__append_4) $(am__append_6) $(am__append_7) \
+       $(am__append_8) $(am__append_12) $(am__EXEEXT_6)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_1 = libbacktrace_elf_for_test.la
+@NATIVE_TRUE@am__append_2 = test_elf test_xcoff_32 test_xcoff_64 \
 @NATIVE_TRUE@  test_pecoff test_unknown unittest unittest_alloc \
 @NATIVE_TRUE@  btest btest_alloc stest stest_alloc ztest \
 @NATIVE_TRUE@  ztest_alloc edtest edtest_alloc
-@NATIVE_TRUE@am__append_2 = allocfail
-@NATIVE_TRUE@am__append_3 = allocfail.sh
-@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_4 = btest_dwz
-@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_5 = btest_dwz_gnudebuglink
-@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_6 = -lz
-@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_7 = -lz
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_8 = ttest ttest_alloc
-@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = btest_gnudebuglink
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_10 = ctestg ctesta \
+@NATIVE_TRUE@am__append_3 = allocfail
+@NATIVE_TRUE@am__append_4 = allocfail.sh
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_5 = b2test \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      b3test
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test_buildid \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      b3test_dwz_buildid
+@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_7 = btest_dwz
+@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = btest_dwz_gnudebuglink
+@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_9 = -lz
+@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_10 = -lz
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_11 = ttest ttest_alloc
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_12 = btest_gnudebuglink
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_13 = ctestg ctesta \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctestg_alloc \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctesta_alloc
 subdir = .
@@ -159,7 +164,8 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
 CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES = backtrace-supported.h
+CONFIG_CLEAN_FILES = backtrace-supported.h \
+       install-debuginfo-for-buildid.sh
 CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 am__DEPENDENCIES_1 =
@@ -175,6 +181,14 @@ am__objects_1 = atomic.lo dwarf.lo fileline.lo posix.lo print.lo \
 @NATIVE_TRUE@am_libbacktrace_alloc_la_OBJECTS = $(am__objects_1)
 libbacktrace_alloc_la_OBJECTS = $(am_libbacktrace_alloc_la_OBJECTS)
 @NATIVE_TRUE@am_libbacktrace_alloc_la_rpath =
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@libbacktrace_elf_for_test_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      elf_for_test.lo \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      $(am__DEPENDENCIES_1) \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      $(am__DEPENDENCIES_1)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_libbacktrace_elf_for_test_la_OBJECTS = $(am__objects_1)
+libbacktrace_elf_for_test_la_OBJECTS =  \
+       $(am_libbacktrace_elf_for_test_la_OBJECTS)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_libbacktrace_elf_for_test_la_rpath =
 @NATIVE_TRUE@am_libbacktrace_instrumented_alloc_la_OBJECTS =  \
 @NATIVE_TRUE@  $(am__objects_1)
 libbacktrace_instrumented_alloc_la_OBJECTS =  \
@@ -185,7 +199,9 @@ libbacktrace_noformat_la_OBJECTS =  \
        $(am_libbacktrace_noformat_la_OBJECTS)
 @NATIVE_TRUE@am_libbacktrace_noformat_la_rpath =
 @NATIVE_TRUE@am__EXEEXT_1 = allocfail$(EXEEXT)
-@NATIVE_TRUE@am__EXEEXT_2 = test_elf$(EXEEXT) test_xcoff_32$(EXEEXT) \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = b2test$(EXEEXT) \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      b3test$(EXEEXT)
+@NATIVE_TRUE@am__EXEEXT_3 = test_elf$(EXEEXT) test_xcoff_32$(EXEEXT) \
 @NATIVE_TRUE@  test_xcoff_64$(EXEEXT) test_pecoff$(EXEEXT) \
 @NATIVE_TRUE@  test_unknown$(EXEEXT) unittest$(EXEEXT) \
 @NATIVE_TRUE@  unittest_alloc$(EXEEXT) btest$(EXEEXT) \
@@ -193,19 +209,35 @@ libbacktrace_noformat_la_OBJECTS =  \
 @NATIVE_TRUE@  stest_alloc$(EXEEXT) ztest$(EXEEXT) \
 @NATIVE_TRUE@  ztest_alloc$(EXEEXT) edtest$(EXEEXT) \
 @NATIVE_TRUE@  edtest_alloc$(EXEEXT)
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = ttest$(EXEEXT) \
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_4 = ttest$(EXEEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@       ttest_alloc$(EXEEXT)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_4 =  \
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_5 =  \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctestg$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctesta$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctestg_alloc$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctesta_alloc$(EXEEXT)
-am__EXEEXT_5 = $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4)
+am__EXEEXT_6 = $(am__EXEEXT_3) $(am__EXEEXT_4) $(am__EXEEXT_5)
 @NATIVE_TRUE@am_allocfail_OBJECTS = allocfail.$(OBJEXT) \
 @NATIVE_TRUE@  testlib.$(OBJEXT)
 allocfail_OBJECTS = $(am_allocfail_OBJECTS)
 @NATIVE_TRUE@allocfail_DEPENDENCIES =  \
 @NATIVE_TRUE@  libbacktrace_instrumented_alloc.la
+@NATIVE_TRUE@am__objects_2 = b2test-btest.$(OBJEXT) \
+@NATIVE_TRUE@  b2test-testlib.$(OBJEXT)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b2test_OBJECTS = $(am__objects_2)
+b2test_OBJECTS = $(am_b2test_OBJECTS)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_DEPENDENCIES = libbacktrace_elf_for_test.la
+b2test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(b2test_CFLAGS) $(CFLAGS) \
+       $(b2test_LDFLAGS) $(LDFLAGS) -o $@
+@NATIVE_TRUE@am__objects_3 = b3test-btest.$(OBJEXT) \
+@NATIVE_TRUE@  b3test-testlib.$(OBJEXT)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b3test_OBJECTS = $(am__objects_3)
+b3test_OBJECTS = $(am_b3test_OBJECTS)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_DEPENDENCIES = libbacktrace_elf_for_test.la
+b3test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(b3test_CFLAGS) $(CFLAGS) \
+       $(b3test_LDFLAGS) $(LDFLAGS) -o $@
 @NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT) \
 @NATIVE_TRUE@  btest-testlib.$(OBJEXT)
 btest_OBJECTS = $(am_btest_OBJECTS)
@@ -213,9 +245,9 @@ btest_OBJECTS = $(am_btest_OBJECTS)
 btest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@
-@NATIVE_TRUE@am__objects_2 = btest_alloc-btest.$(OBJEXT) \
+@NATIVE_TRUE@am__objects_4 = btest_alloc-btest.$(OBJEXT) \
 @NATIVE_TRUE@  btest_alloc-testlib.$(OBJEXT)
-@NATIVE_TRUE@am_btest_alloc_OBJECTS = $(am__objects_2)
+@NATIVE_TRUE@am_btest_alloc_OBJECTS = $(am__objects_4)
 btest_alloc_OBJECTS = $(am_btest_alloc_OBJECTS)
 @NATIVE_TRUE@btest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 btest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -229,10 +261,10 @@ ctesta_OBJECTS = $(am_ctesta_OBJECTS)
 ctesta_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ctesta_CFLAGS) $(CFLAGS) \
        $(ctesta_LDFLAGS) $(LDFLAGS) -o $@
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__objects_3 = ctesta_alloc-btest.$(OBJEXT) \
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__objects_5 = ctesta_alloc-btest.$(OBJEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctesta_alloc-testlib.$(OBJEXT)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctesta_alloc_OBJECTS =  \
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      $(am__objects_3)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      $(am__objects_5)
 ctesta_alloc_OBJECTS = $(am_ctesta_alloc_OBJECTS)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_alloc_DEPENDENCIES = libbacktrace_alloc.la
 ctesta_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -246,10 +278,10 @@ ctestg_OBJECTS = $(am_ctestg_OBJECTS)
 ctestg_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ctestg_CFLAGS) $(CFLAGS) \
        $(ctestg_LDFLAGS) $(LDFLAGS) -o $@
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__objects_4 = ctestg_alloc-btest.$(OBJEXT) \
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__objects_6 = ctestg_alloc-btest.$(OBJEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      ctestg_alloc-testlib.$(OBJEXT)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctestg_alloc_OBJECTS =  \
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      $(am__objects_4)
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@      $(am__objects_6)
 ctestg_alloc_OBJECTS = $(am_ctestg_alloc_OBJECTS)
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_DEPENDENCIES = libbacktrace_alloc.la
 ctestg_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -259,16 +291,16 @@ ctestg_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 @NATIVE_TRUE@  edtest2_build.$(OBJEXT) testlib.$(OBJEXT)
 edtest_OBJECTS = $(am_edtest_OBJECTS)
 @NATIVE_TRUE@edtest_DEPENDENCIES = libbacktrace.la
-@NATIVE_TRUE@am__objects_5 = edtest.$(OBJEXT) edtest2_build.$(OBJEXT) \
+@NATIVE_TRUE@am__objects_7 = edtest.$(OBJEXT) edtest2_build.$(OBJEXT) \
 @NATIVE_TRUE@  testlib.$(OBJEXT)
-@NATIVE_TRUE@am_edtest_alloc_OBJECTS = $(am__objects_5)
+@NATIVE_TRUE@am_edtest_alloc_OBJECTS = $(am__objects_7)
 edtest_alloc_OBJECTS = $(am_edtest_alloc_OBJECTS)
 @NATIVE_TRUE@edtest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 @NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT)
 stest_OBJECTS = $(am_stest_OBJECTS)
 @NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
-@NATIVE_TRUE@am__objects_6 = stest.$(OBJEXT)
-@NATIVE_TRUE@am_stest_alloc_OBJECTS = $(am__objects_6)
+@NATIVE_TRUE@am__objects_8 = stest.$(OBJEXT)
+@NATIVE_TRUE@am_stest_alloc_OBJECTS = $(am__objects_8)
 stest_alloc_OBJECTS = $(am_stest_alloc_OBJECTS)
 @NATIVE_TRUE@stest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 @NATIVE_TRUE@am_test_elf_OBJECTS = test_format.$(OBJEXT) \
@@ -303,11 +335,11 @@ ttest_OBJECTS = $(am_ttest_OBJECTS)
 ttest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ttest_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__objects_7 =  \
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__objects_9 =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@       ttest_alloc-ttest.$(OBJEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@       ttest_alloc-testlib.$(OBJEXT)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_alloc_OBJECTS =  \
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@       $(am__objects_7)
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@       $(am__objects_9)
 ttest_alloc_OBJECTS = $(am_ttest_alloc_OBJECTS)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_alloc_DEPENDENCIES =  \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@       libbacktrace_alloc.la
@@ -318,8 +350,8 @@ ttest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 @NATIVE_TRUE@  testlib.$(OBJEXT)
 unittest_OBJECTS = $(am_unittest_OBJECTS)
 @NATIVE_TRUE@unittest_DEPENDENCIES = libbacktrace.la
-@NATIVE_TRUE@am__objects_8 = unittest.$(OBJEXT) testlib.$(OBJEXT)
-@NATIVE_TRUE@am_unittest_alloc_OBJECTS = $(am__objects_8)
+@NATIVE_TRUE@am__objects_10 = unittest.$(OBJEXT) testlib.$(OBJEXT)
+@NATIVE_TRUE@am_unittest_alloc_OBJECTS = $(am__objects_10)
 unittest_alloc_OBJECTS = $(am_unittest_alloc_OBJECTS)
 @NATIVE_TRUE@unittest_alloc_DEPENDENCIES = libbacktrace_alloc.la
 @NATIVE_TRUE@am_ztest_OBJECTS = ztest-ztest.$(OBJEXT) \
@@ -330,9 +362,9 @@ ztest_OBJECTS = $(am_ztest_OBJECTS)
 ztest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(ztest_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@
-@NATIVE_TRUE@am__objects_9 = ztest_alloc-ztest.$(OBJEXT) \
+@NATIVE_TRUE@am__objects_11 = ztest_alloc-ztest.$(OBJEXT) \
 @NATIVE_TRUE@  ztest_alloc-testlib.$(OBJEXT)
-@NATIVE_TRUE@am_ztest_alloc_OBJECTS = $(am__objects_9)
+@NATIVE_TRUE@am_ztest_alloc_OBJECTS = $(am__objects_11)
 ztest_alloc_OBJECTS = $(am_ztest_alloc_OBJECTS)
 @NATIVE_TRUE@ztest_alloc_DEPENDENCIES = libbacktrace_alloc.la \
 @NATIVE_TRUE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@@ -374,9 +406,11 @@ am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
        $(libbacktrace_alloc_la_SOURCES) \
+       $(libbacktrace_elf_for_test_la_SOURCES) \
        $(libbacktrace_instrumented_alloc_la_SOURCES) \
        $(libbacktrace_noformat_la_SOURCES) $(allocfail_SOURCES) \
-       $(btest_SOURCES) $(btest_alloc_SOURCES) $(ctesta_SOURCES) \
+       $(b2test_SOURCES) $(b3test_SOURCES) $(btest_SOURCES) \
+       $(btest_alloc_SOURCES) $(ctesta_SOURCES) \
        $(ctesta_alloc_SOURCES) $(ctestg_SOURCES) \
        $(ctestg_alloc_SOURCES) $(edtest_SOURCES) \
        $(edtest_alloc_SOURCES) $(stest_SOURCES) \
@@ -683,6 +717,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PIC_FLAG = @PIC_FLAG@
 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
 RANLIB = @RANLIB@
+READELF = @READELF@
 SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
@@ -796,9 +831,9 @@ libbacktrace_la_LIBADD = \
 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
 
 # Add test to this variable, if you want it to be build and run.
-BUILDTESTS = $(am__append_1) $(am__append_8) $(am__append_10)
+BUILDTESTS = $(am__append_2) $(am__append_11) $(am__append_13)
 @NATIVE_TRUE@check_LTLIBRARIES = libbacktrace_alloc.la \
-@NATIVE_TRUE@  libbacktrace_noformat.la \
+@NATIVE_TRUE@  libbacktrace_noformat.la $(am__append_1) \
 @NATIVE_TRUE@  libbacktrace_instrumented_alloc.la
 @NATIVE_TRUE@libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
 @NATIVE_TRUE@libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
@@ -806,6 +841,11 @@ BUILDTESTS = $(am__append_1) $(am__append_8) $(am__append_10)
 @NATIVE_TRUE@libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
 @NATIVE_TRUE@libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
 @NATIVE_TRUE@libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@TEST_BUILD_ID_DIR = $(abs_builddir)/usr/lib/debug/.build-id/
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      $(VIEW_FILE) $(ALLOC_FILE)
+
 @NATIVE_TRUE@test_elf_SOURCES = test_format.c testlib.c
 @NATIVE_TRUE@test_elf_LDADD = libbacktrace_noformat.la elf.lo
 @NATIVE_TRUE@test_xcoff_32_SOURCES = test_format.c testlib.c
@@ -829,6 +869,14 @@ BUILDTESTS = $(am__append_1) $(am__append_8) $(am__append_10)
 
 @NATIVE_TRUE@allocfail_SOURCES = allocfail.c testlib.c
 @NATIVE_TRUE@allocfail_LDADD = libbacktrace_instrumented_alloc.la
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_SOURCES = $(btest_SOURCES)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_CFLAGS = $(btest_CFLAGS)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDFLAGS = -Wl,--build-id
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDADD = libbacktrace_elf_for_test.la
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_SOURCES = $(btest_SOURCES)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_CFLAGS = $(btest_CFLAGS)
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDFLAGS = -Wl,--build-id
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDADD = libbacktrace_elf_for_test.la
 @NATIVE_TRUE@btest_SOURCES = btest.c testlib.c
 @NATIVE_TRUE@btest_CFLAGS = $(AM_CFLAGS) -g -O
 @NATIVE_TRUE@btest_LDADD = libbacktrace.la
@@ -841,10 +889,10 @@ BUILDTESTS = $(am__append_1) $(am__append_8) $(am__append_10)
 @NATIVE_TRUE@stest_alloc_LDADD = libbacktrace_alloc.la
 @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
 @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
-@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_6) \
-@NATIVE_TRUE@  $(CLOCK_GETTIME_LINK)
-@NATIVE_TRUE@ztest_alloc_LDADD = libbacktrace_alloc.la $(am__append_7) \
+@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_9) \
 @NATIVE_TRUE@  $(CLOCK_GETTIME_LINK)
+@NATIVE_TRUE@ztest_alloc_LDADD = libbacktrace_alloc.la \
+@NATIVE_TRUE@  $(am__append_10) $(CLOCK_GETTIME_LINK)
 @NATIVE_TRUE@ztest_alloc_SOURCES = $(ztest_SOURCES)
 @NATIVE_TRUE@ztest_alloc_CFLAGS = $(ztest_CFLAGS)
 @NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c
@@ -948,6 +996,8 @@ distclean-hdr:
        -rm -f config.h stamp-h1
 backtrace-supported.h: $(top_builddir)/config.status $(srcdir)/backtrace-supported.h.in
        cd $(top_builddir) && $(SHELL) ./config.status $@
+install-debuginfo-for-buildid.sh: $(top_builddir)/config.status $(srcdir)/install-debuginfo-for-buildid.sh.in
+       cd $(top_builddir) && $(SHELL) ./config.status $@
 
 clean-checkLTLIBRARIES:
        -test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES)
@@ -977,6 +1027,9 @@ libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) $(EX
 libbacktrace_alloc.la: $(libbacktrace_alloc_la_OBJECTS) $(libbacktrace_alloc_la_DEPENDENCIES) $(EXTRA_libbacktrace_alloc_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) $(am_libbacktrace_alloc_la_rpath) $(libbacktrace_alloc_la_OBJECTS) $(libbacktrace_alloc_la_LIBADD) $(LIBS)
 
+libbacktrace_elf_for_test.la: $(libbacktrace_elf_for_test_la_OBJECTS) $(libbacktrace_elf_for_test_la_DEPENDENCIES) $(EXTRA_libbacktrace_elf_for_test_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK) $(am_libbacktrace_elf_for_test_la_rpath) $(libbacktrace_elf_for_test_la_OBJECTS) $(libbacktrace_elf_for_test_la_LIBADD) $(LIBS)
+
 libbacktrace_instrumented_alloc.la: $(libbacktrace_instrumented_alloc_la_OBJECTS) $(libbacktrace_instrumented_alloc_la_DEPENDENCIES) $(EXTRA_libbacktrace_instrumented_alloc_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) $(am_libbacktrace_instrumented_alloc_la_rpath) $(libbacktrace_instrumented_alloc_la_OBJECTS) $(libbacktrace_instrumented_alloc_la_LIBADD) $(LIBS)
 
@@ -996,6 +1049,14 @@ allocfail$(EXEEXT): $(allocfail_OBJECTS) $(allocfail_DEPENDENCIES) $(EXTRA_alloc
        @rm -f allocfail$(EXEEXT)
        $(AM_V_CCLD)$(LINK) $(allocfail_OBJECTS) $(allocfail_LDADD) $(LIBS)
 
+b2test$(EXEEXT): $(b2test_OBJECTS) $(b2test_DEPENDENCIES) $(EXTRA_b2test_DEPENDENCIES) 
+       @rm -f b2test$(EXEEXT)
+       $(AM_V_CCLD)$(b2test_LINK) $(b2test_OBJECTS) $(b2test_LDADD) $(LIBS)
+
+b3test$(EXEEXT): $(b3test_OBJECTS) $(b3test_DEPENDENCIES) $(EXTRA_b3test_DEPENDENCIES) 
+       @rm -f b3test$(EXEEXT)
+       $(AM_V_CCLD)$(b3test_LINK) $(b3test_OBJECTS) $(b3test_LDADD) $(LIBS)
+
 btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) $(EXTRA_btest_DEPENDENCIES) 
        @rm -f btest$(EXEEXT)
        $(AM_V_CCLD)$(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS)
@@ -1095,6 +1156,30 @@ distclean-compile:
 .c.lo:
        $(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
 
+b2test-btest.o: btest.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b2test_CFLAGS) $(CFLAGS) -c -o b2test-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
+
+b2test-btest.obj: btest.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b2test_CFLAGS) $(CFLAGS) -c -o b2test-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
+
+b2test-testlib.o: testlib.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b2test_CFLAGS) $(CFLAGS) -c -o b2test-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
+
+b2test-testlib.obj: testlib.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b2test_CFLAGS) $(CFLAGS) -c -o b2test-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
+
+b3test-btest.o: btest.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b3test_CFLAGS) $(CFLAGS) -c -o b3test-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
+
+b3test-btest.obj: btest.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b3test_CFLAGS) $(CFLAGS) -c -o b3test-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
+
+b3test-testlib.o: testlib.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b3test_CFLAGS) $(CFLAGS) -c -o b3test-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
+
+b3test-testlib.obj: testlib.c
+       $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(b3test_CFLAGS) $(CFLAGS) -c -o b3test-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
+
 btest-btest.o: btest.c
        $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
 
@@ -1431,6 +1516,20 @@ allocfail.sh.log: allocfail.sh
        --log-file $$b.log --trs-file $$b.trs \
        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
        "$$tst" $(AM_TESTS_FD_REDIRECT)
+b2test_buildid.log: b2test_buildid
+       @p='b2test_buildid'; \
+       b='b2test_buildid'; \
+       $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+       --log-file $$b.log --trs-file $$b.trs \
+       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+       "$$tst" $(AM_TESTS_FD_REDIRECT)
+b3test_dwz_buildid.log: b3test_dwz_buildid
+       @p='b3test_dwz_buildid'; \
+       b='b3test_dwz_buildid'; \
+       $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+       --log-file $$b.log --trs-file $$b.trs \
+       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+       "$$tst" $(AM_TESTS_FD_REDIRECT)
 btest_dwz.log: btest_dwz
        @p='btest_dwz'; \
        b='btest_dwz'; \
@@ -1748,6 +1847,14 @@ uninstall-am:
 .PRECIOUS: Makefile
 
 
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@elf_for_test.c: elf.c
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      $(SED) "s%$$SEARCH%$$REPLACE%" \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@              $< \
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@              > $@.tmp
+@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@      mv $@.tmp $@
+
 @NATIVE_TRUE@xcoff_%.c: xcoff.c
 @NATIVE_TRUE@  SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
 @NATIVE_TRUE@  REPLACE='#undef BACKTRACE_XCOFF_SIZE\
@@ -1778,6 +1885,12 @@ uninstall-am:
 @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@%_gnudebuglink: %
 @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@     $(OBJCOPY) --only-keep-debug $< $@.debug
 @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@     $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
+
+@NATIVE_TRUE@%_buildid: %
+@NATIVE_TRUE@  ./install-debuginfo-for-buildid.sh \
+@NATIVE_TRUE@    "$(TEST_BUILD_ID_DIR)" \
+@NATIVE_TRUE@    $<
+@NATIVE_TRUE@  $(OBJCOPY) --strip-debug $< $@
 alloc.lo: config.h backtrace.h internal.h
 backtrace.lo: config.h backtrace.h internal.h
 btest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h
index 2ea112bde6845e5ead888ad6cb8d261e45aa6991..51d7cb4582a84ec061bc2bd3d54e6b5b9148a9a6 100755 (executable)
@@ -637,6 +637,7 @@ NATIVE_FALSE
 NATIVE_TRUE
 HAVE_OBJCOPY_DEBUGLINK_FALSE
 HAVE_OBJCOPY_DEBUGLINK_TRUE
+READELF
 OBJCOPY
 HAVE_COMPRESSED_DEBUG_FALSE
 HAVE_COMPRESSED_DEBUG_TRUE
@@ -651,6 +652,8 @@ ALLOC_FILE
 VIEW_FILE
 BACKTRACE_SUPPORTS_DATA
 BACKTRACE_SUPPORTED
+HAVE_ELF_FALSE
+HAVE_ELF_TRUE
 FORMAT_FILE
 BACKTRACE_SUPPORTS_THREADS
 PIC_FLAG
@@ -11489,7 +11492,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11492 "configure"
+#line 11495 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11595,7 +11598,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11598 "configure"
+#line 11601 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12512,6 +12515,14 @@ cat >>confdefs.h <<_ACEOF
 #define BACKTRACE_ELF_SIZE $elfsize
 _ACEOF
 
+ if test "$FORMAT_FILE" = "elf.lo"; then
+  HAVE_ELF_TRUE=
+  HAVE_ELF_FALSE='#'
+else
+  HAVE_ELF_TRUE='#'
+  HAVE_ELF_FALSE=
+fi
+
 
 # XCOFF defines.
 xcoffsize=
@@ -13400,6 +13411,43 @@ $as_echo "no" >&6; }
 fi
 
 
+# Extract the first word of "readelf", so it can be a program name with args.
+set dummy readelf; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_READELF+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$READELF"; then
+  ac_cv_prog_READELF="$READELF" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_READELF="readelf"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+READELF=$ac_cv_prog_READELF
+if test -n "$READELF"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5
+$as_echo "$READELF" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether objcopy supports debuglink" >&5
 $as_echo_n "checking whether objcopy supports debuglink... " >&6; }
 if ${libbacktrace_cv_objcopy_debuglink+:} false; then :
@@ -13473,6 +13521,8 @@ fi
 
 ac_config_files="$ac_config_files Makefile backtrace-supported.h"
 
+ac_config_files="$ac_config_files install-debuginfo-for-buildid.sh"
+
 
 # We need multilib support, but only if configuring for the target.
 ac_config_commands="$ac_config_commands default"
@@ -13611,6 +13661,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_DWZ\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_ELF_TRUE}" && test -z "${HAVE_ELF_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_ELF\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HAVE_PTHREAD_TRUE}" && test -z "${HAVE_PTHREAD_FALSE}"; then
   as_fn_error $? "conditional \"HAVE_PTHREAD\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -14525,6 +14579,7 @@ do
     "gstdint.h") CONFIG_COMMANDS="$CONFIG_COMMANDS gstdint.h" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "backtrace-supported.h") CONFIG_FILES="$CONFIG_FILES backtrace-supported.h" ;;
+    "install-debuginfo-for-buildid.sh") CONFIG_FILES="$CONFIG_FILES install-debuginfo-for-buildid.sh" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -16140,6 +16195,7 @@ else
 fi
 
  ;;
+    "install-debuginfo-for-buildid.sh":F) chmod +x install-debuginfo-for-buildid.sh ;;
     "default":C) if test -n "$CONFIG_FILES"; then
    if test -n "${with_target_subdir}"; then
      # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
index c64bf3473bbd7fc2c7cb6af29e2bdd4ebd3f9045..dd25095dcf826b3f4ba8d3fc927de7343de07b1f 100644 (file)
@@ -259,6 +259,7 @@ elf64) elfsize=64 ;;
 *)     elfsize=unused
 esac
 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
+AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo")
 
 # XCOFF defines.
 xcoffsize=
@@ -445,6 +446,7 @@ AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
 
 AC_ARG_VAR(OBJCOPY, [location of objcopy])
 AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
+AC_CHECK_PROG(READELF, readelf, readelf)
 AC_CACHE_CHECK([whether objcopy supports debuglink],
 [libbacktrace_cv_objcopy_debuglink],
 [if test -n "${with_target_subdir}"; then
@@ -472,6 +474,7 @@ else
 fi
 
 AC_CONFIG_FILES(Makefile backtrace-supported.h)
+AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
 
 # We need multilib support, but only if configuring for the target.
 AC_CONFIG_COMMANDS([default],
index 6fee865bece700081005b3a0a3a7f743a89f9a18..d933052200c0ed107555e88244ca673c02a7bdf3 100644 (file)
@@ -809,6 +809,8 @@ elf_readlink (struct backtrace_state *state, const char *filename,
     }
 }
 
+#define SYSTEM_BUILD_ID_DIR "/usr/lib/debug/.build-id/"
+
 /* Open a separate debug info file, using the build ID to find it.
    Returns an open file descriptor, or -1.
 
@@ -821,7 +823,7 @@ elf_open_debugfile_by_buildid (struct backtrace_state *state,
                               backtrace_error_callback error_callback,
                               void *data)
 {
-  const char * const prefix = "/usr/lib/debug/.build-id/";
+  const char * const prefix = SYSTEM_BUILD_ID_DIR;
   const size_t prefix_len = strlen (prefix);
   const char * const suffix = ".debug";
   const size_t suffix_len = strlen (suffix);
diff --git a/libbacktrace/install-debuginfo-for-buildid.sh.in b/libbacktrace/install-debuginfo-for-buildid.sh.in
new file mode 100644 (file)
index 0000000..b98d891
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# install-debug-info-for-buildid.sh -- Helper script for libbacktrace library
+# testing.
+# Copyright (C) 2019 Free Software Foundation, Inc.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+
+#     (1) Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+
+#     (2) Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+
+#     (3) The name of the author may not be used to
+#     endorse or promote products derived from this software without
+#     specific prior written permission.
+
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Extract build-id from src, and copy debug info of src to
+# $build_id_dir/aa/bb...zz.debug.
+
+set -e
+
+sed=@SED@
+awk=@AWK@
+grep=@GREP@
+objcopy=@OBJCOPY@
+readelf=@READELF@
+mkdir_p="@MKDIR_P@"
+
+build_id_dir="$1"
+src="$2"
+
+buildid=$($readelf -n $src \
+             | $grep "Build ID" \
+             | $awk '{print $3}')
+
+prefix=$(echo $buildid \
+            | $sed 's/^\(.\{2\}\).*/\1/')
+
+remainder=$(echo $buildid \
+               | $sed 's/^.\{2\}//')
+
+dir=$build_id_dir/$prefix
+dst=$dir/$remainder.debug
+
+$mkdir_p $dir
+
+$objcopy --only-keep-debug $src $dst