libbacktrace: support MiniDebugInfo

libbacktrace/ChangeLog:
	PR libbacktrace/93608
	Add support for MiniDebugInfo.
	* elf.c (struct elf_view): Define.  Replace most uses of
	backtrace_view with elf_view.
	(elf_get_view): New static functions.  Replace most calls of
	backtrace_get_view with elf_get_view.
	(elf_release_view): New static functions.  Replace most calls of
	backtrace_release_view with elf_release_view.
	(elf_uncompress_failed): Rename from elf_zlib_failed.  Change all
	callers.
	(LZMA_STATES, LZMA_POS_STATES, LZMA_DIST_STATES): Define.
	(LZMA_DIST_SLOTS, LZMA_DIST_MODEL_START): Define.
	(LZMA_DIST_MODEL_END, LZMA_FULL_DISTANCES): Define.
	(LZMA_ALIGN_SIZE, LZMA_LEN_LOW_SYMBOLS): Define.
	(LZMA_LEN_MID_SYMBOLS, LZMA_LEN_HIGH_SYMBOLS): Define.
	(LZMA_LITERAL_CODERS_MAX, LZMA_LITERAL_CODER_SIZE): Define.
	(LZMA_PROB_IS_MATCH_LEN, LZMA_PROB_IS_REP_LEN): Define.
	(LZMA_PROB_IS_REP0_LEN, LZMA_PROB_IS_REP1_LEN): Define.
	(LZMA_PROB_IS_REP2_LEN, LZMA_PROB_IS_REP0_LONG_LEN): Define.
	(LZMA_PROB_DIST_SLOT_LEN, LZMA_PROB_DIST_SPECIAL_LEN): Define.
	(LZMA_PROB_DIST_ALIGN_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_MATCH_LEN_LOW_LEN): Define.
	(LZMA_PROB_MATCH_LEN_MID_LEN): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_REP_LEN_LOW_LEN): Define.
	(LZMA_PROB_REP_LEN_MID_LEN): Define.
	(LZMA_PROB_REP_LEN_HIGH_LEN): Define.
	(LZMA_PROB_LITERAL_LEN): Define.
	(LZMA_PROB_IS_MATCH_OFFSET, LZMA_PROB_IS_REP_OFFSET): Define.
	(LZMA_PROB_IS_REP0_OFFSET, LZMA_PROB_IS_REP1_OFFSET): Define.
	(LZMA_PROB_IS_REP2_OFFSET): Define.
	(LZMA_PROB_IS_REP0_LONG_OFFSET): Define.
	(LZMA_PROB_DIST_SLOT_OFFSET): Define.
	(LZMA_PROB_DIST_SPECIAL_OFFSET): Define.
	(LZMA_PROB_DIST_ALIGN_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_MID_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_REP_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_REP_LEN_MID_OFFSET): Define.
	(LZMA_PROB_REP_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_LITERAL_OFFSET): Define.
	(LZMA_PROB_TOTAL_COUNT): Define.
	(LZMA_IS_MATCH, LZMA_IS_REP, LZMA_IS_REP0): Define.
	(LZMA_IS_REP1, LZMA_IS_REP2, LZMA_IS_REP0_LONG): Define.
	(LZMA_DIST_SLOT, LZMA_DIST_SPECIAL, LZMA_DIST_ALIGN): Define.
	(LZMA_MATCH_LEN_CHOICE, LZMA_MATCH_LEN_CHOICE2): Define.
	(LZMA_MATCH_LEN_LOW, LZMA_MATCH_LEN_MID): Define.
	(LZMA_MATCH_LEN_HIGH, LZMA_REP_LEN_CHOICE): Define.
	(LZMA_REP_LEN_CHOICE2, LZMA_REP_LEN_LOW): Define.
	(LZMA_REP_LEN_MID, LZMA_REP_LEN_HIGH, LZMA_LITERAL): Define.
	(elf_lzma_varint): New static function.
	(elf_lzma_range_normalize): New static function.
	(elf_lzma_bit, elf_lzma_integer): New static functions.
	(elf_lzma_reverse_integer): New static function.
	(elf_lzma_len, elf_uncompress_lzma_block): New static functions.
	(elf_uncompress_lzma): New static function.
	(backtrace_uncompress_lzma): New function.
	(elf_add): Add memory and memory_size parameters.  Change all
	callers.  Look for .gnu_debugdata section, and, if found,
	decompress it and use it for symbols and debug info.  Permit the
	descriptor parameter to be -1.
	* internal.h (backtrace_uncompress_lzma): Declare.
	* mtest.c: New file.
	* xztest.c: New file.
	* configure.ac: Check for nm, xz, and comm programs.  Check for
	liblzma library.
	(HAVE_MINIDEBUG): Define.
	* Makefile.am (mtest_SOURCES): Define.
	(mtest_CFLAGS, mtest_LDADD): Define.
	(TESTS): Add mtest_minidebug if HAVE_MINIDEBUG.
	(%_minidebug): New pattern rule, if HAVE_MINIDEBUG.
	(xztest_SOURCES, xztest_CFLAGS, xztest_LDADD): Define.
	(xztest_alloc_SOURCES, xztest_alloc_CFLAGS): Define
	(xztest_alloc_LDADD): Define.
	(BUILDTESTS): Add mtest, xztest, xztest_alloc.
	(CLEANFILES): Add files created by minidebug pattern.
	(btest.lo): Correct INCDIR reference.
	(mtest.lo, xztest.lo, ztest.lo): New targets.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* Makefile.in: Regenerate.
This commit is contained in:
Ian Lance Taylor 2020-09-14 14:01:56 -07:00
parent cd6743e9c4
commit 05f40bc4c1
9 changed files with 2913 additions and 166 deletions

View File

