libbacktrace: support zstd decompression
Support decompressing --compress-debug-sections=zstd. * configure.ac: Check for zstd library and --compress-debug-sections=zstd linker option. * Makefile.am (zstdtest_*): New targets. (zstdtest_alloc_*, ctestzstd_*): New targets. (BUILDTESTS): Add zstdtest, zstdtest_alloc, ctestzstd as appropriate. * elf.c (ELFCOMPRESS_ZSTD): Define. (elf_fetch_bits): Rename from elf_zlib_fetch. Update uses. (elf_fetch_bits_backward): New static function. (ZLIB_HUFFMAN_*): Rename from HUFFMAN_*. Update uses. (ZLIB_TABLE_*): Rename from ZDEBUG_TABLE_*. Update uses. (ZSTD_TABLE_*): Define. (struct elf_zstd_fse_entry): Define. (elf_zstd_read_fse): New static function. (elf_zstd_build_fse): Likewise. (lit): Define if BACKTRACE_GENERATE_ZSTD_FSE_TABLES. (match, offset, next, print_table, main): Likewise. (elf_zstd_lit_table): New static const array. (elf_zstd_match_table, elf_zstd_offset_table): Likewise. (elf_zstd_read_huff): New static function. (struct elf_zstd_seq_decode): Define. (elf_zstd_unpack_seq_decode): New static function. (ZSTD_LIT_*): Define. (struct elf_zstd_literals): Define. (elf_zstd_literal_output): New static function. (ZSTD_LITERAL_LENGTH_BASELINE_OFFSET): Define. (elf_zstd_literal_length_baseline): New static const array. (elf_zstd_literal_length_bits): Likewise. (ZSTD_MATCH_LENGTH_BASELINE_OFFSET): Define. (elf_zstd_match_length_baseline): New static const array. (elf_zstd_match_length_bits): Likewise. (elf_zstd_decompress): New static function. (ZDEBUG_TABLE_SIZE): New definition. (elf_uncompress_chdr): Support ELF_COMPRESS_ZSTD. (backtrace_uncompress_zstd): New function. (elf_add): Use ZLIB_TABLE_SIZE for zlib-gnu sections. * internal.h (backtrace_uncompress_zstd): Declare. * zstdtest.c: New file. * configure, config.h.in, Makefile.in: Regenerate.
This commit is contained in:
parent
4bc2d9f6cb
commit
9df1ba9a35
8 changed files with 3165 additions and 110 deletions
|
@ -368,6 +368,25 @@ ztest_alloc_CFLAGS = $(ztest_CFLAGS)
|
|||
|
||||
BUILDTESTS += ztest_alloc
|
||||
|
||||
zstdtest_SOURCES = zstdtest.c testlib.c
|
||||
zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
|
||||
zstdtest_LDADD = libbacktrace.la
|
||||
zstdtest_alloc_LDADD = libbacktrace_alloc.la
|
||||
|
||||
if HAVE_ZSTD
|
||||
zstdtest_LDADD += -lzstd
|
||||
zstdtest_alloc_LDADD += -lzstd
|
||||
endif
|
||||
zstdtest_LDADD += $(CLOCK_GETTIME_LINK)
|
||||
zstdtest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
|
||||
|
||||
BUILDTESTS += zstdtest
|
||||
|
||||
zstdtest_alloc_SOURCES = $(zstdtest_SOURCES)
|
||||
zstdtest_alloc_CFLAGS = $(zstdtest_CFLAGS)
|
||||
|
||||
BUILDTESTS += zstdtest_alloc
|
||||
|
||||
endif HAVE_ELF
|
||||
|
||||
edtest_SOURCES = edtest.c edtest2_build.c testlib.c
|
||||
|
@ -450,6 +469,17 @@ ctesta_LDADD = libbacktrace.la
|
|||
|
||||
BUILDTESTS += ctestg ctesta
|
||||
|
||||
if HAVE_COMPRESSED_DEBUG_ZSTD
|
||||
|
||||
ctestzstd_SOURCES = btest.c testlib.c
|
||||
ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||
ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd
|
||||
ctestzstd_LDADD = libbacktrace.la
|
||||
|
||||
BUILDTESTS += ctestzstd
|
||||
|
||||
endif
|
||||
|
||||
ctestg_alloc_SOURCES = $(ctestg_SOURCES)
|
||||
ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
|
||||
ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
|
||||
|
|
|
@ -121,8 +121,8 @@ build_triplet = @build@
|
|||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
|
||||
$(am__EXEEXT_14)
|
||||
TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_14)
|
||||
$(am__EXEEXT_16)
|
||||
TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_16)
|
||||
@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 \
|
||||
|
@ -143,26 +143,29 @@ TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_14)
|
|||
@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_13 = btest_dwz_gnudebuglink
|
||||
@HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_14 = -lz
|
||||
@HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_15 = -lz
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_16 = ztest ztest_alloc
|
||||
@NATIVE_TRUE@am__append_17 = edtest edtest_alloc
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_18 = ttest ttest_alloc
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_19 = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_16 = ztest ztest_alloc zstdtest \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest_alloc
|
||||
@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_17 = -lzstd
|
||||
@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_18 = -lzstd
|
||||
@NATIVE_TRUE@am__append_19 = edtest edtest_alloc
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_20 = ttest ttest_alloc
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_21 = \
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ ttest.dSYM \
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ ttest_alloc.dSYM
|
||||
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_20 = btest_gnudebuglink
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_21 = ctestg ctesta \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctestg_alloc \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta_alloc
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_22 = dwarf5 dwarf5_alloc
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_23 = \
|
||||
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_22 = btest_gnudebuglink
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_23 = ctestg ctesta
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__append_24 = ctestzstd
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_25 = ctestg_alloc ctesta_alloc
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_26 = dwarf5 dwarf5_alloc
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_27 = \
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ dwarf5.dSYM \
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ dwarf5_alloc.dSYM
|
||||
@NATIVE_TRUE@am__append_24 = mtest
|
||||
@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_25 = mtest.dSYM
|
||||
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@am__append_26 = mtest_minidebug
|
||||
@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_27 = -llzma
|
||||
@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_28 = -llzma
|
||||
@HAVE_ELF_TRUE@am__append_29 = xztest xztest_alloc
|
||||
@NATIVE_TRUE@am__append_28 = mtest
|
||||
@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_29 = mtest.dSYM
|
||||
@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@am__append_30 = mtest_minidebug
|
||||
@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_31 = -llzma
|
||||
@HAVE_ELF_TRUE@@HAVE_LIBLZMA_TRUE@am__append_32 = -llzma
|
||||
@HAVE_ELF_TRUE@am__append_33 = xztest xztest_alloc
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \
|
||||
|
@ -230,23 +233,26 @@ libbacktrace_noformat_la_OBJECTS = \
|
|||
@NATIVE_TRUE@am__EXEEXT_6 = btest_alloc$(EXEEXT) stest$(EXEEXT) \
|
||||
@NATIVE_TRUE@ stest_alloc$(EXEEXT)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__EXEEXT_7 = ztest$(EXEEXT) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ ztest_alloc$(EXEEXT)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ ztest_alloc$(EXEEXT) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest$(EXEEXT) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest_alloc$(EXEEXT)
|
||||
@NATIVE_TRUE@am__EXEEXT_8 = edtest$(EXEEXT) edtest_alloc$(EXEEXT)
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = ttest$(EXEEXT) \
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ ttest_alloc$(EXEEXT)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_10 = \
|
||||
@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$(EXEEXT)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__EXEEXT_11 = ctestzstd$(EXEEXT)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_12 = ctestg_alloc$(EXEEXT) \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta_alloc$(EXEEXT)
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__EXEEXT_11 = dwarf5$(EXEEXT) \
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__EXEEXT_13 = dwarf5$(EXEEXT) \
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@ dwarf5_alloc$(EXEEXT)
|
||||
@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) \
|
||||
@NATIVE_TRUE@am__EXEEXT_14 = mtest$(EXEEXT)
|
||||
@HAVE_ELF_TRUE@am__EXEEXT_15 = xztest$(EXEEXT) xztest_alloc$(EXEEXT)
|
||||
am__EXEEXT_16 = $(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_12) \
|
||||
$(am__EXEEXT_13)
|
||||
$(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15)
|
||||
@NATIVE_TRUE@am_allocfail_OBJECTS = allocfail-allocfail.$(OBJEXT) \
|
||||
@NATIVE_TRUE@ allocfail-testlib.$(OBJEXT)
|
||||
allocfail_OBJECTS = $(am_allocfail_OBJECTS)
|
||||
|
@ -328,6 +334,13 @@ ctestg_alloc_OBJECTS = $(am_ctestg_alloc_OBJECTS)
|
|||
ctestg_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ctestg_alloc_CFLAGS) \
|
||||
$(CFLAGS) $(ctestg_alloc_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am_ctestzstd_OBJECTS = ctestzstd-btest.$(OBJEXT) \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ ctestzstd-testlib.$(OBJEXT)
|
||||
ctestzstd_OBJECTS = $(am_ctestzstd_OBJECTS)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_DEPENDENCIES = libbacktrace.la
|
||||
ctestzstd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(ctestzstd_CFLAGS) \
|
||||
$(CFLAGS) $(ctestzstd_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@am_dwarf5_OBJECTS = \
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@ dwarf5-btest.$(OBJEXT) \
|
||||
@HAVE_DWARF5_TRUE@@NATIVE_TRUE@ dwarf5-testlib.$(OBJEXT)
|
||||
|
@ -498,6 +511,30 @@ xztest_alloc_OBJECTS = $(am_xztest_alloc_OBJECTS)
|
|||
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_zstdtest_OBJECTS = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest-zstdtest.$(OBJEXT) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest-testlib.$(OBJEXT)
|
||||
zstdtest_OBJECTS = $(am_zstdtest_OBJECTS)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_DEPENDENCIES = libbacktrace.la \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1)
|
||||
zstdtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(zstdtest_CFLAGS) \
|
||||
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_13 = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest_alloc-zstdtest.$(OBJEXT) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest_alloc-testlib.$(OBJEXT)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@am_zstdtest_alloc_OBJECTS = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__objects_13)
|
||||
zstdtest_alloc_OBJECTS = $(am_zstdtest_alloc_OBJECTS)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_DEPENDENCIES = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ libbacktrace_alloc.la \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1)
|
||||
zstdtest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
|
||||
$(zstdtest_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)
|
||||
|
@ -507,11 +544,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_13 = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__objects_14 = \
|
||||
@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_13)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__objects_14)
|
||||
ztest_alloc_OBJECTS = $(am_ztest_alloc_OBJECTS)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_DEPENDENCIES = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ libbacktrace_alloc.la \
|
||||
|
@ -561,7 +598,7 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
|
|||
$(b2test_SOURCES) $(b3test_SOURCES) $(btest_SOURCES) \
|
||||
$(btest_alloc_SOURCES) $(btest_lto_SOURCES) $(ctesta_SOURCES) \
|
||||
$(ctesta_alloc_SOURCES) $(ctestg_SOURCES) \
|
||||
$(ctestg_alloc_SOURCES) $(dwarf5_SOURCES) \
|
||||
$(ctestg_alloc_SOURCES) $(ctestzstd_SOURCES) $(dwarf5_SOURCES) \
|
||||
$(dwarf5_alloc_SOURCES) $(edtest_SOURCES) \
|
||||
$(edtest_alloc_SOURCES) $(mtest_SOURCES) $(stest_SOURCES) \
|
||||
$(stest_alloc_SOURCES) $(test_elf_32_SOURCES) \
|
||||
|
@ -570,7 +607,8 @@ SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
|
|||
$(test_xcoff_32_SOURCES) $(test_xcoff_64_SOURCES) \
|
||||
$(ttest_SOURCES) $(ttest_alloc_SOURCES) $(unittest_SOURCES) \
|
||||
$(unittest_alloc_SOURCES) $(xztest_SOURCES) \
|
||||
$(xztest_alloc_SOURCES) $(ztest_SOURCES) \
|
||||
$(xztest_alloc_SOURCES) $(zstdtest_SOURCES) \
|
||||
$(zstdtest_alloc_SOURCES) $(ztest_SOURCES) \
|
||||
$(ztest_alloc_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
|
@ -989,18 +1027,18 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
|
|||
# Add a test to this variable if you want it to be built as a Makefile
|
||||
# target and run.
|
||||
MAKETESTS = $(am__append_7) $(am__append_9) $(am__append_12) \
|
||||
$(am__append_13) $(am__append_20) $(am__append_26)
|
||||
$(am__append_13) $(am__append_22) $(am__append_30)
|
||||
|
||||
# Add a test to this variable if you want it to be built as a program,
|
||||
# with SOURCES, etc., 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_24) \
|
||||
$(am__append_29)
|
||||
$(am__append_16) $(am__append_19) $(am__append_20) \
|
||||
$(am__append_23) $(am__append_24) $(am__append_25) \
|
||||
$(am__append_26) $(am__append_28) $(am__append_33)
|
||||
|
||||
# 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) \
|
||||
$(am__append_25)
|
||||
check_DATA = $(am__append_5) $(am__append_21) $(am__append_27) \
|
||||
$(am__append_29)
|
||||
|
||||
# Flags to use when compiling test programs.
|
||||
libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
|
||||
|
@ -1088,6 +1126,17 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
|
|||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_SOURCES = $(ztest_SOURCES)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_CFLAGS = $(ztest_CFLAGS)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_SOURCES = zstdtest.c testlib.c
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_LDADD = libbacktrace.la \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_17) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_LDADD = \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ libbacktrace_alloc.la \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_18) \
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_SOURCES = $(zstdtest_SOURCES)
|
||||
@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_CFLAGS = $(zstdtest_CFLAGS)
|
||||
@NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c
|
||||
@NATIVE_TRUE@edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||
@NATIVE_TRUE@edtest_LDADD = libbacktrace.la
|
||||
|
@ -1108,6 +1157,10 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
|
|||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDADD = libbacktrace.la
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_SOURCES = btest.c testlib.c
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@ctestzstd_LDADD = libbacktrace.la
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_SOURCES = $(ctestg_SOURCES)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
|
||||
|
@ -1127,12 +1180,12 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
|
|||
@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_27) \
|
||||
@HAVE_ELF_TRUE@xztest_LDADD = libbacktrace.la $(am__append_31) \
|
||||
@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_28) $(CLOCK_GETTIME_LINK)
|
||||
@HAVE_ELF_TRUE@ $(am__append_32) $(CLOCK_GETTIME_LINK)
|
||||
CLEANFILES = \
|
||||
$(MAKETESTS) $(BUILDTESTS) *.debug elf_for_test.c edtest2_build.c \
|
||||
gen_edtest2_build \
|
||||
|
@ -1302,6 +1355,10 @@ ctestg_alloc$(EXEEXT): $(ctestg_alloc_OBJECTS) $(ctestg_alloc_DEPENDENCIES) $(EX
|
|||
@rm -f ctestg_alloc$(EXEEXT)
|
||||
$(AM_V_CCLD)$(ctestg_alloc_LINK) $(ctestg_alloc_OBJECTS) $(ctestg_alloc_LDADD) $(LIBS)
|
||||
|
||||
ctestzstd$(EXEEXT): $(ctestzstd_OBJECTS) $(ctestzstd_DEPENDENCIES) $(EXTRA_ctestzstd_DEPENDENCIES)
|
||||
@rm -f ctestzstd$(EXEEXT)
|
||||
$(AM_V_CCLD)$(ctestzstd_LINK) $(ctestzstd_OBJECTS) $(ctestzstd_LDADD) $(LIBS)
|
||||
|
||||
dwarf5$(EXEEXT): $(dwarf5_OBJECTS) $(dwarf5_DEPENDENCIES) $(EXTRA_dwarf5_DEPENDENCIES)
|
||||
@rm -f dwarf5$(EXEEXT)
|
||||
$(AM_V_CCLD)$(dwarf5_LINK) $(dwarf5_OBJECTS) $(dwarf5_LDADD) $(LIBS)
|
||||
|
@ -1382,6 +1439,14 @@ xztest_alloc$(EXEEXT): $(xztest_alloc_OBJECTS) $(xztest_alloc_DEPENDENCIES) $(EX
|
|||
@rm -f xztest_alloc$(EXEEXT)
|
||||
$(AM_V_CCLD)$(xztest_alloc_LINK) $(xztest_alloc_OBJECTS) $(xztest_alloc_LDADD) $(LIBS)
|
||||
|
||||
zstdtest$(EXEEXT): $(zstdtest_OBJECTS) $(zstdtest_DEPENDENCIES) $(EXTRA_zstdtest_DEPENDENCIES)
|
||||
@rm -f zstdtest$(EXEEXT)
|
||||
$(AM_V_CCLD)$(zstdtest_LINK) $(zstdtest_OBJECTS) $(zstdtest_LDADD) $(LIBS)
|
||||
|
||||
zstdtest_alloc$(EXEEXT): $(zstdtest_alloc_OBJECTS) $(zstdtest_alloc_DEPENDENCIES) $(EXTRA_zstdtest_alloc_DEPENDENCIES)
|
||||
@rm -f zstdtest_alloc$(EXEEXT)
|
||||
$(AM_V_CCLD)$(zstdtest_alloc_LINK) $(zstdtest_alloc_OBJECTS) $(zstdtest_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)
|
||||
|
@ -1525,6 +1590,18 @@ ctestg_alloc-testlib.o: testlib.c
|
|||
ctestg_alloc-testlib.obj: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_alloc_CFLAGS) $(CFLAGS) -c -o ctestg_alloc-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
ctestzstd-btest.o: btest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
|
||||
|
||||
ctestzstd-btest.obj: btest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
|
||||
|
||||
ctestzstd-testlib.o: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
ctestzstd-testlib.obj: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestzstd_CFLAGS) $(CFLAGS) -c -o ctestzstd-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
dwarf5-btest.o: btest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dwarf5_CFLAGS) $(CFLAGS) -c -o dwarf5-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
|
||||
|
||||
|
@ -1765,6 +1842,30 @@ xztest_alloc-testlib.o: 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`
|
||||
|
||||
zstdtest-zstdtest.o: zstdtest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-zstdtest.o `test -f 'zstdtest.c' || echo '$(srcdir)/'`zstdtest.c
|
||||
|
||||
zstdtest-zstdtest.obj: zstdtest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-zstdtest.obj `if test -f 'zstdtest.c'; then $(CYGPATH_W) 'zstdtest.c'; else $(CYGPATH_W) '$(srcdir)/zstdtest.c'; fi`
|
||||
|
||||
zstdtest-testlib.o: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
zstdtest-testlib.obj: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_CFLAGS) $(CFLAGS) -c -o zstdtest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
zstdtest_alloc-zstdtest.o: zstdtest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-zstdtest.o `test -f 'zstdtest.c' || echo '$(srcdir)/'`zstdtest.c
|
||||
|
||||
zstdtest_alloc-zstdtest.obj: zstdtest.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-zstdtest.obj `if test -f 'zstdtest.c'; then $(CYGPATH_W) 'zstdtest.c'; else $(CYGPATH_W) '$(srcdir)/zstdtest.c'; fi`
|
||||
|
||||
zstdtest_alloc-testlib.o: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_alloc-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
zstdtest_alloc-testlib.obj: testlib.c
|
||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zstdtest_alloc_CFLAGS) $(CFLAGS) -c -o zstdtest_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
|
||||
|
||||
|
@ -2159,6 +2260,20 @@ ztest_alloc.log: ztest_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)
|
||||
zstdtest.log: zstdtest$(EXEEXT)
|
||||
@p='zstdtest$(EXEEXT)'; \
|
||||
b='zstdtest'; \
|
||||
$(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)
|
||||
zstdtest_alloc.log: zstdtest_alloc$(EXEEXT)
|
||||
@p='zstdtest_alloc$(EXEEXT)'; \
|
||||
b='zstdtest_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)
|
||||
edtest.log: edtest$(EXEEXT)
|
||||
@p='edtest$(EXEEXT)'; \
|
||||
b='edtest'; \
|
||||
|
@ -2201,6 +2316,13 @@ ctesta.log: ctesta$(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)
|
||||
ctestzstd.log: ctestzstd$(EXEEXT)
|
||||
@p='ctestzstd$(EXEEXT)'; \
|
||||
b='ctestzstd'; \
|
||||
$(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)
|
||||
ctestg_alloc.log: ctestg_alloc$(EXEEXT)
|
||||
@p='ctestg_alloc$(EXEEXT)'; \
|
||||
b='ctestg_alloc'; \
|
||||
|
|
|
@ -103,6 +103,9 @@
|
|||
/* Define if -lz is available. */
|
||||
#undef HAVE_ZLIB
|
||||
|
||||
/* Define if -lzstd is available. */
|
||||
#undef HAVE_ZSTD
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
|
105
libbacktrace/configure
vendored
105
libbacktrace/configure
vendored
|
@ -651,6 +651,10 @@ HAVE_OBJCOPY_DEBUGLINK_FALSE
|
|||
HAVE_OBJCOPY_DEBUGLINK_TRUE
|
||||
READELF
|
||||
OBJCOPY
|
||||
HAVE_COMPRESSED_DEBUG_ZSTD_FALSE
|
||||
HAVE_COMPRESSED_DEBUG_ZSTD_TRUE
|
||||
HAVE_ZSTD_FALSE
|
||||
HAVE_ZSTD_TRUE
|
||||
HAVE_COMPRESSED_DEBUG_FALSE
|
||||
HAVE_COMPRESSED_DEBUG_TRUE
|
||||
HAVE_ZLIB_FALSE
|
||||
|
@ -11535,7 +11539,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 11538 "configure"
|
||||
#line 11542 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -11641,7 +11645,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 11644 "configure"
|
||||
#line 11648 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -13776,6 +13780,95 @@ else
|
|||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZSTD_compress in -lzstd" >&5
|
||||
$as_echo_n "checking for ZSTD_compress in -lzstd... " >&6; }
|
||||
if ${ac_cv_lib_zstd_ZSTD_compress+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-lzstd $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 ZSTD_compress ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return ZSTD_compress ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_lib_zstd_ZSTD_compress=yes
|
||||
else
|
||||
ac_cv_lib_zstd_ZSTD_compress=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_zstd_ZSTD_compress" >&5
|
||||
$as_echo "$ac_cv_lib_zstd_ZSTD_compress" >&6; }
|
||||
if test "x$ac_cv_lib_zstd_ZSTD_compress" = xyes; then :
|
||||
|
||||
$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
if test "$ac_cv_lib_zstd_ZSTD_compress" = yes; then
|
||||
HAVE_ZSTD_TRUE=
|
||||
HAVE_ZSTD_FALSE='#'
|
||||
else
|
||||
HAVE_ZSTD_TRUE='#'
|
||||
HAVE_ZSTD_FALSE=
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --compress-debug-sections=zstd is supported" >&5
|
||||
$as_echo_n "checking whether --compress-debug-sections=zstd is supported... " >&6; }
|
||||
if ${libgo_cv_ld_compress_zstd+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
LDFLAGS_hold=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
libgo_cv_ld_compress_zstd=yes
|
||||
else
|
||||
libgo_cv_ld_compress_zstd=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LDFLAGS=$LDFLAGS_hold
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgo_cv_ld_compress_zstd" >&5
|
||||
$as_echo "$libgo_cv_ld_compress_zstd" >&6; }
|
||||
if test "$libgo_cv_ld_compress_zstd" = yes; then
|
||||
HAVE_COMPRESSED_DEBUG_ZSTD_TRUE=
|
||||
HAVE_COMPRESSED_DEBUG_ZSTD_FALSE='#'
|
||||
else
|
||||
HAVE_COMPRESSED_DEBUG_ZSTD_TRUE='#'
|
||||
HAVE_COMPRESSED_DEBUG_ZSTD_FALSE=
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Extract the first word of "objcopy", so it can be a program name with args.
|
||||
set dummy objcopy; ac_word=$2
|
||||
|
@ -14322,6 +14415,14 @@ if test -z "${HAVE_COMPRESSED_DEBUG_TRUE}" && test -z "${HAVE_COMPRESSED_DEBUG_F
|
|||
as_fn_error $? "conditional \"HAVE_COMPRESSED_DEBUG\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
if test -z "${HAVE_ZSTD_TRUE}" && test -z "${HAVE_ZSTD_FALSE}"; then
|
||||
as_fn_error $? "conditional \"HAVE_ZSTD\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
if test -z "${HAVE_COMPRESSED_DEBUG_ZSTD_TRUE}" && test -z "${HAVE_COMPRESSED_DEBUG_ZSTD_FALSE}"; then
|
||||
as_fn_error $? "conditional \"HAVE_COMPRESSED_DEBUG_ZSTD\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
if test -z "${HAVE_OBJCOPY_DEBUGLINK_TRUE}" && test -z "${HAVE_OBJCOPY_DEBUGLINK_FALSE}"; then
|
||||
as_fn_error $? "conditional \"HAVE_OBJCOPY_DEBUGLINK\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
|
|
|
@ -495,6 +495,21 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
|
|||
LDFLAGS=$LDFLAGS_hold])
|
||||
AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
|
||||
|
||||
AC_CHECK_LIB([zstd], [ZSTD_compress],
|
||||
[AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])])
|
||||
AM_CONDITIONAL(HAVE_ZSTD, test "$ac_cv_lib_zstd_ZSTD_compress" = yes)
|
||||
|
||||
dnl Test whether the linker supports --compress-debug-sections=zstd option.
|
||||
AC_CACHE_CHECK([whether --compress-debug-sections=zstd is supported],
|
||||
[libgo_cv_ld_compress_zstd],
|
||||
[LDFLAGS_hold=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
|
||||
[libgo_cv_ld_compress_zstd=yes],
|
||||
[libgo_cv_ld_compress_zstd=no])
|
||||
LDFLAGS=$LDFLAGS_hold])
|
||||
AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZSTD, test "$libgo_cv_ld_compress_zstd" = yes)
|
||||
|
||||
AC_ARG_VAR(OBJCOPY, [location of objcopy])
|
||||
AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
|
||||
AC_CHECK_PROG(READELF, readelf, readelf)
|
||||
|
|
2392
libbacktrace/elf.c
2392
libbacktrace/elf.c
File diff suppressed because it is too large
Load diff
|
@ -368,6 +368,15 @@ extern int backtrace_uncompress_zdebug (struct backtrace_state *,
|
|||
unsigned char **uncompressed,
|
||||
size_t *uncompressed_size);
|
||||
|
||||
/* A test-only hook for elf_zstd_decompress. */
|
||||
|
||||
extern int backtrace_uncompress_zstd (struct backtrace_state *,
|
||||
const unsigned char *compressed,
|
||||
size_t compressed_size,
|
||||
backtrace_error_callback, void *data,
|
||||
unsigned char *uncompressed,
|
||||
size_t uncompressed_size);
|
||||
|
||||
/* A test-only hook for elf_uncompress_lzma. */
|
||||
|
||||
extern int backtrace_uncompress_lzma (struct backtrace_state *,
|
||||
|
|
523
libbacktrace/zstdtest.c
Normal file
523
libbacktrace/zstdtest.c
Normal file
|
@ -0,0 +1,523 @@
|
|||
/* ztest.c -- Test for libbacktrace zstd code.
|
||||
Copyright (C) 2022 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_ZSTD
|
||||
#include <zstd.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 ZSTD_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
|
||||
#else
|
||||
#define ZSTD_CLOCK_GETTIME_ARG CLOCK_REALTIME
|
||||
#endif
|
||||
|
||||
/* Some tests for the local zstd inflation code. */
|
||||
|
||||
struct zstd_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 zstd_test tests[] =
|
||||
{
|
||||
{
|
||||
"empty",
|
||||
"",
|
||||
0,
|
||||
"\x28\xb5\x2f\xfd\x24\x00\x01\x00\x00\x99\xe9\xd8\x51",
|
||||
13,
|
||||
},
|
||||
{
|
||||
"hello",
|
||||
"hello, world\n",
|
||||
0,
|
||||
("\x28\xb5\x2f\xfd\x24\x0d\x69\x00\x00\x68\x65\x6c\x6c\x6f\x2c\x20"
|
||||
"\x77\x6f\x72\x6c\x64\x0a\x4c\x1f\xf9\xf1"),
|
||||
26,
|
||||
},
|
||||
{
|
||||
"goodbye",
|
||||
"goodbye, world",
|
||||
0,
|
||||
("\x28\xb5\x2f\xfd\x24\x0e\x71\x00\x00\x67\x6f\x6f\x64\x62\x79\x65"
|
||||
"\x2c\x20\x77\x6f\x72\x6c\x64\x61\x7b\x4b\x83"),
|
||||
27,
|
||||
},
|
||||
{
|
||||
"ranges",
|
||||
("\xcc\x11\x00\x00\x00\x00\x00\x00\xd5\x13\x00\x00\x00\x00\x00\x00"
|
||||
"\x1c\x14\x00\x00\x00\x00\x00\x00\x72\x14\x00\x00\x00\x00\x00\x00"
|
||||
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00"
|
||||
"\x0c\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00"
|
||||
"\x29\x14\x00\x00\x00\x00\x00\x00\x4e\x14\x00\x00\x00\x00\x00\x00"
|
||||
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00"
|
||||
"\x67\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00"
|
||||
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x5f\x0b\x00\x00\x00\x00\x00\x00\x6c\x0b\x00\x00\x00\x00\x00\x00"
|
||||
"\x7d\x0b\x00\x00\x00\x00\x00\x00\x7e\x0c\x00\x00\x00\x00\x00\x00"
|
||||
"\x38\x0f\x00\x00\x00\x00\x00\x00\x5c\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x83\x0c\x00\x00\x00\x00\x00\x00\xfa\x0c\x00\x00\x00\x00\x00\x00"
|
||||
"\xfd\x0d\x00\x00\x00\x00\x00\x00\xef\x0e\x00\x00\x00\x00\x00\x00"
|
||||
"\x14\x0f\x00\x00\x00\x00\x00\x00\x38\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\xfd\x0d\x00\x00\x00\x00\x00\x00\xd8\x0e\x00\x00\x00\x00\x00\x00"
|
||||
"\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\xfa\x0c\x00\x00\x00\x00\x00\x00\xea\x0d\x00\x00\x00\x00\x00\x00"
|
||||
"\xef\x0e\x00\x00\x00\x00\x00\x00\x14\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\x5c\x0f\x00\x00\x00\x00\x00\x00\x9f\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\xac\x0f\x00\x00\x00\x00\x00\x00\xdb\x0f\x00\x00\x00\x00\x00\x00"
|
||||
"\xff\x0f\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x60\x11\x00\x00\x00\x00\x00\x00\xd1\x16\x00\x00\x00\x00\x00\x00"
|
||||
"\x40\x0b\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x7a\x00\x00\x00\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x7a\x00\x00\x00\x00\x00\x00\x00\xa9\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"),
|
||||
672,
|
||||
("\x28\xb5\x2f\xfd\x64\xa0\x01\x2d\x05\x00\xc4\x04\xcc\x11\x00\xd5"
|
||||
"\x13\x00\x1c\x14\x00\x72\x9d\xd5\xfb\x12\x00\x09\x0c\x13\xcb\x13"
|
||||
"\x29\x4e\x67\x5f\x0b\x6c\x0b\x7d\x0b\x7e\x0c\x38\x0f\x5c\x0f\x83"
|
||||
"\x0c\xfa\x0c\xfd\x0d\xef\x0e\x14\x38\x9f\x0f\xac\x0f\xdb\x0f\xff"
|
||||
"\x0f\xd8\x9f\xac\xdb\xff\xea\x5c\x2c\x10\x60\xd1\x16\x40\x0b\x7a"
|
||||
"\x00\xb6\x00\x9f\x01\xa7\x01\xa9\x36\x20\xa0\x83\x14\x34\x63\x4a"
|
||||
"\x21\x70\x8c\x07\x46\x03\x4e\x10\x62\x3c\x06\x4e\xc8\x8c\xb0\x32"
|
||||
"\x2a\x59\xad\xb2\xf1\x02\x82\x7c\x33\xcb\x92\x6f\x32\x4f\x9b\xb0"
|
||||
"\xa2\x30\xf0\xc0\x06\x1e\x98\x99\x2c\x06\x1e\xd8\xc0\x03\x56\xd8"
|
||||
"\xc0\x03\x0f\x6c\xe0\x01\xf1\xf0\xee\x9a\xc6\xc8\x97\x99\xd1\x6c"
|
||||
"\xb4\x21\x45\x3b\x10\xe4\x7b\x99\x4d\x8a\x36\x64\x5c\x77\x08\x02"
|
||||
"\xcb\xe0\xce"),
|
||||
179,
|
||||
}
|
||||
};
|
||||
|
||||
/* 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 = (unsigned char *) malloc (tests[i].uncompressed_len);
|
||||
if (uncompressed == NULL)
|
||||
{
|
||||
perror ("malloc");
|
||||
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
|
||||
++failures;
|
||||
continue;
|
||||
}
|
||||
|
||||
uncompressed_len = tests[i].uncompressed_len;
|
||||
if (uncompressed_len == 0)
|
||||
uncompressed_len = strlen (tests[i].uncompressed);
|
||||
|
||||
if (!backtrace_uncompress_zstd (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
|
||||
{
|
||||
if (memcmp (tests[i].uncompressed, uncompressed, uncompressed_len)
|
||||
!= 0)
|
||||
{
|
||||
size_t j;
|
||||
|
||||
fprintf (stderr, "test %s: uncompressed data mismatch\n",
|
||||
tests[i].name);
|
||||
for (j = 0; j < uncompressed_len; ++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: uncompress %s\n", tests[i].name);
|
||||
}
|
||||
|
||||
free (uncompressed);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZSTD
|
||||
|
||||
/* 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)
|
||||
{
|
||||
#ifdef HAVE_ZSTD
|
||||
unsigned char *orig_buf;
|
||||
size_t orig_bufsize;
|
||||
size_t i;
|
||||
char *compressed_buf;
|
||||
size_t compressed_bufsize;
|
||||
size_t compressed_size;
|
||||
unsigned char *uncompressed_buf;
|
||||
size_t 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: zstd large\n");
|
||||
return;
|
||||
}
|
||||
|
||||
compressed_bufsize = ZSTD_compressBound (orig_bufsize);
|
||||
compressed_buf = malloc (compressed_bufsize);
|
||||
if (compressed_buf == NULL)
|
||||
{
|
||||
perror ("malloc");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = ZSTD_compress (compressed_buf, compressed_bufsize,
|
||||
orig_buf, orig_bufsize,
|
||||
ZSTD_CLEVEL_DEFAULT);
|
||||
if (ZSTD_isError (r))
|
||||
{
|
||||
fprintf (stderr, "zstd compress failed: %s\n", ZSTD_getErrorName (r));
|
||||
goto fail;
|
||||
}
|
||||
compressed_size = r;
|
||||
|
||||
uncompressed_buf = malloc (orig_bufsize);
|
||||
if (uncompressed_buf == NULL)
|
||||
{
|
||||
perror ("malloc");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!backtrace_uncompress_zstd (state, (unsigned char *) compressed_buf,
|
||||
compressed_size,
|
||||
error_callback_compress, NULL,
|
||||
uncompressed_buf, orig_bufsize))
|
||||
{
|
||||
fprintf (stderr, "zstd large: backtrace_uncompress_zstd failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (memcmp (uncompressed_buf, orig_buf, orig_bufsize) != 0)
|
||||
{
|
||||
size_t j;
|
||||
|
||||
fprintf (stderr, "zstd large: uncompressed data mismatch\n");
|
||||
for (j = 0; j < orig_bufsize; ++j)
|
||||
if (orig_buf[j] != uncompressed_buf[j])
|
||||
fprintf (stderr, " %zu: got %#x want %#x\n", j,
|
||||
uncompressed_buf[j], orig_buf[j]);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
printf ("PASS: zstd large\n");
|
||||
|
||||
for (i = 0; i < trials; ++i)
|
||||
{
|
||||
cid = ZSTD_CLOCK_GETTIME_ARG;
|
||||
if (clock_gettime (cid, &ts1) < 0)
|
||||
{
|
||||
if (errno == EINVAL)
|
||||
return;
|
||||
perror ("clock_gettime");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!backtrace_uncompress_zstd (state,
|
||||
(unsigned char *) compressed_buf,
|
||||
compressed_size,
|
||||
error_callback_compress, NULL,
|
||||
uncompressed_buf,
|
||||
orig_bufsize))
|
||||
{
|
||||
fprintf (stderr,
|
||||
("zstd large: "
|
||||
"benchmark backtrace_uncompress_zstd 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;
|
||||
|
||||
if (clock_gettime (cid, &ts1) < 0)
|
||||
{
|
||||
perror("clock_gettime");
|
||||
return;
|
||||
}
|
||||
|
||||
r = ZSTD_decompress (uncompressed_buf, orig_bufsize,
|
||||
compressed_buf, compressed_size);
|
||||
|
||||
if (clock_gettime (cid, &ts2) < 0)
|
||||
{
|
||||
perror ("clock_gettime");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ZSTD_isError (r))
|
||||
{
|
||||
fprintf (stderr,
|
||||
"zstd large: benchmark zlib uncompress failed: %s\n",
|
||||
ZSTD_getErrorName (r));
|
||||
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 ("zstd : %zu ns\n", ztime);
|
||||
printf ("ratio : %g\n", (double) ztime / (double) ctime);
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
printf ("FAIL: zstd 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_ZSTD */
|
||||
|
||||
printf ("UNSUPPORTED: zstd large\n");
|
||||
|
||||
#endif /* !HAVE_ZSTD */
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
Loading…
Add table
Reference in a new issue