Update from gcc trunk version of libbacktrace at svn rev 256427. (#8)
Includes (among other things) support for compressed debug sections, a variety of bugfixes, and expanded test coverage.
This commit is contained in:
parent
14d377e9be
commit
17f687d2b9
76
Makefile.am
76
Makefile.am
|
@ -1,5 +1,5 @@
|
|||
# Makefile.am -- Backtrace Makefile.
|
||||
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
|
@ -29,11 +29,14 @@
|
|||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
|
||||
AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
|
||||
|
||||
lib_LTLIBRARIES = libbacktrace.la
|
||||
include_HEADERS = backtrace.h backtrace-supported.h
|
||||
|
||||
noinst_LTLIBRARIES = libbacktrace.la
|
||||
|
||||
libbacktrace_la_SOURCES = \
|
||||
backtrace.h \
|
||||
atomic.c \
|
||||
|
@ -53,7 +56,8 @@ BACKTRACE_FILES = \
|
|||
FORMAT_FILES = \
|
||||
elf.c \
|
||||
pecoff.c \
|
||||
unknown.c
|
||||
unknown.c \
|
||||
xcoff.c
|
||||
|
||||
VIEW_FILES = \
|
||||
read.c \
|
||||
|
@ -85,7 +89,7 @@ TESTS = $(check_PROGRAMS)
|
|||
|
||||
if NATIVE
|
||||
|
||||
btest_SOURCES = btest.c
|
||||
btest_SOURCES = btest.c testlib.c
|
||||
btest_CFLAGS = $(AM_CFLAGS) -g -O
|
||||
btest_LDADD = libbacktrace.la
|
||||
|
||||
|
@ -96,6 +100,64 @@ stest_LDADD = libbacktrace.la
|
|||
|
||||
check_PROGRAMS += stest
|
||||
|
||||
ztest_SOURCES = ztest.c testlib.c
|
||||
ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
|
||||
ztest_LDADD = libbacktrace.la
|
||||
|
||||
if HAVE_ZLIB
|
||||
ztest_LDADD += -lz
|
||||
endif
|
||||
ztest_LDADD += $(CLOCK_GETTIME_LINK)
|
||||
|
||||
check_PROGRAMS += ztest
|
||||
|
||||
edtest_SOURCES = edtest.c edtest2_build.c testlib.c
|
||||
edtest_LDADD = libbacktrace.la
|
||||
|
||||
check_PROGRAMS += edtest
|
||||
|
||||
edtest2_build.c: gen_edtest2_build; @true
|
||||
gen_edtest2_build: $(srcdir)/edtest2.c
|
||||
cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
|
||||
$(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c
|
||||
echo timestamp > $@
|
||||
|
||||
if HAVE_PTHREAD
|
||||
|
||||
check_PROGRAMS += ttest
|
||||
|
||||
ttest_SOURCES = ttest.c testlib.c
|
||||
ttest_CFLAGS = $(AM_CFLAGS) -pthread
|
||||
ttest_LDADD = libbacktrace.la
|
||||
|
||||
endif HAVE_PTHREAD
|
||||
|
||||
if HAVE_OBJCOPY_DEBUGLINK
|
||||
|
||||
TESTS += dtest
|
||||
|
||||
dtest: btest
|
||||
$(OBJCOPY) --only-keep-debug btest btest.debug
|
||||
$(OBJCOPY) --strip-debug --add-gnu-debuglink=btest.debug btest dtest
|
||||
|
||||
endif HAVE_OBJCOPY_DEBUGLINK
|
||||
|
||||
if HAVE_COMPRESSED_DEBUG
|
||||
|
||||
ctestg_SOURCES = btest.c testlib.c
|
||||
ctestg_CFLAGS = $(AM_CFLAGS) -g
|
||||
ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
|
||||
ctestg_LDADD = libbacktrace.la
|
||||
|
||||
ctesta_SOURCES = btest.c testlib.c
|
||||
ctesta_CFLAGS = $(AM_CFLAGS) -g
|
||||
ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
|
||||
ctesta_LDADD = libbacktrace.la
|
||||
|
||||
check_PROGRAMS += ctestg ctesta
|
||||
|
||||
endif
|
||||
|
||||
endif NATIVE
|
||||
|
||||
# We can't use automake's automatic dependency tracking, because it
|
||||
|
@ -112,8 +174,8 @@ endif NATIVE
|
|||
|
||||
alloc.lo: config.h backtrace.h internal.h
|
||||
backtrace.lo: config.h backtrace.h internal.h
|
||||
btest.lo: backtrace.h backtrace-supported.h
|
||||
dwarf.lo: config.h backtrace.h internal.h
|
||||
btest.lo: backtrace.h backtrace-supported.h filenames.h
|
||||
dwarf.lo: config.h filenames.h backtrace.h internal.h
|
||||
elf.lo: config.h backtrace.h internal.h
|
||||
fileline.lo: config.h backtrace.h internal.h
|
||||
mmap.lo: config.h backtrace.h internal.h
|
||||
|
@ -128,3 +190,5 @@ sort.lo: config.h backtrace.h internal.h
|
|||
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
|
||||
|
||||
|
|
306
Makefile.in
306
Makefile.in
|
@ -16,7 +16,7 @@
|
|||
@SET_MAKE@
|
||||
|
||||
# Makefile.am -- Backtrace Makefile.
|
||||
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
|
@ -84,8 +84,12 @@ POST_UNINSTALL = :
|
|||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
check_PROGRAMS = $(am__EXEEXT_1)
|
||||
@NATIVE_TRUE@am__append_1 = btest stest
|
||||
check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3)
|
||||
@NATIVE_TRUE@am__append_1 = btest stest ztest edtest
|
||||
@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_2 = -lz
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_3 = ttest
|
||||
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_4 = dtest
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_5 = ctestg ctesta
|
||||
subdir = .
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(top_srcdir)/configure $(am__configure_deps) \
|
||||
|
@ -102,6 +106,90 @@ mkinstalldirs = $(install_sh) -d
|
|||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES = backtrace-supported.h
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 =
|
||||
am_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo fileline.lo posix.lo \
|
||||
print.lo sort.lo state.lo
|
||||
libbacktrace_la_OBJECTS = $(am_libbacktrace_la_OBJECTS)
|
||||
@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) stest$(EXEEXT) \
|
||||
@NATIVE_TRUE@ ztest$(EXEEXT) edtest$(EXEEXT)
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = ttest$(EXEEXT)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctestg$(EXEEXT) \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta$(EXEEXT)
|
||||
@NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT) \
|
||||
@NATIVE_TRUE@ btest-testlib.$(OBJEXT)
|
||||
btest_OBJECTS = $(am_btest_OBJECTS)
|
||||
@NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la
|
||||
btest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctesta_OBJECTS = ctesta-btest.$(OBJEXT) \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctesta-testlib.$(OBJEXT)
|
||||
ctesta_OBJECTS = $(am_ctesta_OBJECTS)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_DEPENDENCIES = \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ libbacktrace.la
|
||||
ctesta_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(ctesta_CFLAGS) $(CFLAGS) \
|
||||
$(ctesta_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am_ctestg_OBJECTS = ctestg-btest.$(OBJEXT) \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ ctestg-testlib.$(OBJEXT)
|
||||
ctestg_OBJECTS = $(am_ctestg_OBJECTS)
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_DEPENDENCIES = \
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ libbacktrace.la
|
||||
ctestg_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(ctestg_CFLAGS) $(CFLAGS) \
|
||||
$(ctestg_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@NATIVE_TRUE@am_edtest_OBJECTS = edtest.$(OBJEXT) \
|
||||
@NATIVE_TRUE@ edtest2_build.$(OBJEXT) testlib.$(OBJEXT)
|
||||
edtest_OBJECTS = $(am_edtest_OBJECTS)
|
||||
@NATIVE_TRUE@edtest_DEPENDENCIES = libbacktrace.la
|
||||
@NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT)
|
||||
stest_OBJECTS = $(am_stest_OBJECTS)
|
||||
@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am_ttest_OBJECTS = \
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ ttest-ttest.$(OBJEXT) \
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ ttest-testlib.$(OBJEXT)
|
||||
ttest_OBJECTS = $(am_ttest_OBJECTS)
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_DEPENDENCIES = libbacktrace.la
|
||||
ttest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(ttest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
@NATIVE_TRUE@am_ztest_OBJECTS = ztest-ztest.$(OBJEXT) \
|
||||
@NATIVE_TRUE@ ztest-testlib.$(OBJEXT)
|
||||
ztest_OBJECTS = $(am_ztest_OBJECTS)
|
||||
@NATIVE_TRUE@ztest_DEPENDENCIES = libbacktrace.la \
|
||||
@NATIVE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
||||
ztest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(ztest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
|
||||
$(btest_SOURCES) $(ctesta_SOURCES) $(ctestg_SOURCES) \
|
||||
$(edtest_SOURCES) $(stest_SOURCES) $(ttest_SOURCES) \
|
||||
$(ztest_SOURCES)
|
||||
MULTISRCTOP =
|
||||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
|
@ -129,47 +217,7 @@ am__uninstall_files_from_dir = { \
|
|||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 =
|
||||
am_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo fileline.lo posix.lo \
|
||||
print.lo sort.lo state.lo
|
||||
libbacktrace_la_OBJECTS = $(am_libbacktrace_la_OBJECTS)
|
||||
@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) stest$(EXEEXT)
|
||||
@NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT)
|
||||
btest_OBJECTS = $(am_btest_OBJECTS)
|
||||
@NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la
|
||||
btest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
@NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT)
|
||||
stest_OBJECTS = $(am_stest_OBJECTS)
|
||||
@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
|
||||
$(btest_SOURCES) $(stest_SOURCES)
|
||||
MULTISRCTOP =
|
||||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__installdirs = "$(DESTDIR)$(includedir)"
|
||||
HEADERS = $(include_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
|
@ -190,6 +238,7 @@ BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@
|
|||
BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
|
@ -223,6 +272,8 @@ MAKEINFO = @MAKEINFO@
|
|||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJCOPY = @OBJCOPY@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
|
@ -235,6 +286,7 @@ PACKAGE_URL = @PACKAGE_URL@
|
|||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PIC_FLAG = @PIC_FLAG@
|
||||
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
|
@ -278,7 +330,6 @@ libexecdir = @libexecdir@
|
|||
libtool_VERSION = @libtool_VERSION@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
multi_basedir = @multi_basedir@
|
||||
|
@ -287,6 +338,7 @@ pdfdir = @pdfdir@
|
|||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
|
@ -299,9 +351,10 @@ target_vendor = @target_vendor@
|
|||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
|
||||
lib_LTLIBRARIES = libbacktrace.la
|
||||
include_HEADERS = backtrace.h backtrace-supported.h
|
||||
noinst_LTLIBRARIES = libbacktrace.la
|
||||
libbacktrace_la_SOURCES = \
|
||||
backtrace.h \
|
||||
atomic.c \
|
||||
|
@ -321,7 +374,8 @@ BACKTRACE_FILES = \
|
|||
FORMAT_FILES = \
|
||||
elf.c \
|
||||
pecoff.c \
|
||||
unknown.c
|
||||
unknown.c \
|
||||
xcoff.c
|
||||
|
||||
VIEW_FILES = \
|
||||
read.c \
|
||||
|
@ -344,12 +398,29 @@ libbacktrace_la_LIBADD = \
|
|||
$(ALLOC_FILE)
|
||||
|
||||
libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
|
||||
TESTS = $(check_PROGRAMS)
|
||||
@NATIVE_TRUE@btest_SOURCES = btest.c
|
||||
TESTS = $(check_PROGRAMS) $(am__append_4)
|
||||
@NATIVE_TRUE@btest_SOURCES = btest.c testlib.c
|
||||
@NATIVE_TRUE@btest_CFLAGS = $(AM_CFLAGS) -g -O
|
||||
@NATIVE_TRUE@btest_LDADD = libbacktrace.la
|
||||
@NATIVE_TRUE@stest_SOURCES = stest.c
|
||||
@NATIVE_TRUE@stest_LDADD = libbacktrace.la
|
||||
@NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
|
||||
@NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
|
||||
@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) \
|
||||
@NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
|
||||
@NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c
|
||||
@NATIVE_TRUE@edtest_LDADD = libbacktrace.la
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_CFLAGS = $(AM_CFLAGS) -pthread
|
||||
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_LDADD = libbacktrace.la
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_SOURCES = btest.c testlib.c
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_CFLAGS = $(AM_CFLAGS) -g
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctestg_LDADD = libbacktrace.la
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_SOURCES = btest.c testlib.c
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_CFLAGS = $(AM_CFLAGS) -g
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
|
||||
@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@ctesta_LDADD = libbacktrace.la
|
||||
all: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
|
@ -406,40 +477,17 @@ distclean-hdr:
|
|||
-rm -f config.h stamp-h1
|
||||
backtrace-supported.h: $(top_builddir)/config.status $(srcdir)/backtrace-supported.h.in
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
list2=; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
list2="$$list2 $$p"; \
|
||||
else :; fi; \
|
||||
done; \
|
||||
test -z "$$list2" || { \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
|
||||
}
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) $(EXTRA_libbacktrace_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(libdir) $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS)
|
||||
$(LINK) $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS)
|
||||
|
||||
clean-checkPROGRAMS:
|
||||
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
|
@ -452,9 +500,24 @@ clean-checkPROGRAMS:
|
|||
btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) $(EXTRA_btest_DEPENDENCIES)
|
||||
@rm -f btest$(EXEEXT)
|
||||
$(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS)
|
||||
ctesta$(EXEEXT): $(ctesta_OBJECTS) $(ctesta_DEPENDENCIES) $(EXTRA_ctesta_DEPENDENCIES)
|
||||
@rm -f ctesta$(EXEEXT)
|
||||
$(ctesta_LINK) $(ctesta_OBJECTS) $(ctesta_LDADD) $(LIBS)
|
||||
ctestg$(EXEEXT): $(ctestg_OBJECTS) $(ctestg_DEPENDENCIES) $(EXTRA_ctestg_DEPENDENCIES)
|
||||
@rm -f ctestg$(EXEEXT)
|
||||
$(ctestg_LINK) $(ctestg_OBJECTS) $(ctestg_LDADD) $(LIBS)
|
||||
edtest$(EXEEXT): $(edtest_OBJECTS) $(edtest_DEPENDENCIES) $(EXTRA_edtest_DEPENDENCIES)
|
||||
@rm -f edtest$(EXEEXT)
|
||||
$(LINK) $(edtest_OBJECTS) $(edtest_LDADD) $(LIBS)
|
||||
stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES) $(EXTRA_stest_DEPENDENCIES)
|
||||
@rm -f stest$(EXEEXT)
|
||||
$(LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS)
|
||||
ttest$(EXEEXT): $(ttest_OBJECTS) $(ttest_DEPENDENCIES) $(EXTRA_ttest_DEPENDENCIES)
|
||||
@rm -f ttest$(EXEEXT)
|
||||
$(ttest_LINK) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS)
|
||||
ztest$(EXEEXT): $(ztest_OBJECTS) $(ztest_DEPENDENCIES) $(EXTRA_ztest_DEPENDENCIES)
|
||||
@rm -f ztest$(EXEEXT)
|
||||
$(ztest_LINK) $(ztest_OBJECTS) $(ztest_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
@ -477,6 +540,60 @@ btest-btest.o: btest.c
|
|||
btest-btest.obj: btest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
|
||||
|
||||
btest-testlib.o: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
btest-testlib.obj: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
ctesta-btest.o: btest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
|
||||
|
||||
ctesta-btest.obj: btest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
|
||||
|
||||
ctesta-testlib.o: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
ctesta-testlib.obj: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctesta_CFLAGS) $(CFLAGS) -c -o ctesta-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
ctestg-btest.o: btest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c
|
||||
|
||||
ctestg-btest.obj: btest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi`
|
||||
|
||||
ctestg-testlib.o: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
ctestg-testlib.obj: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ctestg_CFLAGS) $(CFLAGS) -c -o ctestg-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
ttest-ttest.o: ttest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-ttest.o `test -f 'ttest.c' || echo '$(srcdir)/'`ttest.c
|
||||
|
||||
ttest-ttest.obj: ttest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-ttest.obj `if test -f 'ttest.c'; then $(CYGPATH_W) 'ttest.c'; else $(CYGPATH_W) '$(srcdir)/ttest.c'; fi`
|
||||
|
||||
ttest-testlib.o: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
ttest-testlib.obj: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ttest_CFLAGS) $(CFLAGS) -c -o ttest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
ztest-ztest.o: ztest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-ztest.o `test -f 'ztest.c' || echo '$(srcdir)/'`ztest.c
|
||||
|
||||
ztest-ztest.obj: ztest.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-ztest.obj `if test -f 'ztest.c'; then $(CYGPATH_W) 'ztest.c'; else $(CYGPATH_W) '$(srcdir)/ztest.c'; fi`
|
||||
|
||||
ztest-testlib.o: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-testlib.o `test -f 'testlib.c' || echo '$(srcdir)/'`testlib.c
|
||||
|
||||
ztest-testlib.obj: testlib.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ztest_CFLAGS) $(CFLAGS) -c -o ztest-testlib.obj `if test -f 'testlib.c'; then $(CYGPATH_W) 'testlib.c'; else $(CYGPATH_W) '$(srcdir)/testlib.c'; fi`
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
|
@ -674,7 +791,7 @@ check-am: all-am
|
|||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) all-multi $(HEADERS) config.h
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
|
||||
for dir in "$(DESTDIR)$(includedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
|
@ -709,8 +826,8 @@ maintainer-clean-generic:
|
|||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am clean-multi
|
||||
|
||||
clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \
|
||||
clean-libtool mostlyclean-am
|
||||
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
|
||||
clean-noinstLTLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-am distclean-multi
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
|
@ -736,7 +853,7 @@ install-dvi: install-dvi-am
|
|||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-libLTLIBRARIES install-multi
|
||||
install-exec-am: install-multi
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
|
@ -777,30 +894,40 @@ ps: ps-am
|
|||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
|
||||
uninstall-am: uninstall-includeHEADERS
|
||||
|
||||
.MAKE: all all-multi check-am clean-multi distclean-multi install-am \
|
||||
install-multi install-strip maintainer-clean-multi \
|
||||
mostlyclean-multi
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am all-multi am--refresh check check-TESTS \
|
||||
check-am clean clean-checkPROGRAMS clean-generic \
|
||||
clean-libLTLIBRARIES clean-libtool clean-multi ctags distclean \
|
||||
check-am clean clean-checkPROGRAMS clean-generic clean-libtool \
|
||||
clean-multi clean-noinstLTLIBRARIES ctags distclean \
|
||||
distclean-compile distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-multi distclean-tags dvi dvi-am \
|
||||
html html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am \
|
||||
install-includeHEADERS install-info install-info-am \
|
||||
install-libLTLIBRARIES install-man install-multi install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
install-man install-multi install-pdf install-pdf-am \
|
||||
install-ps install-ps-am install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic maintainer-clean-multi mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
mostlyclean-multi pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-includeHEADERS uninstall-libLTLIBRARIES
|
||||
uninstall-am uninstall-includeHEADERS
|
||||
|
||||
|
||||
@NATIVE_TRUE@edtest2_build.c: gen_edtest2_build; @true
|
||||
@NATIVE_TRUE@gen_edtest2_build: $(srcdir)/edtest2.c
|
||||
@NATIVE_TRUE@ cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
|
||||
@NATIVE_TRUE@ $(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c
|
||||
@NATIVE_TRUE@ echo timestamp > $@
|
||||
|
||||
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@dtest: btest
|
||||
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --only-keep-debug btest btest.debug
|
||||
@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ $(OBJCOPY) --strip-debug --add-gnu-debuglink=btest.debug btest dtest
|
||||
|
||||
# We can't use automake's automatic dependency tracking, because it
|
||||
# breaks when using bootstrap-lean. Automatic dependency tracking
|
||||
# with GCC bootstrap will cause some of the objects to depend on
|
||||
|
@ -815,8 +942,8 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
|
|||
|
||||
alloc.lo: config.h backtrace.h internal.h
|
||||
backtrace.lo: config.h backtrace.h internal.h
|
||||
btest.lo: backtrace.h backtrace-supported.h
|
||||
dwarf.lo: config.h backtrace.h internal.h
|
||||
btest.lo: backtrace.h backtrace-supported.h filenames.h
|
||||
dwarf.lo: config.h filenames.h backtrace.h internal.h
|
||||
elf.lo: config.h backtrace.h internal.h
|
||||
fileline.lo: config.h backtrace.h internal.h
|
||||
mmap.lo: config.h backtrace.h internal.h
|
||||
|
@ -831,6 +958,7 @@ sort.lo: config.h backtrace.h internal.h
|
|||
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
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
|
|
@ -69,3 +69,4 @@ CFLAGS="$save_CFLAGS"
|
|||
m4_popdef([acx_Var])dnl
|
||||
AC_LANG_POP(C)
|
||||
])# ACX_PROG_CC_WARNING_OPTS
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
2
alloc.c
2
alloc.c
|
@ -1,5 +1,5 @@
|
|||
/* alloc.c -- Memory allocation without mmap.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
atomic.c
2
atomic.c
|
@ -1,5 +1,5 @@
|
|||
/* atomic.c -- Support for atomic functions if not present.
|
||||
Copyright (C) 2013-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* backtrace.c -- Entry point for stack backtrace library.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* backtrace.h -- Public header file for stack backtrace library.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
281
btest.c
281
btest.c
|
@ -1,5 +1,5 @@
|
|||
/* btest.c -- Test for libbacktrace library
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -38,246 +38,12 @@ POSSIBILITY OF SUCH DAMAGE. */
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "filenames.h"
|
||||
|
||||
#include "backtrace.h"
|
||||
#include "backtrace-supported.h"
|
||||
|
||||
/* Portable attribute syntax. Actually some of these tests probably
|
||||
won't work if the attributes are not recognized. */
|
||||
|
||||
#ifndef GCC_VERSION
|
||||
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#endif
|
||||
|
||||
#if (GCC_VERSION < 2007)
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
|
||||
# define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
|
||||
#else
|
||||
# define IS_DIR_SEPARATOR(c) ((c) == '/')
|
||||
#endif
|
||||
|
||||
/* Used to collect backtrace info. */
|
||||
|
||||
struct info
|
||||
{
|
||||
char *filename;
|
||||
int lineno;
|
||||
char *function;
|
||||
};
|
||||
|
||||
/* Passed to backtrace callback function. */
|
||||
|
||||
struct bdata
|
||||
{
|
||||
struct info *all;
|
||||
size_t index;
|
||||
size_t max;
|
||||
int failed;
|
||||
};
|
||||
|
||||
/* Passed to backtrace_simple callback function. */
|
||||
|
||||
struct sdata
|
||||
{
|
||||
uintptr_t *addrs;
|
||||
size_t index;
|
||||
size_t max;
|
||||
int failed;
|
||||
};
|
||||
|
||||
/* Passed to backtrace_syminfo callback function. */
|
||||
|
||||
struct symdata
|
||||
{
|
||||
const char *name;
|
||||
uintptr_t val, size;
|
||||
int failed;
|
||||
};
|
||||
|
||||
/* The backtrace state. */
|
||||
|
||||
static void *state;
|
||||
|
||||
/* The number of failures. */
|
||||
|
||||
static int failures;
|
||||
|
||||
/* Return the base name in a path. */
|
||||
|
||||
static const char *
|
||||
base (const char *p)
|
||||
{
|
||||
const char *last;
|
||||
const char *s;
|
||||
|
||||
last = NULL;
|
||||
for (s = p; *s != '\0'; ++s)
|
||||
{
|
||||
if (IS_DIR_SEPARATOR (*s))
|
||||
last = s + 1;
|
||||
}
|
||||
return last != NULL ? last : p;
|
||||
}
|
||||
|
||||
/* Check an entry in a struct info array. */
|
||||
|
||||
static void
|
||||
check (const char *name, int index, const struct info *all, int want_lineno,
|
||||
const char *want_function, int *failed)
|
||||
{
|
||||
if (*failed)
|
||||
return;
|
||||
if (all[index].filename == NULL || all[index].function == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: missing file name or function name\n",
|
||||
name, index);
|
||||
*failed = 1;
|
||||
return;
|
||||
}
|
||||
if (strcmp (base (all[index].filename), "btest.c") != 0)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: got %s expected test.c\n", name, index,
|
||||
all[index].filename);
|
||||
*failed = 1;
|
||||
}
|
||||
if (all[index].lineno != want_lineno)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: got %d expected %d\n", name, index,
|
||||
all[index].lineno, want_lineno);
|
||||
*failed = 1;
|
||||
}
|
||||
if (strcmp (all[index].function, want_function) != 0)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index,
|
||||
all[index].function, want_function);
|
||||
*failed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The backtrace callback function. */
|
||||
|
||||
static int
|
||||
callback_one (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||
const char *filename, int lineno, const char *function)
|
||||
{
|
||||
struct bdata *data = (struct bdata *) vdata;
|
||||
struct info *p;
|
||||
|
||||
if (data->index >= data->max)
|
||||
{
|
||||
fprintf (stderr, "callback_one: callback called too many times\n");
|
||||
data->failed = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
p = &data->all[data->index];
|
||||
if (filename == NULL)
|
||||
p->filename = NULL;
|
||||
else
|
||||
{
|
||||
p->filename = strdup (filename);
|
||||
assert (p->filename != NULL);
|
||||
}
|
||||
p->lineno = lineno;
|
||||
if (function == NULL)
|
||||
p->function = NULL;
|
||||
else
|
||||
{
|
||||
p->function = strdup (function);
|
||||
assert (p->function != NULL);
|
||||
}
|
||||
++data->index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* An error callback passed to backtrace. */
|
||||
|
||||
static void
|
||||
error_callback_one (void *vdata, const char *msg, int errnum)
|
||||
{
|
||||
struct bdata *data = (struct bdata *) vdata;
|
||||
|
||||
fprintf (stderr, "%s", msg);
|
||||
if (errnum > 0)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
fprintf (stderr, "\n");
|
||||
data->failed = 1;
|
||||
}
|
||||
|
||||
/* The backtrace_simple callback function. */
|
||||
|
||||
static int
|
||||
callback_two (void *vdata, uintptr_t pc)
|
||||
{
|
||||
struct sdata *data = (struct sdata *) vdata;
|
||||
|
||||
if (data->index >= data->max)
|
||||
{
|
||||
fprintf (stderr, "callback_two: callback called too many times\n");
|
||||
data->failed = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
data->addrs[data->index] = pc;
|
||||
++data->index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* An error callback passed to backtrace_simple. */
|
||||
|
||||
static void
|
||||
error_callback_two (void *vdata, const char *msg, int errnum)
|
||||
{
|
||||
struct sdata *data = (struct sdata *) vdata;
|
||||
|
||||
fprintf (stderr, "%s", msg);
|
||||
if (errnum > 0)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
fprintf (stderr, "\n");
|
||||
data->failed = 1;
|
||||
}
|
||||
|
||||
/* The backtrace_syminfo callback function. */
|
||||
|
||||
static void
|
||||
callback_three (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||
const char *symname, uintptr_t symval,
|
||||
uintptr_t symsize)
|
||||
{
|
||||
struct symdata *data = (struct symdata *) vdata;
|
||||
|
||||
if (symname == NULL)
|
||||
data->name = NULL;
|
||||
else
|
||||
{
|
||||
data->name = strdup (symname);
|
||||
assert (data->name != NULL);
|
||||
}
|
||||
data->val = symval;
|
||||
data->size = symsize;
|
||||
}
|
||||
|
||||
/* The backtrace_syminfo error callback function. */
|
||||
|
||||
static void
|
||||
error_callback_three (void *vdata, const char *msg, int errnum)
|
||||
{
|
||||
struct symdata *data = (struct symdata *) vdata;
|
||||
|
||||
fprintf (stderr, "%s", msg);
|
||||
if (errnum > 0)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
fprintf (stderr, "\n");
|
||||
data->failed = 1;
|
||||
}
|
||||
#include "testlib.h"
|
||||
|
||||
/* Test the backtrace function with non-inlined functions. */
|
||||
|
||||
|
@ -329,9 +95,9 @@ f3 (int f1line, int f2line)
|
|||
data.failed = 1;
|
||||
}
|
||||
|
||||
check ("test1", 0, all, f3line, "f3", &data.failed);
|
||||
check ("test1", 1, all, f2line, "f2", &data.failed);
|
||||
check ("test1", 2, all, f1line, "test1", &data.failed);
|
||||
check ("test1", 0, all, f3line, "f3", "btest.c", &data.failed);
|
||||
check ("test1", 1, all, f2line, "f2", "btest.c", &data.failed);
|
||||
check ("test1", 2, all, f1line, "test1", "btest.c", &data.failed);
|
||||
|
||||
printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS");
|
||||
|
||||
|
@ -381,9 +147,9 @@ f13 (int f1line, int f2line)
|
|||
data.failed = 1;
|
||||
}
|
||||
|
||||
check ("test2", 0, all, f3line, "f13", &data.failed);
|
||||
check ("test2", 1, all, f2line, "f12", &data.failed);
|
||||
check ("test2", 2, all, f1line, "test2", &data.failed);
|
||||
check ("test2", 0, all, f3line, "f13", "btest.c", &data.failed);
|
||||
check ("test2", 1, all, f2line, "f12", "btest.c", &data.failed);
|
||||
check ("test2", 2, all, f1line, "test2", "btest.c", &data.failed);
|
||||
|
||||
printf ("%s: backtrace_full inline\n", data.failed ? "FAIL" : "PASS");
|
||||
|
||||
|
@ -466,9 +232,9 @@ f23 (int f1line, int f2line)
|
|||
}
|
||||
}
|
||||
|
||||
check ("test3", 0, all, f3line, "f23", &bdata.failed);
|
||||
check ("test3", 1, all, f2line, "f22", &bdata.failed);
|
||||
check ("test3", 2, all, f1line, "test3", &bdata.failed);
|
||||
check ("test3", 0, all, f3line, "f23", "btest.c", &bdata.failed);
|
||||
check ("test3", 1, all, f2line, "f22", "btest.c", &bdata.failed);
|
||||
check ("test3", 2, all, f1line, "test3", "btest.c", &bdata.failed);
|
||||
|
||||
if (bdata.failed)
|
||||
data.failed = 1;
|
||||
|
@ -604,9 +370,9 @@ f33 (int f1line, int f2line)
|
|||
bdata.failed = 1;
|
||||
}
|
||||
|
||||
check ("test4", 0, all, f3line, "f33", &bdata.failed);
|
||||
check ("test4", 1, all, f2line, "f32", &bdata.failed);
|
||||
check ("test4", 2, all, f1line, "test4", &bdata.failed);
|
||||
check ("test4", 0, all, f3line, "f33", "btest.c", &bdata.failed);
|
||||
check ("test4", 1, all, f2line, "f32", "btest.c", &bdata.failed);
|
||||
check ("test4", 2, all, f1line, "test4", "btest.c", &bdata.failed);
|
||||
|
||||
if (bdata.failed)
|
||||
data.failed = 1;
|
||||
|
@ -620,7 +386,7 @@ f33 (int f1line, int f2line)
|
|||
return failures;
|
||||
}
|
||||
|
||||
#if BACKTRACE_SUPPORTS_DATA
|
||||
static int test5 (void) __attribute__ ((unused));
|
||||
|
||||
int global = 1;
|
||||
|
||||
|
@ -690,19 +456,6 @@ test5 (void)
|
|||
return failures;
|
||||
}
|
||||
|
||||
#endif /* BACKTRACE_SUPPORTS_DATA */
|
||||
|
||||
static void
|
||||
error_callback_create (void *data 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);
|
||||
}
|
||||
|
||||
/* Run all the tests. */
|
||||
|
||||
int
|
||||
|
|
98
configure.ac
98
configure.ac
|
@ -1,5 +1,5 @@
|
|||
# configure.ac -- Backtrace configure script.
|
||||
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
|
@ -83,6 +83,8 @@ esac
|
|||
LT_INIT
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
backtrace_supported=yes
|
||||
|
||||
if test -n "${with_target_subdir}"; then
|
||||
|
@ -232,6 +234,9 @@ elf*) FORMAT_FILE="elf.lo" ;;
|
|||
pecoff) FORMAT_FILE="pecoff.lo"
|
||||
backtrace_supports_data=no
|
||||
;;
|
||||
xcoff*) FORMAT_FILE="xcoff.lo"
|
||||
backtrace_supports_data=no
|
||||
;;
|
||||
*) AC_MSG_WARN([could not determine output file type])
|
||||
FORMAT_FILE="unknown.lo"
|
||||
backtrace_supported=no
|
||||
|
@ -248,6 +253,15 @@ elf64) elfsize=64 ;;
|
|||
esac
|
||||
AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
|
||||
|
||||
# XCOFF defines.
|
||||
xcoffsize=
|
||||
case "$libbacktrace_cv_sys_filetype" in
|
||||
xcoff32) xcoffsize=32 ;;
|
||||
xcoff64) xcoffsize=64 ;;
|
||||
*) xcoffsize=unused
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
|
||||
|
||||
BACKTRACE_SUPPORTED=0
|
||||
if test "$backtrace_supported" = "yes"; then
|
||||
BACKTRACE_SUPPORTED=1
|
||||
|
@ -324,6 +338,24 @@ if test "$have_dl_iterate_phdr" = "yes"; then
|
|||
AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
|
||||
fi
|
||||
|
||||
# Check for loadquery.
|
||||
AC_CHECK_HEADERS(sys/ldr.h)
|
||||
if test "$ac_cv_header_sys_ldr_h" = "no"; then
|
||||
have_loadquery=no
|
||||
else
|
||||
if test -n "${with_target_subdir}"; then
|
||||
# When built as a GCC target library, we can't do a link test.
|
||||
AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes],
|
||||
[have_loadquery=no])
|
||||
else
|
||||
AC_CHECK_FUNC([loadquery], [have_loadquery=yes],
|
||||
[have_loadquery=no])
|
||||
fi
|
||||
fi
|
||||
if test "$have_loadquery" = "yes"; then
|
||||
AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
|
||||
fi
|
||||
|
||||
# Check for the fcntl function.
|
||||
if test -n "${with_target_subdir}"; then
|
||||
case "${host}" in
|
||||
|
@ -340,6 +372,7 @@ if test "$have_fcntl" = "yes"; then
|
|||
fi
|
||||
|
||||
AC_CHECK_DECLS(strnlen)
|
||||
AC_CHECK_FUNCS(lstat readlink)
|
||||
|
||||
# Check for getexecname function.
|
||||
if test -n "${with_target_subdir}"; then
|
||||
|
@ -354,6 +387,69 @@ if test "$have_getexecname" = "yes"; then
|
|||
AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
|
||||
fi
|
||||
|
||||
# Check for the clock_gettime function.
|
||||
AC_CHECK_FUNCS(clock_gettime)
|
||||
clock_gettime_link=
|
||||
# At least for glibc, clock_gettime is in librt. But don't
|
||||
# pull that in if it still doesn't give us the function we want. This
|
||||
# test is copied from libgomp, and modified to not link in -lrt as
|
||||
# we're using this for test timing only.
|
||||
if test "$ac_cv_func_clock_gettime" = no; then
|
||||
AC_CHECK_LIB(rt, clock_gettime,
|
||||
[CLOCK_GETTIME_LINK=-lrt
|
||||
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
|
||||
[Define to 1 if you have the `clock_gettime' function.])])
|
||||
fi
|
||||
AC_SUBST(CLOCK_GETTIME_LINK)
|
||||
|
||||
dnl Test whether the compiler supports the -pthread option.
|
||||
AC_CACHE_CHECK([whether -pthread is supported],
|
||||
[libgo_cv_lib_pthread],
|
||||
[CFLAGS_hold=$CFLAGS
|
||||
CFLAGS="$CFLAGS -pthread"
|
||||
AC_COMPILE_IFELSE([[int i;]],
|
||||
[libgo_cv_lib_pthread=yes],
|
||||
[libgo_cv_lib_pthread=no])
|
||||
CFLAGS=$CFLAGS_hold])
|
||||
PTHREAD_CFLAGS=
|
||||
if test "$libgo_cv_lib_pthread" = yes; then
|
||||
PTHREAD_CFLAGS=-pthread
|
||||
fi
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
|
||||
AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
|
||||
|
||||
AC_CHECK_LIB([z], [compress], [])
|
||||
if test $ac_cv_lib_z_compress = "yes"; then
|
||||
AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
|
||||
|
||||
dnl Test whether the linker supports the --compress_debug_sections option.
|
||||
AC_CACHE_CHECK([whether --compress-debug-sections is supported],
|
||||
[libgo_cv_ld_compress],
|
||||
[LDFLAGS_hold=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
|
||||
[libgo_cv_ld_compress=yes],
|
||||
[libgo_cv_ld_compress=no])
|
||||
LDFLAGS=$LDFLAGS_hold])
|
||||
AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
|
||||
|
||||
AC_ARG_VAR(OBJCOPY, [location of objcopy])
|
||||
AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
|
||||
AC_CACHE_CHECK([whether objcopy supports debuglink],
|
||||
[libbacktrace_cv_objcopy_debuglink],
|
||||
[if test -n "${with_target_subdir}"; then
|
||||
libbacktrace_cv_objcopy_debuglink=no
|
||||
elif ${OBJCOPY} --add-gnu-debuglink=x /bin/ls /tmp/ls$$; then
|
||||
rm -f /tmp/ls$$
|
||||
libbacktrace_cv_objcopy_debuglink=yes
|
||||
else
|
||||
libbacktrace_cv_objcopy_debuglink=no
|
||||
fi])
|
||||
AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
|
||||
|
||||
AC_CACHE_CHECK([whether tests can run],
|
||||
[libbacktrace_cv_sys_native],
|
||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
|
||||
|
|
27
dwarf.c
27
dwarf.c
|
@ -1,5 +1,5 @@
|
|||
/* dwarf.c -- Get file/line information from DWARF for backtraces.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1648,16 +1648,15 @@ add_line (struct backtrace_state *state, struct dwarf_data *ddata,
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Free the line header information. If FREE_FILENAMES is true we
|
||||
free the file names themselves, otherwise we leave them, as there
|
||||
may be line structures pointing to them. */
|
||||
/* Free the line header information. */
|
||||
|
||||
static void
|
||||
free_line_header (struct backtrace_state *state, struct line_header *hdr,
|
||||
backtrace_error_callback error_callback, void *data)
|
||||
{
|
||||
backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *),
|
||||
error_callback, data);
|
||||
if (hdr->dirs_count != 0)
|
||||
backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *),
|
||||
error_callback, data);
|
||||
backtrace_free (state, hdr->filenames,
|
||||
hdr->filenames_count * sizeof (char *),
|
||||
error_callback, data);
|
||||
|
@ -1718,12 +1717,16 @@ read_line_header (struct backtrace_state *state, struct unit *u,
|
|||
++hdr->dirs_count;
|
||||
}
|
||||
|
||||
hdr->dirs = ((const char **)
|
||||
backtrace_alloc (state,
|
||||
hdr->dirs_count * sizeof (const char *),
|
||||
line_buf->error_callback, line_buf->data));
|
||||
if (hdr->dirs == NULL)
|
||||
return 0;
|
||||
hdr->dirs = NULL;
|
||||
if (hdr->dirs_count != 0)
|
||||
{
|
||||
hdr->dirs = ((const char **)
|
||||
backtrace_alloc (state,
|
||||
hdr->dirs_count * sizeof (const char *),
|
||||
line_buf->error_callback, line_buf->data));
|
||||
if (hdr->dirs == NULL)
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (*hdr_buf.buf != '\0')
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/* edtest.c -- Test for libbacktrace storage allocation stress handling
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
(1) Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
(2) Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
(3) The name of the author may not be used to
|
||||
endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "backtrace.h"
|
||||
#include "backtrace-supported.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include "testlib.h"
|
||||
|
||||
static int test1 (void) __attribute__ ((noinline, unused));
|
||||
static int test1 (void) __attribute__ ((noinline, unused));
|
||||
extern int f2 (int);
|
||||
extern int f3 (int, int);
|
||||
|
||||
static int
|
||||
test1 (void)
|
||||
{
|
||||
/* Returning a value here and elsewhere avoids a tailcall which
|
||||
would mess up the backtrace. */
|
||||
return f2 (__LINE__) + 1;
|
||||
}
|
||||
|
||||
int
|
||||
f3 (int f1line, int f2line)
|
||||
{
|
||||
struct info all[20];
|
||||
struct bdata data;
|
||||
int f3line;
|
||||
int i;
|
||||
|
||||
data.all = &all[0];
|
||||
data.index = 0;
|
||||
data.max = 20;
|
||||
data.failed = 0;
|
||||
|
||||
f3line = __LINE__ + 1;
|
||||
i = backtrace_full (state, 0, callback_one, 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;
|
||||
}
|
||||
|
||||
check ("test1", 0, all, f3line, "f3", "edtest.c", &data.failed);
|
||||
check ("test1", 1, all, f2line, "f2", "edtest2_build.c", &data.failed);
|
||||
check ("test1", 2, all, f1line, "test1", "edtest.c", &data.failed);
|
||||
|
||||
printf ("%s: backtrace_full alloc stress\n", data.failed ? "FAIL" : "PASS");
|
||||
|
||||
if (data.failed)
|
||||
++failures;
|
||||
|
||||
return failures;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||
{
|
||||
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||
error_callback_create, NULL);
|
||||
|
||||
// Grab the storage allocation lock prior to doing anything interesting.
|
||||
// The intent here is to insure that the backtrace_alloc code is forced
|
||||
// to always call mmap() for new memory as opposed to reusing previously
|
||||
// allocated memory from the free list. Doing things this way helps
|
||||
// simulate what you might see in a multithreaded program in which there
|
||||
// are racing calls to the allocator.
|
||||
struct backtrace_state *state_internal =
|
||||
(struct backtrace_state *) state;
|
||||
state_internal->lock_alloc = 1;
|
||||
|
||||
// Kick off the test
|
||||
test1();
|
||||
|
||||
exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2)
|
||||
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
(1) Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
(2) Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
(3) The name of the author may not be used to
|
||||
endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
/* This file intentionally written without any #include's
|
||||
*/
|
||||
|
||||
extern int f3(int, int);
|
||||
extern int f2(int);
|
||||
|
||||
int f2(int x)
|
||||
{
|
||||
/* Returning a value here and elsewhere avoids a tailcall which
|
||||
would mess up the backtrace. */
|
||||
return f3(x, __LINE__) + 3;
|
||||
}
|
17
fileline.c
17
fileline.c
|
@ -1,5 +1,5 @@
|
|||
/* fileline.c -- Get file and line number information in a backtrace.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. */
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "backtrace.h"
|
||||
#include "internal.h"
|
||||
|
@ -57,6 +58,8 @@ fileline_initialize (struct backtrace_state *state,
|
|||
int pass;
|
||||
int called_error_callback;
|
||||
int descriptor;
|
||||
const char *filename;
|
||||
char buf[64];
|
||||
|
||||
if (!state->threaded)
|
||||
failed = state->fileline_initialization_failed;
|
||||
|
@ -80,9 +83,8 @@ fileline_initialize (struct backtrace_state *state,
|
|||
|
||||
descriptor = -1;
|
||||
called_error_callback = 0;
|
||||
for (pass = 0; pass < 4; ++pass)
|
||||
for (pass = 0; pass < 5; ++pass)
|
||||
{
|
||||
const char *filename;
|
||||
int does_not_exist;
|
||||
|
||||
switch (pass)
|
||||
|
@ -99,6 +101,11 @@ fileline_initialize (struct backtrace_state *state,
|
|||
case 3:
|
||||
filename = "/proc/curproc/file";
|
||||
break;
|
||||
case 4:
|
||||
snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out",
|
||||
(long) getpid ());
|
||||
filename = buf;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
@ -133,8 +140,8 @@ fileline_initialize (struct backtrace_state *state,
|
|||
|
||||
if (!failed)
|
||||
{
|
||||
if (!backtrace_initialize (state, descriptor, error_callback, data,
|
||||
&fileline_fn))
|
||||
if (!backtrace_initialize (state, filename, descriptor, error_callback,
|
||||
data, &fileline_fn))
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* btest.c -- Filename header for libbacktrace library
|
||||
Copyright (C) 2012-2018 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. */
|
||||
|
||||
#ifndef GCC_VERSION
|
||||
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#endif
|
||||
|
||||
#if (GCC_VERSION < 2007)
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
|
||||
# define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
|
||||
#else
|
||||
# define IS_DIR_SEPARATOR(c) ((c) == '/')
|
||||
#endif
|
12
internal.h
12
internal.h
|
@ -1,5 +1,5 @@
|
|||
/* internal.h -- Internal header file for stack backtrace library.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -268,6 +268,7 @@ extern int backtrace_vector_release (struct backtrace_state *state,
|
|||
appropriate one. */
|
||||
|
||||
extern int backtrace_initialize (struct backtrace_state *state,
|
||||
const char *filename,
|
||||
int descriptor,
|
||||
backtrace_error_callback error_callback,
|
||||
void *data,
|
||||
|
@ -291,4 +292,13 @@ extern int backtrace_dwarf_add (struct backtrace_state *state,
|
|||
backtrace_error_callback error_callback,
|
||||
void *data, fileline *fileline_fn);
|
||||
|
||||
/* A test-only hook for elf_uncompress_zdebug. */
|
||||
|
||||
extern int backtrace_uncompress_zdebug (struct backtrace_state *,
|
||||
const unsigned char *compressed,
|
||||
size_t compressed_size,
|
||||
backtrace_error_callback, void *data,
|
||||
unsigned char **uncompressed,
|
||||
size_t *uncompressed_size);
|
||||
|
||||
#endif
|
||||
|
|
2
mmap.c
2
mmap.c
|
@ -1,5 +1,5 @@
|
|||
/* mmap.c -- Memory allocation with mmap.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
mmapio.c
2
mmapio.c
|
@ -1,5 +1,5 @@
|
|||
/* mmapio.c -- File views using mmap.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/sh
|
||||
# Like mv $1 $2, but if the files are the same, just delete $1.
|
||||
# Status is zero if successful, nonzero otherwise.
|
||||
|
||||
VERSION='2012-01-06 07:23'; # UTC
|
||||
# The definition above must lie within the first 8 lines in order
|
||||
# for the Emacs time-stamp write hook (at end) to update it.
|
||||
# If you change this file with Emacs, please let the write hook
|
||||
# do its job. Otherwise, update this string manually.
|
||||
|
||||
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage="usage: $0 SOURCE DEST"
|
||||
|
||||
help="$usage
|
||||
or: $0 OPTION
|
||||
If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
|
||||
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
|
||||
The variable CMPPROG can be used to specify an alternative to 'cmp'.
|
||||
|
||||
Report bugs to <bug-gnulib@gnu.org>."
|
||||
|
||||
version=`expr "$VERSION" : '\([^ ]*\)'`
|
||||
version="move-if-change (gnulib) $version
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law."
|
||||
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
--help | --hel | --he | --h)
|
||||
exec echo "$help" ;;
|
||||
--version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||
exec echo "$version" ;;
|
||||
--)
|
||||
shift
|
||||
break ;;
|
||||
-*)
|
||||
echo "$0: invalid option: $arg" >&2
|
||||
exit 1 ;;
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; }
|
||||
|
||||
if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then
|
||||
rm -f -- "$1"
|
||||
else
|
||||
if mv -f -- "$1" "$2"; then :; else
|
||||
# Ignore failure due to a concurrent move-if-change.
|
||||
test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1"
|
||||
fi
|
||||
fi
|
||||
|
||||
## Local Variables:
|
||||
## eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
## time-stamp-start: "VERSION='"
|
||||
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
|
||||
## time-stamp-time-zone: "UTC"
|
||||
## time-stamp-end: "'; # UTC"
|
||||
## End:
|
|
@ -1,5 +1,5 @@
|
|||
/* backtrace.c -- Entry point for stack backtrace library.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
7
pecoff.c
7
pecoff.c
|
@ -1,5 +1,5 @@
|
|||
/* pecoff.c -- Get debug data from a PE/COFF file for backtraces.
|
||||
Copyright (C) 2015-2016 Free Software Foundation, Inc.
|
||||
/* pecoff.c -- Get debug data from a PE/COFFF file for backtraces.
|
||||
Copyright (C) 2015-2018 Free Software Foundation, Inc.
|
||||
Adapted from elf.c by Tristan Gingold, AdaCore.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -890,7 +890,8 @@ coff_add (struct backtrace_state *state, int descriptor,
|
|||
sections. */
|
||||
|
||||
int
|
||||
backtrace_initialize (struct backtrace_state *state, int descriptor,
|
||||
backtrace_initialize (struct backtrace_state *state,
|
||||
const char *filename ATTRIBUTE_UNUSED, int descriptor,
|
||||
backtrace_error_callback error_callback,
|
||||
void *data, fileline *fileline_fn)
|
||||
{
|
||||
|
|
2
posix.c
2
posix.c
|
@ -1,5 +1,5 @@
|
|||
/* posix.c -- POSIX file I/O routines for the backtrace library.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
print.c
2
print.c
|
@ -1,5 +1,5 @@
|
|||
/* print.c -- Print the current backtrace.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
read.c
2
read.c
|
@ -1,5 +1,5 @@
|
|||
/* read.c -- File views without mmap.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
simple.c
2
simple.c
|
@ -1,5 +1,5 @@
|
|||
/* simple.c -- The backtrace_simple function.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
sort.c
2
sort.c
|
@ -1,5 +1,5 @@
|
|||
/* sort.c -- Sort without allocating memory
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
state.c
2
state.c
|
@ -1,5 +1,5 @@
|
|||
/* state.c -- Create the backtrace state.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
stest.c
2
stest.c
|
@ -1,5 +1,5 @@
|
|||
/* stest.c -- Test for libbacktrace internal sort function
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
/* testlib.c -- test functions for libbacktrace library
|
||||
Copyright (C) 2012-2018 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 <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "filenames.h"
|
||||
|
||||
#include "backtrace.h"
|
||||
|
||||
#include "testlib.h"
|
||||
|
||||
/* The backtrace state. */
|
||||
|
||||
void *state;
|
||||
|
||||
/* The number of failures. */
|
||||
|
||||
int failures;
|
||||
|
||||
/* Return the base name in a path. */
|
||||
|
||||
const char *
|
||||
base (const char *p)
|
||||
{
|
||||
const char *last;
|
||||
const char *s;
|
||||
|
||||
last = NULL;
|
||||
for (s = p; *s != '\0'; ++s)
|
||||
{
|
||||
if (IS_DIR_SEPARATOR (*s))
|
||||
last = s + 1;
|
||||
}
|
||||
return last != NULL ? last : p;
|
||||
}
|
||||
|
||||
/* Check an entry in a struct info array. */
|
||||
|
||||
void
|
||||
check (const char *name, int index, const struct info *all, int want_lineno,
|
||||
const char *want_function, const char *want_file, int *failed)
|
||||
{
|
||||
if (*failed)
|
||||
return;
|
||||
if (all[index].filename == NULL || all[index].function == NULL)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: missing file name or function name\n",
|
||||
name, index);
|
||||
*failed = 1;
|
||||
return;
|
||||
}
|
||||
if (strcmp (base (all[index].filename), want_file) != 0)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index,
|
||||
all[index].filename, want_file);
|
||||
*failed = 1;
|
||||
}
|
||||
if (all[index].lineno != want_lineno)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: got %d expected %d\n", name, index,
|
||||
all[index].lineno, want_lineno);
|
||||
*failed = 1;
|
||||
}
|
||||
if (strcmp (all[index].function, want_function) != 0)
|
||||
{
|
||||
fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index,
|
||||
all[index].function, want_function);
|
||||
*failed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The backtrace callback function. */
|
||||
|
||||
int
|
||||
callback_one (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||
const char *filename, int lineno, const char *function)
|
||||
{
|
||||
struct bdata *data = (struct bdata *) vdata;
|
||||
struct info *p;
|
||||
|
||||
if (data->index >= data->max)
|
||||
{
|
||||
fprintf (stderr, "callback_one: callback called too many times\n");
|
||||
data->failed = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
p = &data->all[data->index];
|
||||
if (filename == NULL)
|
||||
p->filename = NULL;
|
||||
else
|
||||
{
|
||||
p->filename = strdup (filename);
|
||||
assert (p->filename != NULL);
|
||||
}
|
||||
p->lineno = lineno;
|
||||
if (function == NULL)
|
||||
p->function = NULL;
|
||||
else
|
||||
{
|
||||
p->function = strdup (function);
|
||||
assert (p->function != NULL);
|
||||
}
|
||||
++data->index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* An error callback passed to backtrace. */
|
||||
|
||||
void
|
||||
error_callback_one (void *vdata, const char *msg, int errnum)
|
||||
{
|
||||
struct bdata *data = (struct bdata *) vdata;
|
||||
|
||||
fprintf (stderr, "%s", msg);
|
||||
if (errnum > 0)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
fprintf (stderr, "\n");
|
||||
data->failed = 1;
|
||||
}
|
||||
|
||||
/* The backtrace_simple callback function. */
|
||||
|
||||
int
|
||||
callback_two (void *vdata, uintptr_t pc)
|
||||
{
|
||||
struct sdata *data = (struct sdata *) vdata;
|
||||
|
||||
if (data->index >= data->max)
|
||||
{
|
||||
fprintf (stderr, "callback_two: callback called too many times\n");
|
||||
data->failed = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
data->addrs[data->index] = pc;
|
||||
++data->index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* An error callback passed to backtrace_simple. */
|
||||
|
||||
void
|
||||
error_callback_two (void *vdata, const char *msg, int errnum)
|
||||
{
|
||||
struct sdata *data = (struct sdata *) vdata;
|
||||
|
||||
fprintf (stderr, "%s", msg);
|
||||
if (errnum > 0)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
fprintf (stderr, "\n");
|
||||
data->failed = 1;
|
||||
}
|
||||
|
||||
/* The backtrace_syminfo callback function. */
|
||||
|
||||
void
|
||||
callback_three (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||
const char *symname, uintptr_t symval,
|
||||
uintptr_t symsize)
|
||||
{
|
||||
struct symdata *data = (struct symdata *) vdata;
|
||||
|
||||
if (symname == NULL)
|
||||
data->name = NULL;
|
||||
else
|
||||
{
|
||||
data->name = strdup (symname);
|
||||
assert (data->name != NULL);
|
||||
}
|
||||
data->val = symval;
|
||||
data->size = symsize;
|
||||
}
|
||||
|
||||
/* The backtrace_syminfo error callback function. */
|
||||
|
||||
void
|
||||
error_callback_three (void *vdata, const char *msg, int errnum)
|
||||
{
|
||||
struct symdata *data = (struct symdata *) vdata;
|
||||
|
||||
fprintf (stderr, "%s", msg);
|
||||
if (errnum > 0)
|
||||
fprintf (stderr, ": %s", strerror (errnum));
|
||||
fprintf (stderr, "\n");
|
||||
data->failed = 1;
|
||||
}
|
||||
|
||||
/* The backtrace_create_state error callback function. */
|
||||
|
||||
void
|
||||
error_callback_create (void *data 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);
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/* testlib.h -- Header for test functions for libbacktrace library
|
||||
Copyright (C) 2012-2018 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. */
|
||||
|
||||
#ifndef LIBBACKTRACE_TESTLIB_H
|
||||
#define LIBBACKTRACE_TESTLIB_H
|
||||
|
||||
/* Portable attribute syntax. Actually some of these tests probably
|
||||
won't work if the attributes are not recognized. */
|
||||
|
||||
#ifndef GCC_VERSION
|
||||
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#endif
|
||||
|
||||
#if (GCC_VERSION < 2007)
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif
|
||||
|
||||
/* Used to collect backtrace info. */
|
||||
|
||||
struct info
|
||||
{
|
||||
char *filename;
|
||||
int lineno;
|
||||
char *function;
|
||||
};
|
||||
|
||||
/* Passed to backtrace callback function. */
|
||||
|
||||
struct bdata
|
||||
{
|
||||
struct info *all;
|
||||
size_t index;
|
||||
size_t max;
|
||||
int failed;
|
||||
};
|
||||
|
||||
/* Passed to backtrace_simple callback function. */
|
||||
|
||||
struct sdata
|
||||
{
|
||||
uintptr_t *addrs;
|
||||
size_t index;
|
||||
size_t max;
|
||||
int failed;
|
||||
};
|
||||
|
||||
/* Passed to backtrace_syminfo callback function. */
|
||||
|
||||
struct symdata
|
||||
{
|
||||
const char *name;
|
||||
uintptr_t val, size;
|
||||
int failed;
|
||||
};
|
||||
|
||||
/* The backtrace state. */
|
||||
|
||||
extern void *state;
|
||||
|
||||
/* The number of failures. */
|
||||
|
||||
extern int failures;
|
||||
|
||||
extern const char *base (const char *p);
|
||||
extern void check (const char *name, int index, const struct info *all,
|
||||
int want_lineno, const char *want_function,
|
||||
const char *want_file, int *failed);
|
||||
extern int callback_one (void *, uintptr_t, const char *, int, const char *);
|
||||
extern void error_callback_one (void *, const char *, int);
|
||||
extern int callback_two (void *, uintptr_t);
|
||||
extern void error_callback_two (void *, const char *, int);
|
||||
extern void callback_three (void *, uintptr_t, const char *, uintptr_t,
|
||||
uintptr_t);
|
||||
extern void error_callback_three (void *, const char *, int);
|
||||
extern void error_callback_create (void *, const char *, int);
|
||||
|
||||
#endif /* !defined(LIBBACKTRACE_TESTLIB_H) */
|
|
@ -0,0 +1,161 @@
|
|||
/* ttest.c -- Test for libbacktrace library
|
||||
Copyright (C) 2017-2018 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. */
|
||||
|
||||
/* Test using the libbacktrace library from multiple threads. */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "filenames.h"
|
||||
|
||||
#include "backtrace.h"
|
||||
#include "backtrace-supported.h"
|
||||
|
||||
#include "testlib.h"
|
||||
|
||||
static int f2 (int) __attribute__ ((noinline));
|
||||
static int f3 (int, int) __attribute__ ((noinline));
|
||||
|
||||
/* Test that a simple backtrace works. This is called via
|
||||
pthread_create. It returns the number of failures, as void *. */
|
||||
|
||||
static void *
|
||||
test1_thread (void *arg ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* Returning a value here and elsewhere avoids a tailcall which
|
||||
would mess up the backtrace. */
|
||||
return (void *) (uintptr_t) (f2 (__LINE__) - 2);
|
||||
}
|
||||
|
||||
static int
|
||||
f2 (int f1line)
|
||||
{
|
||||
return f3 (f1line, __LINE__) + 2;
|
||||
}
|
||||
|
||||
static int
|
||||
f3 (int f1line, int f2line)
|
||||
{
|
||||
struct info all[20];
|
||||
struct bdata data;
|
||||
int f3line;
|
||||
int i;
|
||||
|
||||
data.all = &all[0];
|
||||
data.index = 0;
|
||||
data.max = 20;
|
||||
data.failed = 0;
|
||||
|
||||
f3line = __LINE__ + 1;
|
||||
i = backtrace_full (state, 0, callback_one, 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;
|
||||
}
|
||||
|
||||
check ("test1", 0, all, f3line, "f3", "ttest.c", &data.failed);
|
||||
check ("test1", 1, all, f2line, "f2", "ttest.c", &data.failed);
|
||||
check ("test1", 2, all, f1line, "test1_thread", "ttest.c", &data.failed);
|
||||
|
||||
return data.failed;
|
||||
}
|
||||
|
||||
/* Run the test with 10 threads simultaneously. */
|
||||
|
||||
#define THREAD_COUNT 10
|
||||
|
||||
static void test1 (void) __attribute__ ((unused));
|
||||
|
||||
static void
|
||||
test1 (void)
|
||||
{
|
||||
pthread_t atid[THREAD_COUNT];
|
||||
int i;
|
||||
int errnum;
|
||||
int this_fail;
|
||||
void *ret;
|
||||
|
||||
for (i = 0; i < THREAD_COUNT; i++)
|
||||
{
|
||||
errnum = pthread_create (&atid[i], NULL, test1_thread, NULL);
|
||||
if (errnum != 0)
|
||||
{
|
||||
fprintf (stderr, "pthread_create %d: %s\n", i, strerror (errnum));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
this_fail = 0;
|
||||
for (i = 0; i < THREAD_COUNT; i++)
|
||||
{
|
||||
errnum = pthread_join (atid[i], &ret);
|
||||
if (errnum != 0)
|
||||
{
|
||||
fprintf (stderr, "pthread_join %d: %s\n", i, strerror (errnum));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
this_fail += (int) (uintptr_t) ret;
|
||||
}
|
||||
|
||||
printf ("%s: threaded backtrace_full noinline\n", this_fail > 0 ? "FAIL" : "PASS");
|
||||
|
||||
failures += this_fail;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||
error_callback_create, NULL);
|
||||
|
||||
#if BACKTRACE_SUPPORTED
|
||||
#if BACKTRACE_SUPPORTS_THREADS
|
||||
test1 ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* unknown.c -- used when backtrace configury does not know file format.
|
||||
Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -54,6 +54,7 @@ unknown_fileline (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
|||
|
||||
int
|
||||
backtrace_initialize (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||
const char *filename ATTRIBUTE_UNUSED,
|
||||
int descriptor ATTRIBUTE_UNUSED,
|
||||
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||
void *data ATTRIBUTE_UNUSED, fileline *fileline_fn)
|
||||
|
|
|
@ -0,0 +1,474 @@
|
|||
/* ztest.c -- Test for libbacktrace inflate code.
|
||||
Copyright (C) 2017-2018 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_ZLIB
|
||||
#include <zlib.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 ZLIB_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
|
||||
#else
|
||||
#define ZLIB_CLOCK_GETTIME_ARG CLOCK_REALTIME
|
||||
#endif
|
||||
|
||||
/* Some tests for the local zlib inflation code. */
|
||||
|
||||
struct zlib_test
|
||||
{
|
||||
const char *name;
|
||||
const char *uncompressed;
|
||||
const char *compressed;
|
||||
size_t compressed_len;
|
||||
};
|
||||
|
||||
/* Error callback. */
|
||||
|
||||
static void
|
||||
error_callback_compress (void *vdata, 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 zlib_test tests[] =
|
||||
{
|
||||
{
|
||||
"empty",
|
||||
"",
|
||||
"\x78\x9c\x03\x00\x00\x00\x00\x01",
|
||||
8,
|
||||
},
|
||||
{
|
||||
"hello",
|
||||
"hello, world\n",
|
||||
("\x78\x9c\xca\x48\xcd\xc9\xc9\xd7\x51\x28\xcf"
|
||||
"\x2f\xca\x49\xe1\x02\x04\x00\x00\xff\xff\x21\xe7\x04\x93"),
|
||||
25,
|
||||
},
|
||||
{
|
||||
"goodbye",
|
||||
"goodbye, world",
|
||||
("\x78\x9c\x4b\xcf\xcf\x4f\x49\xaa"
|
||||
"\x4c\xd5\x51\x28\xcf\x2f\xca\x49"
|
||||
"\x01\x00\x28\xa5\x05\x5e"),
|
||||
22,
|
||||
}
|
||||
};
|
||||
|
||||
/* 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)
|
||||
{
|
||||
char *p;
|
||||
size_t v;
|
||||
size_t j;
|
||||
unsigned char *uncompressed;
|
||||
size_t uncompressed_len;
|
||||
|
||||
p = malloc (12 + tests[i].compressed_len);
|
||||
memcpy (p, "ZLIB", 4);
|
||||
v = strlen (tests[i].uncompressed);
|
||||
for (j = 0; j < 8; ++j)
|
||||
p[j + 4] = (v >> ((7 - j) * 8)) & 0xff;
|
||||
memcpy (p + 12, tests[i].compressed, tests[i].compressed_len);
|
||||
uncompressed = NULL;
|
||||
uncompressed_len = 0;
|
||||
if (!backtrace_uncompress_zdebug (state, (unsigned char *) p,
|
||||
tests[i].compressed_len + 12,
|
||||
error_callback_compress, NULL,
|
||||
&uncompressed, &uncompressed_len))
|
||||
{
|
||||
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
|
||||
++failures;
|
||||
}
|
||||
else
|
||||
{
|
||||
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: inflate %s\n", tests[i].name);
|
||||
|
||||
backtrace_free (state, uncompressed, uncompressed_len,
|
||||
error_callback_compress, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
|
||||
/* 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)
|
||||
{
|
||||
#ifdef HAVE_ZLIB
|
||||
unsigned char *orig_buf;
|
||||
size_t orig_bufsize;
|
||||
size_t i;
|
||||
char *compressed_buf;
|
||||
size_t compressed_bufsize;
|
||||
unsigned long compress_sizearg;
|
||||
unsigned char *uncompressed_buf;
|
||||
size_t uncompressed_bufsize;
|
||||
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[] = {
|
||||
"Mark.Twain-Tom.Sawyer.txt",
|
||||
"../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.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 = rbuf;
|
||||
orig_bufsize = got;
|
||||
break;
|
||||
}
|
||||
free (rbuf);
|
||||
}
|
||||
|
||||
if (orig_buf == NULL)
|
||||
{
|
||||
/* We couldn't find an input file. */
|
||||
printf ("UNSUPPORTED: inflate large\n");
|
||||
return;
|
||||
}
|
||||
|
||||
compressed_bufsize = compressBound (orig_bufsize) + 12;
|
||||
compressed_buf = malloc (compressed_bufsize);
|
||||
if (compressed_buf == NULL)
|
||||
{
|
||||
perror ("malloc");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
compress_sizearg = compressed_bufsize - 12;
|
||||
r = compress (compressed_buf + 12, &compress_sizearg,
|
||||
orig_buf, orig_bufsize);
|
||||
if (r != Z_OK)
|
||||
{
|
||||
fprintf (stderr, "zlib compress failed: %d\n", r);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
compressed_bufsize = compress_sizearg + 12;
|
||||
|
||||
/* Prepare the header that our library expects. */
|
||||
memcpy (compressed_buf, "ZLIB", 4);
|
||||
for (i = 0; i < 8; ++i)
|
||||
compressed_buf[i + 4] = (orig_bufsize >> ((7 - i) * 8)) & 0xff;
|
||||
|
||||
uncompressed_buf = malloc (orig_bufsize);
|
||||
if (uncompressed_buf == NULL)
|
||||
{
|
||||
perror ("malloc");
|
||||
goto fail;
|
||||
}
|
||||
uncompressed_bufsize = orig_bufsize;
|
||||
|
||||
if (!backtrace_uncompress_zdebug (state, compressed_buf, compressed_bufsize,
|
||||
error_callback_compress, NULL,
|
||||
&uncompressed_buf, &uncompressed_bufsize))
|
||||
{
|
||||
fprintf (stderr, "inflate large: backtrace_uncompress_zdebug failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (uncompressed_bufsize != orig_bufsize)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"inflate 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, "inflate large: uncompressed data mismatch\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
printf ("PASS: inflate large\n");
|
||||
|
||||
for (i = 0; i < trials; ++i)
|
||||
{
|
||||
unsigned long uncompress_sizearg;
|
||||
|
||||
cid = ZLIB_CLOCK_GETTIME_ARG;
|
||||
if (clock_gettime (cid, &ts1) < 0)
|
||||
{
|
||||
if (errno == EINVAL)
|
||||
return;
|
||||
perror ("clock_gettime");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!backtrace_uncompress_zdebug (state, compressed_buf,
|
||||
compressed_bufsize,
|
||||
error_callback_compress, NULL,
|
||||
&uncompressed_buf,
|
||||
&uncompressed_bufsize))
|
||||
{
|
||||
fprintf (stderr,
|
||||
("inflate large: "
|
||||
"benchmark backtrace_uncompress_zdebug 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;
|
||||
}
|
||||
|
||||
uncompress_sizearg = uncompressed_bufsize;
|
||||
r = uncompress (uncompressed_buf, &uncompress_sizearg,
|
||||
compressed_buf + 12, compressed_bufsize - 12);
|
||||
|
||||
if (clock_gettime (cid, &ts2) < 0)
|
||||
{
|
||||
perror ("clock_gettime");
|
||||
return;
|
||||
}
|
||||
|
||||
if (r != Z_OK)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"inflate large: benchmark zlib uncompress failed: %d\n",
|
||||
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 ("zlib : %zu ns\n", ztime);
|
||||
printf ("ratio : %g\n", (double) ztime / (double) ctime);
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
printf ("FAIL: inflate 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_ZLIB */
|
||||
|
||||
printf ("UNSUPPORTED: inflate large\n");
|
||||
|
||||
#endif /* !HAVE_ZLIB */
|
||||
}
|
||||
|
||||
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…
Reference in New Issue