@ -478,13 +478,61 @@ endif HAVE_DSYMUTIL
endif
mtest_SOURCES = mtest.c testlib.c
mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
mtest_LDADD = libbacktrace.la
BUILDTESTS += mtest
if HAVE_MINIDEBUG
TESTS += mtest_minidebug
%_minidebug: %
$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
$(OBJCOPY) --only-keep-debug $< $<.dbg
$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
$(OBJCOPY) --strip-all --remove-section ..comment $< $<.strip
rm -f $<.mdbg.xz
$(XZ) $<.mdbg
$(OBJCOPY) --add-section .gnu_debugdata=$<.mdbg.xz $<.strip
mv $<.strip $@
endif HAVE_MINIDEBUG
endif NATIVE
if HAVE_ELF
xztest_SOURCES = xztest.c testlib.c
xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
xztest_LDADD = libbacktrace.la
xztest_alloc_SOURCES = $(xztest_SOURCES)
xztest_alloc_CFLAGS = $(xztest_CFLAGS)
xztest_alloc_LDADD = libbacktrace_alloc.la
if HAVE_LIBLZMA
xztest_LDADD += -llzma
xztest_alloc_LDADD += -llzma
endif
xztest_LDADD += $(CLOCK_GETTIME_LINK)
xztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
BUILDTESTS += xztest xztest_alloc
endif HAVE_ELF
check_PROGRAMS += $(BUILDTESTS)
TESTS += $(BUILDTESTS)
CLEANFILES = $(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build
CLEANFILES = \
$(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build \
*.dsyms *.fsyms *.keepsyms *.dbg *.mdbg *.mdbg.xz *.strip
clean-local:
-rm -rf usr
@ -504,7 +552,7 @@ clean-local:
INCDIR = $(top_srcdir)/../include
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
btest.lo: $(INCDIR)/filenames.h backtrace.h backtrace-supported.h
dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \
$(INCDIR)/filenames.h backtrace.h internal.h
elf.lo: config.h backtrace.h internal.h
@ -512,6 +560,7 @@ fileline.lo: config.h backtrace.h internal.h
macho.lo: config.h backtrace.h internal.h
mmap.lo: config.h backtrace.h internal.h
mmapio.lo: config.h backtrace.h internal.h
mtest.lo: backtrace.h backtrace-supported.h
nounwind.lo: config.h internal.h
pecoff.lo: config.h backtrace.h internal.h
posix.lo: config.h backtrace.h internal.h
@ -523,5 +572,7 @@ stest.lo: config.h backtrace.h internal.h
state.lo: config.h backtrace.h backtrace-supported.h internal.h
unknown.lo: config.h backtrace.h internal.h
xcoff.lo: config.h backtrace.h internal.h
xztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
ztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
include $(top_srcdir)/../multilib.am

View File

@ -121,10 +121,10 @@ build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
$(am__EXEEXT_12)
$(am__EXEEXT_14)
TESTS = $(am__append_4) $(am__append_7) $(am__append_9) \
$(am__append_12) $(am__append_13) $(am__append_20) \
$(am__EXEEXT_12)
$(am__append_25) $(am__EXEEXT_14)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_1 = libbacktrace_elf_for_test.la
@NATIVE_TRUE@am__append_2 = test_elf_32 test_elf_64 test_macho \
@NATIVE_TRUE@ test_xcoff_32 test_xcoff_64 test_pecoff \
@ -157,6 +157,11 @@ TESTS = $(am__append_4) $(am__append_7) $(am__append_9) \
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_22 = dwarf5 dwarf5_alloc
@HAVE_DSYMUTIL_TRUE@@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_23 = dwarf5.dSYM \
@HAVE_DSYMUTIL_TRUE@@HAVE_DWARF5_TRUE@@NATIVE_TRUE@ dwarf5_alloc.dSYM
@NATIVE_TRUE@am__append_24 = mtest
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@am__append_25 = mtest_minidebug
@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_26 = -llzma
@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_27 = -llzma
@HAVE_ELF_TRUE@am__append_28 = xztest xztest_alloc
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \
@ -235,9 +240,12 @@ libbacktrace_noformat_la_OBJECTS = \
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta_alloc$(EXEEXT)
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__EXEEXT_11 = dwarf5$(EXEEXT) \
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@ dwarf5_alloc$(EXEEXT)
am__EXEEXT_12 = $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
@NATIVE_TRUE@am__EXEEXT_12 = mtest$(EXEEXT)
@HAVE_ELF_TRUE@am__EXEEXT_13 = xztest$(EXEEXT) xztest_alloc$(EXEEXT)
am__EXEEXT_14 = $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \
$(am__EXEEXT_10) $(am__EXEEXT_11)
$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
$(am__EXEEXT_13)
@NATIVE_TRUE@am_allocfail_OBJECTS = allocfail-allocfail.$(OBJEXT) \
@NATIVE_TRUE@ allocfail-testlib.$(OBJEXT)
allocfail_OBJECTS = $(am_allocfail_OBJECTS)
@ -355,6 +363,13 @@ edtest_alloc_OBJECTS = $(am_edtest_alloc_OBJECTS)
edtest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(edtest_alloc_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@NATIVE_TRUE@am_mtest_OBJECTS = mtest-mtest.$(OBJEXT) \
@NATIVE_TRUE@ mtest-testlib.$(OBJEXT)
mtest_OBJECTS = $(am_mtest_OBJECTS)
@NATIVE_TRUE@mtest_DEPENDENCIES = libbacktrace.la
mtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(mtest_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
@NATIVE_TRUE@am_stest_OBJECTS = stest-stest.$(OBJEXT)
stest_OBJECTS = $(am_stest_OBJECTS)
@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
@ -465,6 +480,23 @@ unittest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(unittest_alloc_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \
$@
@HAVE_ELF_TRUE@am_xztest_OBJECTS = xztest-xztest.$(OBJEXT) \
@HAVE_ELF_TRUE@ xztest-testlib.$(OBJEXT)
xztest_OBJECTS = $(am_xztest_OBJECTS)
@HAVE_ELF_TRUE@xztest_DEPENDENCIES = libbacktrace.la \
@HAVE_ELF_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
xztest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(xztest_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
@HAVE_ELF_TRUE@am__objects_12 = xztest_alloc-xztest.$(OBJEXT) \
@HAVE_ELF_TRUE@ xztest_alloc-testlib.$(OBJEXT)
@HAVE_ELF_TRUE@am_xztest_alloc_OBJECTS = $(am__objects_12)
xztest_alloc_OBJECTS = $(am_xztest_alloc_OBJECTS)
@HAVE_ELF_TRUE@xztest_alloc_DEPENDENCIES = libbacktrace_alloc.la \
@HAVE_ELF_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
xztest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(xztest_alloc_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@HAVE_ELF_TRUE@@NATIVE_TRUE@am_ztest_OBJECTS = ztest-ztest.$(OBJEXT) \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ ztest-testlib.$(OBJEXT)
ztest_OBJECTS = $(am_ztest_OBJECTS)
@ -474,11 +506,11 @@ 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 $@
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_12 = \
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_13 = \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ ztest_alloc-ztest.$(OBJEXT) \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ ztest_alloc-testlib.$(OBJEXT)
@HAVE_ELF_TRUE@@NATIVE_TRUE@am_ztest_alloc_OBJECTS = \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__objects_12)
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__objects_13)
ztest_alloc_OBJECTS = $(am_ztest_alloc_OBJECTS)
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_DEPENDENCIES = \
@HAVE_ELF_TRUE@@NATIVE_TRUE@ libbacktrace_alloc.la \
@ -530,13 +562,14 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
$(ctesta_alloc_SOURCES) $(ctestg_SOURCES) \
$(ctestg_alloc_SOURCES) $(dwarf5_SOURCES) \
$(dwarf5_alloc_SOURCES) $(edtest_SOURCES) \
$(edtest_alloc_SOURCES) $(stest_SOURCES) \
$(edtest_alloc_SOURCES) $(mtest_SOURCES) $(stest_SOURCES) \
$(stest_alloc_SOURCES) $(test_elf_32_SOURCES) \
$(test_elf_64_SOURCES) $(test_macho_SOURCES) \
$(test_pecoff_SOURCES) $(test_unknown_SOURCES) \
$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \
$(ttest_SOURCES) $(ttest_alloc_SOURCES) $(unittest_SOURCES) \
$(unittest_alloc_SOURCES) $(ztest_SOURCES) \
$(unittest_alloc_SOURCES) $(xztest_SOURCES) \
$(xztest_alloc_SOURCES) $(ztest_SOURCES) \
$(ztest_alloc_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
@ -786,6 +819,7 @@ CC = @CC@
CET_HOST_FLAGS = @CET_HOST_FLAGS@
CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
COMM = @COMM@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
@ -844,6 +878,7 @@ STRIP = @STRIP@
VERSION = @VERSION@
VIEW_FILE = @VIEW_FILE@
WARN_FLAGS = @WARN_FLAGS@
XZ = @XZ@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@ -953,7 +988,8 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
# Add a test to this variable if you want it to be built and run.
BUILDTESTS = $(am__append_2) $(am__append_10) $(am__append_11) \
$(am__append_16) $(am__append_17) $(am__append_18) \
$(am__append_21) $(am__append_22)
$(am__append_21) $(am__append_22) $(am__append_24) \
$(am__append_28)
# Add a file to this variable if you want it to be built for testing.
check_DATA = $(am__append_5) $(am__append_19) $(am__append_23)
@ -1078,7 +1114,21 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@dwarf5_alloc_LDADD = libbacktrace_alloc.la
CLEANFILES = $(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build
@NATIVE_TRUE@mtest_SOURCES = mtest.c testlib.c
@NATIVE_TRUE@mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
@NATIVE_TRUE@mtest_LDADD = libbacktrace.la
@HAVE_ELF_TRUE@xztest_SOURCES = xztest.c testlib.c
@HAVE_ELF_TRUE@xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
@HAVE_ELF_TRUE@xztest_LDADD = libbacktrace.la $(am__append_26) \
@HAVE_ELF_TRUE@ $(CLOCK_GETTIME_LINK)
@HAVE_ELF_TRUE@xztest_alloc_SOURCES = $(xztest_SOURCES)
@HAVE_ELF_TRUE@xztest_alloc_CFLAGS = $(xztest_CFLAGS)
@HAVE_ELF_TRUE@xztest_alloc_LDADD = libbacktrace_alloc.la \
@HAVE_ELF_TRUE@ $(am__append_27) $(CLOCK_GETTIME_LINK)
CLEANFILES = \
$(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build \
*.dsyms *.fsyms *.keepsyms *.dbg *.mdbg *.mdbg.xz *.strip
# We can't use automake's automatic dependency tracking, because it
# breaks when using bootstrap-lean. Automatic dependency tracking
@ -1259,6 +1309,10 @@ edtest_alloc$(EXEEXT): $(edtest_alloc_OBJECTS) $(edtest_alloc_DEPENDENCIES) $(EX
@rm -f edtest_alloc$(EXEEXT)
$(AM_V_CCLD)$(edtest_alloc_LINK) $(edtest_alloc_OBJECTS) $(edtest_alloc_LDADD) $(LIBS)
mtest$(EXEEXT): $(mtest_OBJECTS) $(mtest_DEPENDENCIES) $(EXTRA_mtest_DEPENDENCIES)
@rm -f mtest$(EXEEXT)
$(AM_V_CCLD)$(mtest_LINK) $(mtest_OBJECTS) $(mtest_LDADD) $(LIBS)
stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES) $(EXTRA_stest_DEPENDENCIES)
@rm -f stest$(EXEEXT)
$(AM_V_CCLD)$(stest_LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS)
@ -1311,6 +1365,14 @@ unittest_alloc$(EXEEXT): $(unittest_alloc_OBJECTS) $(unittest_alloc_DEPENDENCIES
@rm -f unittest_alloc$(EXEEXT)
$(AM_V_CCLD)$(unittest_alloc_LINK) $(unittest_alloc_OBJECTS) $(unittest_alloc_LDADD) $(LIBS)
xztest$(EXEEXT): $(xztest_OBJECTS) $(xztest_DEPENDENCIES) $(EXTRA_xztest_DEPENDENCIES)
@rm -f xztest$(EXEEXT)
$(AM_V_CCLD)$(xztest_LINK) $(xztest_OBJECTS) $(xztest_LDADD) $(LIBS)
xztest_alloc$(EXEEXT): $(xztest_alloc_OBJECTS) $(xztest_alloc_DEPENDENCIES) $(EXTRA_xztest_alloc_DEPENDENCIES)
@rm -f xztest_alloc$(EXEEXT)
$(AM_V_CCLD)$(xztest_alloc_LINK) $(xztest_alloc_OBJECTS) $(xztest_alloc_LDADD) $(LIBS)
ztest$(EXEEXT): $(ztest_OBJECTS) $(ztest_DEPENDENCIES) $(EXTRA_ztest_DEPENDENCIES)
@rm -f ztest$(EXEEXT)
$(AM_V_CCLD)$(ztest_LINK) $(ztest_OBJECTS) $(ztest_LDADD) $(LIBS)
@ -1514,6 +1576,18 @@ edtest_alloc-testlib.o: testlib.c
edtest_alloc-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(edtest_alloc_CFLAGS) $(CFLAGS) -c -o edtest_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
mtest-mtest.o: mtest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mtest_CFLAGS) $(CFLAGS) -c -o mtest-mtest.o `test -f 'mtest.c' || echo '$(srcdir)/'`mtest.c
mtest-mtest.obj: mtest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mtest_CFLAGS) $(CFLAGS) -c -o mtest-mtest.obj `if test -f 'mtest.c'; then $(CYGPATH_W) 'mtest.c'; else $(CYGPATH_W) '$(srcdir)/mtest.c'; fi`
mtest-testlib.o: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mtest_CFLAGS) $(CFLAGS) -c -o mtest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
mtest-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mtest_CFLAGS) $(CFLAGS) -c -o mtest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
stest-stest.o: stest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stest_CFLAGS) $(CFLAGS) -c -o stest-stest.o `test -f 'stest.c' || echo '$(srcdir)/'`stest.c
@ -1658,6 +1732,30 @@ unittest_alloc-testlib.o: testlib.c
unittest_alloc-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(unittest_alloc_CFLAGS) $(CFLAGS) -c -o unittest_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
xztest-xztest.o: xztest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_CFLAGS) $(CFLAGS) -c -o xztest-xztest.o `test -f 'xztest.c' || echo '$(srcdir)/'`xztest.c
xztest-xztest.obj: xztest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_CFLAGS) $(CFLAGS) -c -o xztest-xztest.obj `if test -f 'xztest.c'; then $(CYGPATH_W) 'xztest.c'; else $(CYGPATH_W) '$(srcdir)/xztest.c'; fi`
xztest-testlib.o: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_CFLAGS) $(CFLAGS) -c -o xztest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
xztest-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_CFLAGS) $(CFLAGS) -c -o xztest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
xztest_alloc-xztest.o: xztest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_alloc_CFLAGS) $(CFLAGS) -c -o xztest_alloc-xztest.o `test -f 'xztest.c' || echo '$(srcdir)/'`xztest.c
xztest_alloc-xztest.obj: xztest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_alloc_CFLAGS) $(CFLAGS) -c -o xztest_alloc-xztest.obj `if test -f 'xztest.c'; then $(CYGPATH_W) 'xztest.c'; else $(CYGPATH_W) '$(srcdir)/xztest.c'; fi`
xztest_alloc-testlib.o: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_alloc_CFLAGS) $(CFLAGS) -c -o xztest_alloc-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
xztest_alloc-testlib.obj: testlib.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xztest_alloc_CFLAGS) $(CFLAGS) -c -o xztest_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
ztest-ztest.o: ztest.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-ztest.o `test -f 'ztest.c' || echo '$(srcdir)/'`ztest.c
@ -1933,6 +2031,13 @@ btest_gnudebuglink.log: btest_gnudebuglink
--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)
mtest_minidebug.log: mtest_minidebug
@p='mtest_minidebug'; \
b='mtest_minidebug'; \
$(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)
test_elf_32.log: test_elf_32$(EXEEXT)
@p='test_elf_32$(EXEEXT)'; \
b='test_elf_32'; \
@ -2115,6 +2220,27 @@ dwarf5_alloc.log: dwarf5_alloc$(EXEEXT)
--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)
mtest.log: mtest$(EXEEXT)
@p='mtest$(EXEEXT)'; \
b='mtest'; \
$(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)
xztest.log: xztest$(EXEEXT)
@p='xztest$(EXEEXT)'; \
b='xztest'; \
$(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)
xztest_alloc.log: xztest_alloc$(EXEEXT)
@p='xztest_alloc$(EXEEXT)'; \
b='xztest_alloc'; \
$(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)
.test.log:
@p='$<'; \
$(am__set_b); \
@ -2323,11 +2449,23 @@ uninstall-am:
@NATIVE_TRUE@ $<
@NATIVE_TRUE@ $(OBJCOPY) --strip-debug $< $@
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: %
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --only-keep-debug $< $<.dbg
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --strip-all --remove-section ..comment $< $<.strip
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ rm -f $<.mdbg.xz
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(XZ) $<.mdbg
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --add-section .gnu_debugdata=$<.mdbg.xz $<.strip
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@ mv $<.strip $@
clean-local:
-rm -rf usr
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
btest.lo: $(INCDIR)/filenames.h backtrace.h backtrace-supported.h
dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \
$(INCDIR)/filenames.h backtrace.h internal.h
elf.lo: config.h backtrace.h internal.h
@ -2335,6 +2473,7 @@ fileline.lo: config.h backtrace.h internal.h
macho.lo: config.h backtrace.h internal.h
mmap.lo: config.h backtrace.h internal.h
mmapio.lo: config.h backtrace.h internal.h
mtest.lo: backtrace.h backtrace-supported.h
nounwind.lo: config.h internal.h
pecoff.lo: config.h backtrace.h internal.h
posix.lo: config.h backtrace.h internal.h
@ -2346,6 +2485,8 @@ stest.lo: config.h backtrace.h internal.h
state.lo: config.h backtrace.h backtrace-supported.h internal.h
unknown.lo: config.h backtrace.h internal.h
xcoff.lo: config.h backtrace.h internal.h
xztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
ztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
# GNU Make needs to see an explicit $(MAKE) variable in the command it
# runs to enable its job server during parallel builds. Hence the

View File

@ -46,6 +46,9 @@
<sys/sysctl.h>. */
#undef HAVE_KERN_PROC_ARGS
/* Define if -llzma is available. */
#undef HAVE_LIBLZMA
/* Define to 1 if you have the <link.h> header file. */
#undef HAVE_LINK_H

224
libbacktrace/configure vendored
View File

@ -635,6 +635,16 @@ LTLIBOBJS
LIBOBJS
NATIVE_FALSE
NATIVE_TRUE
HAVE_LIBLZMA_FALSE
HAVE_LIBLZMA_TRUE
HAVE_MINIDEBUG_FALSE
HAVE_MINIDEBUG_TRUE
HAVE_COMM_FALSE
HAVE_COMM_TRUE
COMM
HAVE_XZ_FALSE
HAVE_XZ_TRUE
XZ
HAVE_DSYMUTIL_FALSE
HAVE_DSYMUTIL_TRUE
HAVE_OBJCOPY_DEBUGLINK_FALSE
@ -804,7 +814,8 @@ LIBS
CPPFLAGS
CPP
OBJCOPY
DSYMUTIL'
DSYMUTIL
NM'
# Initialize some variables set by options.
@ -1460,6 +1471,7 @@ Some influential environment variables:
CPP C preprocessor
OBJCOPY location of objcopy
DSYMUTIL location of dsymutil
NM location of nm
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@ -11505,7 +11517,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11508 "configure"
#line 11520 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11611,7 +11623,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11614 "configure"
#line 11626 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -13857,6 +13869,196 @@ else
fi
# Extract the first word of "nm", so it can be a program name with args.
set dummy nm; 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_NM+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$NM"; then
ac_cv_prog_NM="$NM" # 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_NM="nm"
$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
NM=$ac_cv_prog_NM
if test -n "$NM"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5
$as_echo "$NM" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Extract the first word of "xz", so it can be a program name with args.
set dummy xz; 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_XZ+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$XZ"; then
ac_cv_prog_XZ="$XZ" # 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_XZ="xz"
$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
XZ=$ac_cv_prog_XZ
if test -n "$XZ"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $XZ" >&5
$as_echo "$XZ" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$XZ" != ""; then
HAVE_XZ_TRUE=
HAVE_XZ_FALSE='#'
else
HAVE_XZ_TRUE='#'
HAVE_XZ_FALSE=
fi
# Extract the first word of "comm", so it can be a program name with args.
set dummy comm; 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_COMM+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$COMM"; then
ac_cv_prog_COMM="$COMM" # 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_COMM="comm"
$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
COMM=$ac_cv_prog_COMM
if test -n "$COMM"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5
$as_echo "$COMM" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$COMM" != ""; then
HAVE_COMM_TRUE=
HAVE_COMM_FALSE='#'
else
HAVE_COMM_TRUE='#'
HAVE_COMM_FALSE=
fi
if test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != ""; then
HAVE_MINIDEBUG_TRUE=
HAVE_MINIDEBUG_FALSE='#'
else
HAVE_MINIDEBUG_TRUE='#'
HAVE_MINIDEBUG_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_auto_decoder in -llzma" >&5
$as_echo_n "checking for lzma_auto_decoder in -llzma... " >&6; }
if ${ac_cv_lib_lzma_lzma_auto_decoder+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llzma $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char lzma_auto_decoder ();
int
main ()
{
return lzma_auto_decoder ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lzma_lzma_auto_decoder=yes
else
ac_cv_lib_lzma_lzma_auto_decoder=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_auto_decoder" >&5
$as_echo "$ac_cv_lib_lzma_lzma_auto_decoder" >&6; }
if test "x$ac_cv_lib_lzma_lzma_auto_decoder" = xyes; then :
$as_echo "#define HAVE_LIBLZMA 1" >>confdefs.h
fi
if test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes; then
HAVE_LIBLZMA_TRUE=
HAVE_LIBLZMA_FALSE='#'
else
HAVE_LIBLZMA_TRUE='#'
HAVE_LIBLZMA_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tests can run" >&5
$as_echo_n "checking whether tests can run... " >&6; }
if ${libbacktrace_cv_sys_native+:} false; then :
@ -14073,6 +14275,22 @@ if test -z "${HAVE_DSYMUTIL_TRUE}" && test -z "${HAVE_DSYMUTIL_FALSE}"; then
as_fn_error $? "conditional \"HAVE_DSYMUTIL\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_XZ_TRUE}" && test -z "${HAVE_XZ_FALSE}"; then
as_fn_error $? "conditional \"HAVE_XZ\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_COMM_TRUE}" && test -z "${HAVE_COMM_FALSE}"; then
as_fn_error $? "conditional \"HAVE_COMM\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_MINIDEBUG_TRUE}" && test -z "${HAVE_MINIDEBUG_FALSE}"; then
as_fn_error $? "conditional \"HAVE_MINIDEBUG\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_LIBLZMA_TRUE}" && test -z "${HAVE_LIBLZMA_FALSE}"; then
as_fn_error $? "conditional \"HAVE_LIBLZMA\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NATIVE_TRUE}" && test -z "${NATIVE_FALSE}"; then
as_fn_error $? "conditional \"NATIVE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -512,6 +512,21 @@ AC_ARG_VAR(DSYMUTIL, [location of dsymutil])
AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil)
AM_CONDITIONAL(HAVE_DSYMUTIL, test -n "${DSYMUTIL}")
AC_ARG_VAR(NM, [location of nm])
AC_CHECK_PROG(NM, nm, nm)
AC_CHECK_PROG(XZ, xz, xz)
AM_CONDITIONAL(HAVE_XZ, test "$XZ" != "")
AC_CHECK_PROG(COMM, comm, comm)
AM_CONDITIONAL(HAVE_COMM, test "$COMM" != "")
AM_CONDITIONAL(HAVE_MINIDEBUG,
test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != "")
AC_CHECK_LIB([lzma], [lzma_auto_decoder],
[AC_DEFINE(HAVE_LIBLZMA, 1, [Define if -llzma is available.])])
AM_CONDITIONAL(HAVE_LIBLZMA, test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes)
AC_CACHE_CHECK([whether tests can run],
[libbacktrace_cv_sys_native],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],

File diff suppressed because it is too large Load Diff

View File

@ -335,4 +335,13 @@ extern int backtrace_uncompress_zdebug (struct backtrace_state *,
unsigned char **uncompressed,
size_t *uncompressed_size);
/* A test-only hook for elf_uncompress_lzma. */
extern int backtrace_uncompress_lzma (struct backtrace_state *,
const unsigned char *compressed,
size_t compressed_size,
backtrace_error_callback, void *data,
unsigned char **uncompressed,
size_t *uncompressed_size);
#endif

401
libbacktrace/mtest.c Normal file
View File

@ -0,0 +1,401 @@
/* mtest.c -- Minidebug test for libbacktrace library
Copyright (C) 2020 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
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. */
/* This program tests using libbacktrace with a program that uses the
minidebuginfo format in a .gnu_debugdata section. See
https://sourceware.org/gdb/current/onlinedocs/gdb/MiniDebugInfo.html
for a bit more information about minidebuginfo. What is relevant
for libbacktrace is that we have just a symbol table, with no debug
info, so we should be able to do a function backtrace, but we can't
do a file/line backtrace. */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "backtrace.h"
#include "backtrace-supported.h"
#include "testlib.h"
static int test1 (void) __attribute__ ((noinline, noclone, unused));
static int f2 (int) __attribute__ ((noinline, noclone));
static int f3 (int, int) __attribute__ ((noinline, noclone));
/* Collected PC values. */
static uintptr_t addrs[20];
/* The backtrace callback function. This is like callback_one in
testlib.c, but it saves the PC also. */
static int
callback_mtest (void *vdata, uintptr_t pc, const char *filename, int lineno,
const char *function)
{
struct bdata *data = (struct bdata *) vdata;
if (data->index >= sizeof addrs / sizeof addrs[0])
{
fprintf (stderr, "callback_mtest: callback called too many times\n");
data->failed = 1;
return 1;
}
addrs[data->index] = pc;
return callback_one (vdata, pc, filename, lineno, function);
}
/* Test the backtrace function with non-inlined functions. (We don't
test with inlined functions because they won't work with minidebug
anyhow.) */
static int
test1 (void)
{
/* Returning a value here and elsewhere avoids a tailcall which
would mess up the backtrace. */
return f2 (__LINE__) + 1;
}
static int
f2 (int f1line)
{
return f3 (f1line, __LINE__) + 2;
}
static int
f3 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
{
struct info all[20];
struct bdata data;
int i;
size_t j;
data.all = &all[0];
data.index = 0;
data.max = 20;
data.failed = 0;
i = backtrace_full (state, 0, callback_mtest, error_callback_one, &data);
if (i != 0)
{
fprintf (stderr, "test1: unexpected return value %d\n", i);
data.failed = 1;
}
if (data.index < 3)
{
fprintf (stderr,
"test1: not enough frames; got %zu, expected at least 3\n",
data.index);
data.failed = 1;
}
/* When using minidebug we don't expect the function name here. */
for (j = 0; j < 3 && j < data.index; j++)
{
if (all[j].function == NULL)
{
struct symdata symdata;
symdata.name = NULL;
symdata.val = 0;
symdata.size = 0;
symdata.failed = 0;
i = backtrace_syminfo (state, addrs[j], callback_three,
error_callback_three, &symdata);
if (i == 0)
{
fprintf (stderr,
("test1: [%zu], unexpected return value from "
"backtrace_syminfo %d\n"),
j, i);
data.failed = 1;
}
else if (symdata.name == NULL)
{
fprintf (stderr, "test1: [%zu]: syminfo did not find name\n", j);
data.failed = 1;
}
else
all[j].function = strdup (symdata.name);
}
}
if (all[0].function == NULL)
{
fprintf (stderr, "test1: [0]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[0].function, "f3") != 0)
{
fprintf (stderr, "test1: [0]: got %s expected %s\n",
all[0].function, "f3");
data.failed = 1;
}
if (all[1].function == NULL)
{
fprintf (stderr, "test1: [1]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[1].function, "f2") != 0)
{
fprintf (stderr, "test1: [1]: got %s expected %s\n",
all[0].function, "f2");
data.failed = 1;
}
if (all[2].function == NULL)
{
fprintf (stderr, "test1: [2]: missing function name\n");
data.failed = 1;
}
else if (strcmp (all[2].function, "test1") != 0)
{
fprintf (stderr, "test1: [2]: got %s expected %s\n",
all[0].function, "test1");
data.failed = 1;
}
printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS");
if (data.failed)
++failures;
return failures;
}
/* Test the backtrace_simple function with non-inlined functions. */
static int test3 (void) __attribute__ ((noinline, noclone, unused));
static int f22 (int) __attribute__ ((noinline, noclone));
static int f23 (int, int) __attribute__ ((noinline, noclone));
static int
test3 (void)
{
return f22 (__LINE__) + 1;
}
static int
f22 (int f1line)
{
return f23 (f1line, __LINE__) + 2;
}
static int
f23 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
{
uintptr_t addrs[20];
struct sdata data;
int i;
data.addrs = &addrs[0];
data.index = 0;
data.max = 20;
data.failed = 0;
i = backtrace_simple (state, 0, callback_two, error_callback_two, &data);
if (i != 0)
{
fprintf (stderr, "test3: unexpected return value %d\n", i);
data.failed = 1;
}
if (!data.failed)
{
int j;
for (j = 0; j < 3; ++j)
{
struct symdata symdata;
symdata.name = NULL;
symdata.val = 0;
symdata.size = 0;
symdata.failed = 0;
i = backtrace_syminfo (state, addrs[j], callback_three,
error_callback_three, &symdata);
if (i == 0)
{
fprintf (stderr,
("test3: [%d]: unexpected return value "
"from backtrace_syminfo %d\n"),
j, i);
symdata.failed = 1;
}
if (!symdata.failed)
{
const char *expected;
switch (j)
{
case 0:
expected = "f23";
break;
case 1:
expected = "f22";
break;
case 2:
expected = "test3";
break;
default:
assert (0);
}
if (symdata.name == NULL)
{
fprintf (stderr, "test3: [%d]: NULL syminfo name\n", j);
symdata.failed = 1;
}
/* Use strncmp, not strcmp, because GCC might create a
clone. */
else if (strncmp (symdata.name, expected, strlen (expected))
!= 0)
{
fprintf (stderr,
("test3: [%d]: unexpected syminfo name "
"got %s expected %s\n"),
j, symdata.name, expected);
symdata.failed = 1;
}
}
if (symdata.failed)
data.failed = 1;
}
}
printf ("%s: backtrace_simple noinline\n", data.failed ? "FAIL" : "PASS");
if (data.failed)
++failures;
return failures;
}
int test5 (void) __attribute__ ((unused));
int global = 1;
int
test5 (void)
{
struct symdata symdata;
int i;
uintptr_t addr = (uintptr_t) &global;
if (sizeof (global) > 1)
addr += 1;
symdata.name = NULL;
symdata.val = 0;
symdata.size = 0;
symdata.failed = 0;
i = backtrace_syminfo (state, addr, callback_three,
error_callback_three, &symdata);
if (i == 0)
{
fprintf (stderr,
"test5: unexpected return value from backtrace_syminfo %d\n",
i);
symdata.failed = 1;
}
if (!symdata.failed)
{
if (symdata.name == NULL)
{
fprintf (stderr, "test5: NULL syminfo name\n");
symdata.failed = 1;
}
else if (!(strncmp (symdata.name, "global", 6) == 0
&& (symdata.name[6] == '\0'|| symdata.name[6] == '.')))
{
fprintf (stderr,
"test5: unexpected syminfo name got %s expected %s\n",
symdata.name, "global");
symdata.failed = 1;
}
else if (symdata.val != (uintptr_t) &global)
{
fprintf (stderr,
"test5: unexpected syminfo value got %lx expected %lx\n",
(unsigned long) symdata.val,
(unsigned long) (uintptr_t) &global);
symdata.failed = 1;
}
else if (symdata.size != sizeof (global))
{
fprintf (stderr,
"test5: unexpected syminfo size got %lx expected %lx\n",
(unsigned long) symdata.size,
(unsigned long) sizeof (global));
symdata.failed = 1;
}
}
printf ("%s: backtrace_syminfo variable\n",
symdata.failed ? "FAIL" : "PASS");
if (symdata.failed)
++failures;
return failures;
}
int
main (int argc ATTRIBUTE_UNUSED, char **argv)
{
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_create, NULL);
#if BACKTRACE_SUPPORTED
test1 ();
test3 ();
#if BACKTRACE_SUPPORTS_DATA
test5 ();
#endif
#endif
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
}

508
libbacktrace/xztest.c Normal file
View File

@ -0,0 +1,508 @@
/* xztest.c -- Test for libbacktrace LZMA decoder.
Copyright (C) 2020 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
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. */
#include "config.h"
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_LIBLZMA
#include <lzma.h>
#endif
#include "backtrace.h"
#include "backtrace-supported.h"
#include "internal.h"
#include "testlib.h"
#ifndef HAVE_CLOCK_GETTIME
typedef int xclockid_t;
static int
xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED,
struct timespec *ts ATTRIBUTE_UNUSED)
{
errno = EINVAL;
return -1;
}
#define clockid_t xclockid_t
#define clock_gettime xclock_gettime
#undef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif /* !defined(HAVE_CLOCK_GETTIME) */
#ifdef CLOCK_PROCESS_CPUTIME_ID
#define LIBLZMA_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
#else
#define LIBLZMA_CLOCK_GETTIME_ARG CLOCK_REALTIME
#endif
/* Some tests for the local lzma inflation code. */
struct lzma_test
{
const char *name;
const char *uncompressed;
size_t uncompressed_len;
const char *compressed;
size_t compressed_len;
};
/* Error callback. */
static void
error_callback_compress (void *vdata ATTRIBUTE_UNUSED, const char *msg,
int errnum)
{
fprintf (stderr, "%s", msg);
if (errnum > 0)
fprintf (stderr, ": %s", strerror (errnum));
fprintf (stderr, "\n");
exit (EXIT_FAILURE);
}
static const struct lzma_test tests[] =
{
{
"empty",
"",
0,
("\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x00\x00\x00\x00"
"\x1c\xdf\x44\x21\x1f\xb6\xf3\x7d\x01\x00\x00\x00\x00\x04\x59\x5a"),
32,
},
{
"hello",
"hello, world\n",
0,
("\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00\x21\x01"
"\x16\x00\x00\x00\x74\x2f\xe5\xa3\x01\x00\x0c\x68\x65\x6c\x6c\x6f"
"\x2c\x20\x77\x6f\x72\x6c\x64\x0a\x00\x00\x00\x00\x7b\x46\x5a\x81"
"\xc9\x12\xb8\xea\x00\x01\x25\x0d\x71\x19\xc4\xb6\x1f\xb6\xf3\x7d"
"\x01\x00\x00\x00\x00\x04\x59\x5a"),
72,
},
{
"goodbye",
"goodbye, world",
0,
("\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00\x21\x01"
"\x16\x00\x00\x00\x74\x2f\xe5\xa3\x01\x00\x0d\x67\x6f\x6f\x64\x62"
"\x79\x65\x2c\x20\x77\x6f\x72\x6c\x64\x00\x00\x00\xf6\xf8\xa3\x33"
"\x8c\x4e\xc9\x68\x00\x01\x26\x0e\x08\x1b\xe0\x04\x1f\xb6\xf3\x7d"
"\x01\x00\x00\x00\x00\x04\x59\x5a"),
72,
},
};
/* Test the hand coded samples. */
static void
test_samples (struct backtrace_state *state)
{
size_t i;
for (i = 0; i < sizeof tests / sizeof tests[0]; ++i)
{
unsigned char *uncompressed;
size_t uncompressed_len;
uncompressed = NULL;
uncompressed_len = 0;
if (!backtrace_uncompress_lzma (state,
((const unsigned char *)
tests[i].compressed),
tests[i].compressed_len,
error_callback_compress, NULL,
&uncompressed, &uncompressed_len))
{
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
++failures;
}
else
{
size_t v;
v = tests[i].uncompressed_len;
if (v == 0)
v = strlen (tests[i].uncompressed);
if (uncompressed_len != v)
{
fprintf (stderr,
"test %s: got uncompressed length %zu, want %zu\n",
tests[i].name, uncompressed_len, v);
++failures;
}
else if (memcmp (tests[i].uncompressed, uncompressed, v) != 0)
{
size_t j;
fprintf (stderr, "test %s: uncompressed data mismatch\n",
tests[i].name);
for (j = 0; j < v; ++j)
if (tests[i].uncompressed[j] != uncompressed[j])
fprintf (stderr, " %zu: got %#x want %#x\n", j,
uncompressed[j], tests[i].uncompressed[j]);
++failures;
}
else
printf ("PASS: lzma %s\n", tests[i].name);
backtrace_free (state, uncompressed, uncompressed_len,
error_callback_compress, NULL);
}
}
}
#if HAVE_LIBLZMA
/* Given a set of TRIALS timings, discard the lowest and highest
values and return the mean average of the rest. */
static size_t
average_time (const size_t *times, size_t trials)
{
size_t imax;
size_t max;
size_t imin;
size_t min;
size_t i;
size_t sum;
imin = 0;
imax = 0;
min = times[0];
max = times[0];
for (i = 1; i < trials; ++i)
{
if (times[i] < min)
{
imin = i;
min = times[i];
}
if (times[i] > max)
{
imax = i;
max = times[i];
}
}
sum = 0;
for (i = 0; i < trials; ++i)
{
if (i != imax && i != imin)
sum += times[i];
}
return sum / (trials - 2);
}
#endif
/* Test a larger text, if available. */
static void
test_large (struct backtrace_state *state ATTRIBUTE_UNUSED)
{
#if HAVE_LIBLZMA
unsigned char *orig_buf;
size_t orig_bufsize;
size_t i;
lzma_stream initial_stream = LZMA_STREAM_INIT;
lzma_stream stream;
unsigned char *compressed_buf;
size_t compressed_bufsize;
unsigned char *uncompressed_buf;
size_t uncompressed_bufsize;
unsigned char *spare_buf;
int r;
clockid_t cid;
struct timespec ts1;
struct timespec ts2;
size_t ctime;
size_t ztime;
const size_t trials = 16;
size_t ctimes[16];
size_t ztimes[16];
static const char * const names[] = {
"Isaac.Newton-Opticks.txt",
"../libgo/go/testdata/Isaac.Newton-Opticks.txt",
};
orig_buf = NULL;
orig_bufsize = 0;
uncompressed_buf = NULL;
compressed_buf = NULL;
for (i = 0; i < sizeof names / sizeof names[0]; ++i)
{
size_t len;
char *namebuf;
FILE *e;
struct stat st;
char *rbuf;
size_t got;
len = strlen (SRCDIR) + strlen (names[i]) + 2;
namebuf = malloc (len);
if (namebuf == NULL)
{
perror ("malloc");
goto fail;
}
snprintf (namebuf, len, "%s/%s", SRCDIR, names[i]);
e = fopen (namebuf, "r");
free (namebuf);
if (e == NULL)
continue;
if (fstat (fileno (e), &st) < 0)
{
perror ("fstat");
fclose (e);
continue;
}
rbuf = malloc (st.st_size);
if (rbuf == NULL)
{
perror ("malloc");
goto fail;
}
got = fread (rbuf, 1, st.st_size, e);
fclose (e);
if (got > 0)
{
orig_buf = (unsigned char *) rbuf;
orig_bufsize = got;
break;
}
free (rbuf);
}
if (orig_buf == NULL)
{
/* We couldn't find an input file. */
printf ("UNSUPPORTED: lzma large\n");
return;
}
stream = initial_stream;
r = lzma_easy_encoder (&stream, 6, LZMA_CHECK_CRC32);
if (r != LZMA_OK)
{
fprintf (stderr, "lzma_easy_encoder failed: %d\n", r);
goto fail;
}
compressed_bufsize = orig_bufsize + 100;
compressed_buf = malloc (compressed_bufsize);
if (compressed_buf == NULL)
{
perror ("malloc");
goto fail;
}
stream.next_in = orig_buf;
stream.avail_in = orig_bufsize;
stream.next_out = compressed_buf;
stream.avail_out = compressed_bufsize;
do
{
r = lzma_code (&stream, LZMA_FINISH);
if (r != LZMA_OK && r != LZMA_STREAM_END)
{
fprintf (stderr, "lzma_code failed: %d\n", r);
goto fail;
}
}
while (r != LZMA_STREAM_END);
compressed_bufsize = stream.total_out;
if (!backtrace_uncompress_lzma (state, (unsigned char *) compressed_buf,
compressed_bufsize,
error_callback_compress, NULL,
&uncompressed_buf, &uncompressed_bufsize))
{
fprintf (stderr, "lzma large: backtrace_uncompress_lzma failed\n");
goto fail;
}
if (uncompressed_bufsize != orig_bufsize)
{
fprintf (stderr,
"lzma large: got uncompressed length %zu, want %zu\n",
uncompressed_bufsize, orig_bufsize);
goto fail;
}
if (memcmp (uncompressed_buf, orig_buf, uncompressed_bufsize) != 0)
{
fprintf (stderr, "lzma large: uncompressed data mismatch\n");
goto fail;
}
printf ("PASS: lzma large\n");
spare_buf = malloc (orig_bufsize);
if (spare_buf == NULL)
{
perror ("malloc");
goto fail;
}
for (i = 0; i < trials; ++i)
{
cid = LIBLZMA_CLOCK_GETTIME_ARG;
if (clock_gettime (cid, &ts1) < 0)
{
if (errno == EINVAL)
return;
perror ("clock_gettime");
return;
}
if (!backtrace_uncompress_lzma (state,
(unsigned char *) compressed_buf,
compressed_bufsize,
error_callback_compress, NULL,
&uncompressed_buf,
&uncompressed_bufsize))
{
fprintf (stderr,
("lzma large: "
"benchmark backtrace_uncompress_lzma failed\n"));
return;
}
if (clock_gettime (cid, &ts2) < 0)
{
perror ("clock_gettime");
return;
}
ctime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
ctime += ts2.tv_nsec - ts1.tv_nsec;
ctimes[i] = ctime;
stream = initial_stream;
r = lzma_auto_decoder (&stream, UINT64_MAX, 0);
if (r != LZMA_OK)
{
fprintf (stderr, "lzma_stream_decoder failed: %d\n", r);
goto fail;
}
stream.next_in = compressed_buf;
stream.avail_in = compressed_bufsize;
stream.next_out = spare_buf;
stream.avail_out = orig_bufsize;
if (clock_gettime (cid, &ts1) < 0)
{
perror("clock_gettime");
return;
}
do
{
r = lzma_code (&stream, LZMA_FINISH);
if (r != LZMA_OK && r != LZMA_STREAM_END)
{
fprintf (stderr, "lzma_code failed: %d\n", r);
goto fail;
}
}
while (r != LZMA_STREAM_END);
if (clock_gettime (cid, &ts2) < 0)
{
perror ("clock_gettime");
return;
}
ztime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
ztime += ts2.tv_nsec - ts1.tv_nsec;
ztimes[i] = ztime;
}
/* Toss the highest and lowest times and average the rest. */
ctime = average_time (ctimes, trials);
ztime = average_time (ztimes, trials);
printf ("backtrace: %zu ns\n", ctime);
printf ("liblzma : %zu ns\n", ztime);
printf ("ratio : %g\n", (double) ztime / (double) ctime);
return;
fail:
printf ("FAIL: lzma large\n");
++failures;
if (orig_buf != NULL)
free (orig_buf);
if (compressed_buf != NULL)
free (compressed_buf);
if (uncompressed_buf != NULL)
free (uncompressed_buf);
#else /* !HAVE_LIBLZMA */
printf ("UNSUPPORTED: lzma large\n");
#endif /* !HAVE_LIBLZMA */
}
int
main (int argc ATTRIBUTE_UNUSED, char **argv)
{
struct backtrace_state *state;
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_create, NULL);
test_samples (state);
test_large (state);
exit (failures != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}