Commit 559ab7ca by Ian Lance Taylor

libbacktrace: update to current version from GCC trunk

This adds DWARF 5 support as well as an enhanced testsuite. Patch assembled by Than McIntosh.
parent 5a99ff7f
# Makefile.am -- Backtrace Makefile. # Makefile.am -- Backtrace Makefile.
# Copyright (C) 2012-2018 Free Software Foundation, Inc. # Copyright (C) 2012-2019 Free Software Foundation, Inc.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
ACLOCAL_AMFLAGS = -I config ACLOCAL_AMFLAGS = -I config
AM_CPPFLAGS =
AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
include_HEADERS = backtrace.h backtrace-supported.h include_HEADERS = backtrace.h backtrace-supported.h
...@@ -83,46 +85,240 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) ...@@ -83,46 +85,240 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
# Testsuite. # Testsuite.
# Add test to this variable, if you want it to be build.
check_PROGRAMS = check_PROGRAMS =
CLEANFILES =
TESTS = $(check_PROGRAMS) # Add test to this variable, if you want it to be run.
TESTS =
# Add test to this variable, if you want it to be build and run.
BUILDTESTS =
if NATIVE if NATIVE
check_LTLIBRARIES = libbacktrace_alloc.la
libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD)
check_LTLIBRARIES += libbacktrace_noformat.la
libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
if HAVE_ELF
if HAVE_OBJCOPY_DEBUGLINK
TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/
check_LTLIBRARIES += libbacktrace_elf_for_test.la
libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES)
libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
$(VIEW_FILE) $(ALLOC_FILE)
elf_for_test.c: elf.c
SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
$(SED) "s%$$SEARCH%$$REPLACE%" \
$< \
> $@.tmp
mv $@.tmp $@
endif HAVE_OBJCOPY_DEBUGLINK
endif HAVE_ELF
elf_%.c: elf.c
SEARCH='#error "Unknown BACKTRACE_ELF_SIZE"'; \
REPLACE='#undef BACKTRACE_ELF_SIZE\
#define BACKTRACE_ELF_SIZE'; \
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
$< \
> $@.tmp
mv $@.tmp $@
xcoff_%.c: xcoff.c
SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
REPLACE='#undef BACKTRACE_XCOFF_SIZE\
#define BACKTRACE_XCOFF_SIZE'; \
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
$< \
> $@.tmp
mv $@.tmp $@
test_elf_32_SOURCES = test_format.c testlib.c
test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
BUILDTESTS += test_elf_32
test_elf_64_SOURCES = test_format.c testlib.c
test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
BUILDTESTS += test_elf_64
test_xcoff_32_SOURCES = test_format.c testlib.c
test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
BUILDTESTS += test_xcoff_32
test_xcoff_64_SOURCES = test_format.c testlib.c
test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
BUILDTESTS += test_xcoff_64
test_pecoff_SOURCES = test_format.c testlib.c
test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
BUILDTESTS += test_pecoff
test_unknown_SOURCES = test_format.c testlib.c
test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
BUILDTESTS += test_unknown
unittest_SOURCES = unittest.c testlib.c
unittest_LDADD = libbacktrace.la
BUILDTESTS += unittest
unittest_alloc_SOURCES = $(unittest_SOURCES)
unittest_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += unittest_alloc
check_LTLIBRARIES += libbacktrace_instrumented_alloc.la
libbacktrace_instrumented_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
libbacktrace_instrumented_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) \
read.lo instrumented_alloc.lo
libbacktrace_instrumented_alloc_la_DEPENDENCIES = \
$(libbacktrace_instrumented_alloc_la_LIBADD)
instrumented_alloc.lo: alloc.c
allocfail_SOURCES = allocfail.c testlib.c
allocfail_LDADD = libbacktrace_instrumented_alloc.la
check_PROGRAMS += allocfail
allocfail.sh: allocfail
TESTS += allocfail.sh
if HAVE_ELF
if HAVE_OBJCOPY_DEBUGLINK
b2test_SOURCES = $(btest_SOURCES)
b2test_CFLAGS = $(btest_CFLAGS)
b2test_LDFLAGS = -Wl,--build-id
b2test_LDADD = libbacktrace_elf_for_test.la
check_PROGRAMS += b2test
TESTS += b2test_buildid
if HAVE_DWZ
b3test_SOURCES = $(btest_SOURCES)
b3test_CFLAGS = $(btest_CFLAGS)
b3test_LDFLAGS = -Wl,--build-id
b3test_LDADD = libbacktrace_elf_for_test.la
check_PROGRAMS += b3test
TESTS += b3test_dwz_buildid
endif HAVE_DWZ
endif HAVE_OBJCOPY_DEBUGLINK
endif HAVE_ELF
btest_SOURCES = btest.c testlib.c btest_SOURCES = btest.c testlib.c
btest_CFLAGS = $(AM_CFLAGS) -g -O btest_CFLAGS = $(AM_CFLAGS) -g -O
btest_LDADD = libbacktrace.la btest_LDADD = libbacktrace.la
check_PROGRAMS += btest BUILDTESTS += btest
if HAVE_ELF
btest_lto_SOURCES = btest.c testlib.c
btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto
btest_lto_LDADD = libbacktrace.la
BUILDTESTS += btest_lto
endif HAVE_ELF
btest_alloc_SOURCES = $(btest_SOURCES)
btest_alloc_CFLAGS = $(btest_CFLAGS)
btest_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += btest_alloc
if HAVE_DWZ
btest_static_SOURCES = btest.c testlib.c %_dwz: %
btest_static_CFLAGS = $(AM_CFLAGS) -g -O rm -f $@ $@_common.debug
btest_static_LDADD = libbacktrace.la cp $< $@_1
btest_static_LDFLAGS = -static-libtool-libs cp $< $@_2
$(DWZ) -m $@_common.debug $@_1 $@_2
rm -f $@_2
mv $@_1 $@
check_PROGRAMS += btest_static TESTS += btest_dwz
if HAVE_OBJCOPY_DEBUGLINK
TESTS += btest_dwz_gnudebuglink
endif HAVE_OBJCOPY_DEBUGLINK
endif HAVE_DWZ
stest_SOURCES = stest.c stest_SOURCES = stest.c
stest_LDADD = libbacktrace.la stest_LDADD = libbacktrace.la
check_PROGRAMS += stest BUILDTESTS += stest
stest_alloc_SOURCES = $(stest_SOURCES)
stest_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += stest_alloc
if HAVE_ELF
ztest_SOURCES = ztest.c testlib.c ztest_SOURCES = ztest.c testlib.c
ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\" ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
ztest_LDADD = libbacktrace.la ztest_LDADD = libbacktrace.la
ztest_alloc_LDADD = libbacktrace_alloc.la
if HAVE_ZLIB if HAVE_ZLIB
ztest_LDADD += -lz ztest_LDADD += -lz
ztest_alloc_LDADD += -lz
endif endif
ztest_LDADD += $(CLOCK_GETTIME_LINK) ztest_LDADD += $(CLOCK_GETTIME_LINK)
ztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
BUILDTESTS += ztest
ztest_alloc_SOURCES = $(ztest_SOURCES)
ztest_alloc_CFLAGS = $(ztest_CFLAGS)
check_PROGRAMS += ztest BUILDTESTS += ztest_alloc
endif HAVE_ELF
edtest_SOURCES = edtest.c edtest2_build.c testlib.c edtest_SOURCES = edtest.c edtest2_build.c testlib.c
edtest_LDADD = libbacktrace.la edtest_LDADD = libbacktrace.la
check_PROGRAMS += edtest BUILDTESTS += edtest
edtest_alloc_SOURCES = $(edtest_SOURCES)
edtest_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += edtest_alloc
edtest2_build.c: gen_edtest2_build; @true edtest2_build.c: gen_edtest2_build; @true
gen_edtest2_build: $(srcdir)/edtest2.c gen_edtest2_build: $(srcdir)/edtest2.c
...@@ -130,30 +326,38 @@ gen_edtest2_build: $(srcdir)/edtest2.c ...@@ -130,30 +326,38 @@ gen_edtest2_build: $(srcdir)/edtest2.c
$(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c $(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c
echo timestamp > $@ echo timestamp > $@
CLEANFILES += edtest2_build.c gen_edtest2_build
if HAVE_PTHREAD if HAVE_PTHREAD
check_PROGRAMS += ttest BUILDTESTS += ttest
ttest_SOURCES = ttest.c testlib.c ttest_SOURCES = ttest.c testlib.c
ttest_CFLAGS = $(AM_CFLAGS) -pthread ttest_CFLAGS = $(AM_CFLAGS) -pthread
ttest_LDADD = libbacktrace.la ttest_LDADD = libbacktrace.la
BUILDTESTS += ttest_alloc
ttest_alloc_SOURCES = $(ttest_SOURCES)
ttest_alloc_CFLAGS = $(ttest_CFLAGS)
ttest_alloc_LDADD = libbacktrace_alloc.la
endif HAVE_PTHREAD endif HAVE_PTHREAD
if HAVE_OBJCOPY_DEBUGLINK if HAVE_OBJCOPY_DEBUGLINK
TESTS += dtest TESTS += btest_gnudebuglink
dtest: btest_static %_gnudebuglink: %
$(OBJCOPY) --only-keep-debug btest_static btest.debug $(OBJCOPY) --only-keep-debug $< $@.debug
$(OBJCOPY) --strip-debug --add-gnu-debuglink=btest.debug btest_static dtest $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
CLEANFILES += dtest btest.debug
endif HAVE_OBJCOPY_DEBUGLINK endif HAVE_OBJCOPY_DEBUGLINK
%_buildid: %
./install-debuginfo-for-buildid.sh \
"$(TEST_BUILD_ID_DIR)" \
$<
$(OBJCOPY) --strip-debug $< $@
if HAVE_COMPRESSED_DEBUG if HAVE_COMPRESSED_DEBUG
ctestg_SOURCES = btest.c testlib.c ctestg_SOURCES = btest.c testlib.c
...@@ -166,12 +370,49 @@ ctesta_CFLAGS = $(AM_CFLAGS) -g ...@@ -166,12 +370,49 @@ ctesta_CFLAGS = $(AM_CFLAGS) -g
ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
ctesta_LDADD = libbacktrace.la ctesta_LDADD = libbacktrace.la
check_PROGRAMS += ctestg ctesta BUILDTESTS += ctestg ctesta
ctestg_alloc_SOURCES = $(ctestg_SOURCES)
ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
ctestg_alloc_LDADD = libbacktrace_alloc.la
ctesta_alloc_SOURCES = $(ctesta_SOURCES)
ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
ctesta_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += ctestg_alloc ctesta_alloc
endif
if HAVE_DWARF5
dwarf5_SOURCES = btest.c testlib.c
dwarf5_CFLAGS = $(AM_CFLAGS) -gdwarf-5
dwarf5_LDADD = libbacktrace.la
BUILDTESTS += dwarf5
dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
dwarf5_alloc_LDADD = libbacktrace_alloc.la
BUILDTESTS += dwarf5_alloc
endif endif
endif NATIVE endif NATIVE
check_PROGRAMS += $(BUILDTESTS)
TESTS += $(BUILDTESTS)
CLEANFILES = $(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build
clean-local:
-rm -rf usr
# We can't use automake's automatic dependency tracking, because it # We can't use automake's automatic dependency tracking, because it
# breaks when using bootstrap-lean. Automatic dependency tracking # breaks when using bootstrap-lean. Automatic dependency tracking
# with GCC bootstrap will cause some of the objects to depend on # with GCC bootstrap will cause some of the objects to depend on
...@@ -186,7 +427,7 @@ endif NATIVE ...@@ -186,7 +427,7 @@ endif NATIVE
alloc.lo: config.h backtrace.h internal.h alloc.lo: config.h backtrace.h internal.h
backtrace.lo: config.h backtrace.h internal.h backtrace.lo: config.h backtrace.h internal.h
btest.lo: backtrace.h backtrace-supported.h filenames.h btest.lo: filenames.h backtrace.h backtrace-supported.h
dwarf.lo: config.h filenames.h backtrace.h internal.h dwarf.lo: config.h filenames.h backtrace.h internal.h
elf.lo: config.h backtrace.h internal.h elf.lo: config.h backtrace.h internal.h
fileline.lo: config.h backtrace.h internal.h fileline.lo: config.h backtrace.h internal.h
......
/* alloc.c -- Memory allocation without mmap. /* alloc.c -- Memory allocation without mmap.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -145,12 +145,23 @@ backtrace_vector_release (struct backtrace_state *state ATTRIBUTE_UNUSED, ...@@ -145,12 +145,23 @@ backtrace_vector_release (struct backtrace_state *state ATTRIBUTE_UNUSED,
backtrace_error_callback error_callback, backtrace_error_callback error_callback,
void *data) void *data)
{ {
vec->alc = 0;
if (vec->size == 0)
{
/* As of C17, realloc with size 0 is marked as an obsolescent feature, use
free instead. */
free (vec->base);
vec->base = NULL;
return 1;
}
vec->base = realloc (vec->base, vec->size); vec->base = realloc (vec->base, vec->size);
if (vec->base == NULL) if (vec->base == NULL)
{ {
error_callback (data, "realloc", errno); error_callback (data, "realloc", errno);
return 0; return 0;
} }
vec->alc = 0;
return 1; return 1;
} }
/* allocfail.c -- Test for libbacktrace library
Copyright (C) 2018-2019 Free Software Foundation, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
(3) The name of the author may not be used to
endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "filenames.h"
#include "backtrace.h"
#include "backtrace-supported.h"
#include "testlib.h"
extern uint64_t get_nr_allocs (void);
extern void set_fail_at_alloc (uint64_t);
extern int at_fail_alloc_p (void);
static int test1 (void) __attribute__ ((noinline, unused));
static int f2 (int) __attribute__ ((noinline));
static int f3 (int, int) __attribute__ ((noinline));
static unsigned callback_errors = 0;
static void
error_callback_full (void *vdata ATTRIBUTE_UNUSED,
const char *msg ATTRIBUTE_UNUSED,
int errnum ATTRIBUTE_UNUSED)
{
if (at_fail_alloc_p ())
{
set_fail_at_alloc (0);
return;
}
callback_errors++;
}
static int
callback_full (void *vdata ATTRIBUTE_UNUSED, uintptr_t pc ATTRIBUTE_UNUSED,
const char *filename ATTRIBUTE_UNUSED,
int lineno ATTRIBUTE_UNUSED,
const char *function ATTRIBUTE_UNUSED)
{
return 0;
}
static int
test1 (void)
{
return f2 (__LINE__) + 1;
}
static int
f2 (int f1line)
{
return f3 (f1line, __LINE__) + 2;
}
static int
f3 (int f1line ATTRIBUTE_UNUSED, int f2line ATTRIBUTE_UNUSED)
{
int i;
i = backtrace_full (state, 0, callback_full, error_callback_full, NULL);
if (i != 0)
{
fprintf (stderr, "test1: unexpected return value %d\n", i);
++failures;
}
if (callback_errors)
++failures;
return failures;
}
/* Run all the tests. */
int
main (int argc, char **argv)
{
uint64_t fail_at = 0;
if (argc == 2)
{
fail_at = atoi (argv[1]);
set_fail_at_alloc (fail_at);
}
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_full, NULL);
if (state == NULL)
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
#if BACKTRACE_SUPPORTED
test1 ();
#endif
if (argc == 1)
fprintf (stderr, "%llu\n", (long long unsigned) get_nr_allocs ());
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
}
#!/bin/sh
# allocfail.sh -- Test for libbacktrace library.
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# (1) Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# (2) Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# (3) The name of the author may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
set -e
if [ ! -f ./allocfail ]; then
# Hard failure.
exit 99
fi
allocs=$(./allocfail 2>&1)
if [ "$allocs" = "" ]; then
# Hard failure.
exit 99
fi
# This generates the following output:
# ...
# $ allocfail.sh
# allocs: 80495
# Status changed to 0 at 1
# Status changed to 1 at 3
# Status changed to 0 at 11
# Status changed to 1 at 12
# Status changed to 0 at 845
# ...
#
# We have status 0 for an allocation failure at:
# - 1 because backtrace_create_state handles failure robustly
# - 2 because the fail switches backtrace_full to !can_alloc mode.
# - 11 because failure of elf_open_debugfile_by_buildid does not generate an
# error callback beyond the one for the allocation failure itself.
echo "allocs: $allocs"
step=1
i=1
passes=0
prev_status=-1
while [ $i -le $allocs ]; do
if ./allocfail $i >/dev/null 2>&1; status=$?; then
true
fi
if [ $status -gt 1 ]; then
echo "Unallowed fail found: $i"
# Failure.
exit 1
fi
# The test-case would run too long if we would excercise all allocs.
# So, run with step 1 initially, and increase the step once we have 10
# subsequent passes, and drop back to step 1 once we encounter another
# failure. This takes ~2.6 seconds on an i7-6600U CPU @ 2.60GHz.
if [ $status -eq 0 ]; then
passes=$(($passes + 1))
if [ $passes -ge 10 ]; then
step=$((step * 10))
passes=0
fi
elif [ $status -eq 1 ]; then
passes=0
step=1
fi
if [ $status -ne $prev_status ]; then
echo "Status changed to $status at $i"
fi
prev_status=$status
i=$(($i + $step))
done
# Success.
exit 0
/* atomic.c -- Support for atomic functions if not present. /* atomic.c -- Support for atomic functions if not present.
Copyright (C) 2013-2018 Free Software Foundation, Inc. Copyright (C) 2013-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* backtrace-supported.h.in -- Whether stack backtrace is supported. /* backtrace-supported.h.in -- Whether stack backtrace is supported.
Copyright (C) 2012-2016 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* backtrace.c -- Entry point for stack backtrace library. /* backtrace.c -- Entry point for stack backtrace library.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -98,7 +98,7 @@ unwind (struct _Unwind_Context *context, void *vdata) ...@@ -98,7 +98,7 @@ unwind (struct _Unwind_Context *context, void *vdata)
/* Get a stack backtrace. */ /* Get a stack backtrace. */
int int __attribute__((noinline))
backtrace_full (struct backtrace_state *state, int skip, backtrace_full (struct backtrace_state *state, int skip,
backtrace_full_callback callback, backtrace_full_callback callback,
backtrace_error_callback error_callback, void *data) backtrace_error_callback error_callback, void *data)
......
/* backtrace.h -- Public header file for stack backtrace library. /* backtrace.h -- Public header file for stack backtrace library.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -75,7 +75,13 @@ typedef void (*backtrace_error_callback) (void *data, const char *msg, ...@@ -75,7 +75,13 @@ typedef void (*backtrace_error_callback) (void *data, const char *msg,
use appropriate atomic operations. If THREADED is zero the state use appropriate atomic operations. If THREADED is zero the state
may only be accessed by one thread at a time. This returns a state may only be accessed by one thread at a time. This returns a state
pointer on success, NULL on error. If an error occurs, this will pointer on success, NULL on error. If an error occurs, this will
call the ERROR_CALLBACK routine. */ call the ERROR_CALLBACK routine.
Calling this function allocates resources that cannot be freed.
There is no backtrace_free_state function. The state is used to
cache information that is expensive to recompute. Programs are
expected to call this function at most once and to save the return
value for all later calls to backtrace functions. */
extern struct backtrace_state *backtrace_create_state ( extern struct backtrace_state *backtrace_create_state (
const char *filename, int threaded, const char *filename, int threaded,
......
/* btest.c -- Test for libbacktrace library /* btest.c -- Test for libbacktrace library
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -48,9 +48,9 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -48,9 +48,9 @@ POSSIBILITY OF SUCH DAMAGE. */
/* Test the backtrace function with non-inlined functions. */ /* Test the backtrace function with non-inlined functions. */
static int test1 (void) __attribute__ ((noinline, unused)); static int test1 (void) __attribute__ ((noinline, noclone, unused));
static int f2 (int) __attribute__ ((noinline)); static int f2 (int) __attribute__ ((noinline, noclone));
static int f3 (int, int) __attribute__ ((noinline)); static int f3 (int, int) __attribute__ ((noinline, noclone));
static int static int
test1 (void) test1 (void)
...@@ -162,9 +162,9 @@ f13 (int f1line, int f2line) ...@@ -162,9 +162,9 @@ f13 (int f1line, int f2line)
/* Test the backtrace_simple function with non-inlined functions. */ /* Test the backtrace_simple function with non-inlined functions. */
static int test3 (void) __attribute__ ((noinline, unused)); static int test3 (void) __attribute__ ((noinline, noclone, unused));
static int f22 (int) __attribute__ ((noinline)); static int f22 (int) __attribute__ ((noinline, noclone));
static int f23 (int, int) __attribute__ ((noinline)); static int f23 (int, int) __attribute__ ((noinline, noclone));
static int static int
test3 (void) test3 (void)
...@@ -423,7 +423,8 @@ test5 (void) ...@@ -423,7 +423,8 @@ test5 (void)
fprintf (stderr, "test5: NULL syminfo name\n"); fprintf (stderr, "test5: NULL syminfo name\n");
symdata.failed = 1; symdata.failed = 1;
} }
else if (strcmp (symdata.name, "global") != 0) else if (!(strncmp (symdata.name, "global", 6) == 0
&& (symdata.name[6] == '\0'|| symdata.name[6] == '.')))
{ {
fprintf (stderr, fprintf (stderr,
"test5: unexpected syminfo name got %s expected %s\n", "test5: unexpected syminfo name got %s expected %s\n",
......
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2016-01-11.22; # UTC
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# 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 2, 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/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
...@@ -34,9 +34,6 @@ ...@@ -34,9 +34,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <link.h> header file. */ /* Define to 1 if you have the <link.h> header file. */
#undef HAVE_LINK_H #undef HAVE_LINK_H
...@@ -132,6 +129,11 @@ ...@@ -132,6 +129,11 @@
#endif #endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */ /* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS #undef _FILE_OFFSET_BITS
......
dnl ----------------------------------------------------------------------
dnl This whole bit snagged from libstdc++-v3.
dnl
dnl GCC_ENABLE
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
dnl
dnl See docs/html/17_intro/configury.html#enable for documentation.
dnl
AC_DEFUN([GCC_ENABLE],[dnl
m4_define([_g_switch],[--enable-$1])dnl
m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
AC_ARG_ENABLE($1,_g_help,
m4_bmatch([$5],
[^permit ],
[[
case "$enableval" in
m4_bpatsubst([$5],[permit ])) ;;
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
dnl Idea for future: generate a URL pointing to
dnl "onlinedocs/configopts.html#whatever"
esac
]],
[^$],
[[
case "$enableval" in
yes|no) ;;
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
esac
]],
[[$5]]),
[enable_]m4_bpatsubst([$1],-,_)[=][$2])
m4_undefine([_g_switch])dnl
m4_undefine([_g_help])dnl
])
# -*- Autoconf -*-
# Copyright (C) 2003, 2009 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, 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; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# serial 1
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Helper functions for option handling. -*- Autoconf -*- # Helper functions for option handling. -*- Autoconf -*-
# #
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# Written by Gary V. Vaughan, 2004 # Written by Gary V. Vaughan, 2004
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
...@@ -125,7 +126,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll], ...@@ -125,7 +126,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes [enable_win32_dll=yes
case $host in case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32*) *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false) AC_CHECK_TOOL(OBJDUMP, objdump, false)
...@@ -133,13 +134,13 @@ case $host in ...@@ -133,13 +134,13 @@ case $host in
esac esac
test -z "$AS" && AS=as test -z "$AS" && AS=as
_LT_DECL([], [AS], [0], [Assembler program])dnl _LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll ])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL], AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
......
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
# #
# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004 # Written by Gary V. Vaughan, 2004
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# serial 5 ltsugar.m4 # serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define. # This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
...@@ -63,14 +63,14 @@ m4_define([lt_append], ...@@ -63,14 +63,14 @@ m4_define([lt_append],
# Produce a SEP delimited list of all paired combinations of elements of # Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn. # has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine], m4_define([lt_combine],
[m4_if([$2], [], [], [m4_if(m4_eval([$# > 3]), [1],
[m4_if([$4], [], [], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[lt_join(m4_quote(m4_default([$1], [[, ]])), [[m4_foreach([_Lt_prefix], [$2],
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2], [m4_foreach([_Lt_suffix],
[m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]), ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
# Generated from ltversion.in. # Generated from ltversion.in.
# serial 2976 ltversion.m4 # serial 3134 ltversion.m4
# This file is part of GNU Libtool # This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.2.4]) m4_define([LT_PACKAGE_VERSION], [2.2.7a])
m4_define([LT_PACKAGE_REVISION], [1.2976]) m4_define([LT_PACKAGE_REVISION], [1.3134])
AC_DEFUN([LTVERSION_VERSION], AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.2.4' [macro_version='2.2.7a'
macro_revision='1.2976' macro_revision='1.3134'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0) _LT_DECL(, macro_revision, 0)
]) ])
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
# #
# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004. # Written by Scott James Remnant, 2004.
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
...@@ -77,7 +77,6 @@ m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) ...@@ -77,7 +77,6 @@ m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
...@@ -90,3 +89,10 @@ m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) ...@@ -90,3 +89,10 @@ m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
## -*- Autoconf -*-
# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 6
# AM_ENABLE_MULTILIB([MAKEFILE], [REL-TO-TOP-SRCDIR])
# ---------------------------------------------------
# Add --enable-multilib to configure.
AC_DEFUN([AM_ENABLE_MULTILIB],
[# Default to --enable-multilib
AC_ARG_ENABLE(multilib,
[ --enable-multilib build many library versions (default)],
[case "$enableval" in
yes) multilib=yes ;;
no) multilib=no ;;
*) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
esac],
[multilib=yes])
# We may get other options which we leave undocumented:
# --with-target-subdir, --with-multisrctop, --with-multisubdir
# See config-ml.in if you want the gory details.
if test "$srcdir" = "."; then
if test "$with_target_subdir" != "."; then
multi_basedir="$srcdir/$with_multisrctop../$2"
else
multi_basedir="$srcdir/$with_multisrctop$2"
fi
else
multi_basedir="$srcdir/$2"
fi
AC_SUBST(multi_basedir)
# Even if the default multilib is not a cross compilation,
# it may be that some of the other multilibs are.
if test $cross_compiling = no && test $multilib = yes \
&& test "x${with_multisubdir}" != x ; then
cross_compiling=maybe
fi
AC_OUTPUT_COMMANDS([
# Only add multilib support code if we just rebuilt the top-level
# Makefile.
case " $CONFIG_FILES " in
*" ]m4_default([$1],Makefile)[ "*)
ac_file=]m4_default([$1],Makefile)[ . ${multi_basedir}/config-ml.in
;;
esac],
[
srcdir="$srcdir"
host="$host"
target="$target"
with_multisubdir="$with_multisubdir"
with_multisrctop="$with_multisrctop"
with_target_subdir="$with_target_subdir"
ac_configure_args="${multilib_arg} ${ac_configure_args}"
multi_basedir="$multi_basedir"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
CC="$CC"
CXX="$CXX"
GFORTRAN="$GFORTRAN"
GDC="$GDC"])])dnl
dnl Fix Autoconf bugs by overriding broken internal Autoconf
dnl macros with backports of fixes from newer releases.
dnl
dnl The override bits of this file should be a no-op for the newest
dnl Autoconf version, which means they can be removed once the complete
dnl tree has moved to a new enough Autoconf version.
dnl
dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired
dnl Autoconf version is used. It should be kept for consistency.
dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
ifdef([m4_PACKAGE_VERSION], [
dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions.
m4_ifndef([m4_copy_force],
[m4_define([m4_copy_force],
[m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])])
m4_ifndef([m4_rename_force],
[m4_define([m4_rename_force],
[m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])])
dnl AC_DEFUN a commonly used macro so this file is picked up.
m4_copy([AC_PREREQ], [_AC_PREREQ])
AC_DEFUN([AC_PREREQ], [frob])
m4_copy_force([_AC_PREREQ], [AC_PREREQ])
dnl Ensure exactly this Autoconf version is used
m4_ifndef([_GCC_AUTOCONF_VERSION],
[m4_define([_GCC_AUTOCONF_VERSION], [2.69])])
dnl Test for the exact version when AC_INIT is expanded.
dnl This allows to update the tree in steps (for testing)
dnl by putting
dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
dnl in configure.ac before AC_INIT,
dnl without rewriting this file.
dnl Or for updating the whole tree at once with the definition above.
AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
m4_defn([m4_PACKAGE_VERSION]), [],
[m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
])
m4_define([AC_INIT], m4_defn([AC_INIT])[
_GCC_AUTOCONF_VERSION_CHECK
])
dnl Ensure we do not use a buggy M4.
m4_if(m4_index([..wi.d.], [.d.]), [-1],
[m4_fatal(m4_do([m4 with buggy strstr detected. Please install
GNU M4 1.4.16 or newer and set the M4 environment variable]))])
dnl Fix 2.64 cross compile detection for AVR and RTEMS
dnl by not trying to compile fopen.
m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
[m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
[m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
m4_version_prereq([2.66],, [
dnl We need AC_CHECK_DECL which works for overloaded C++ functions.
# _AC_CHECK_DECL_BODY
# -------------------
# Shell function body for AC_CHECK_DECL.
m4_define([_AC_CHECK_DECL_BODY],
[ AS_LINENO_PUSH([$[]1])
[as_decl_name=`echo $][2|sed 's/ *(.*//'`]
[as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
[@%:@ifndef $[]as_decl_name
@%:@ifdef __cplusplus
(void) $[]as_decl_use;
@%:@else
(void) $[]as_decl_name;
@%:@endif
@%:@endif
])],
[AS_VAR_SET([$[]3], [yes])],
[AS_VAR_SET([$[]3], [no])])])
AS_LINENO_POP
])# _AC_CHECK_DECL_BODY
# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
# INCLUDES)
# -------------------------------------------------------------
# Helper to AC_CHECK_DECLS, which generates the check for a single
# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
m4_define([_AC_CHECK_DECLS],
[AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
[$ac_have_decl],
[Define to 1 if you have the declaration of `$1',
and to 0 if you don't.])]dnl
[m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])
])
dnl If flex/lex are not found, the top level configure sets LEX to
dnl "/path_to/missing flex". When AC_PROG_LEX tries to find the flex
dnl output file, it calls $LEX to do so, but the current lightweight
dnl "missing" won't create a file. This results in an error.
dnl Avoid calling the bulk of AC_PROG_LEX when $LEX is "missing".
AC_DEFUN_ONCE([AC_PROG_LEX],
[AC_CHECK_PROGS(LEX, flex lex, :)
case "$LEX" in
:|*"missing "*) ;;
*) _AC_PROG_LEX_YYTEXT_DECL ;;
esac])
])
...@@ -35,38 +35,3 @@ AC_DEFUN([GCC_CHECK_UNWIND_GETIPINFO], [ ...@@ -35,38 +35,3 @@ AC_DEFUN([GCC_CHECK_UNWIND_GETIPINFO], [
AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
fi fi
]) ])
# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS])
# Sets @VARIABLE@ to the subset of the given options which the
# compiler accepts.
AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_LANG_PUSH(C)
m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
save_CFLAGS="$CFLAGS"
for real_option in $1; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in
-Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
*) option=$real_option ;;
esac
AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
[CFLAGS="$option"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[AS_VAR_SET(acx_Woption, yes)],
[AS_VAR_SET(acx_Woption, no)])
])
AS_IF([test AS_VAR_GET(acx_Woption) = yes],
[acx_Var="$acx_Var${acx_Var:+ }$real_option"])
AS_VAR_POPDEF([acx_Woption])dnl
done
CFLAGS="$save_CFLAGS"
m4_popdef([acx_Var])dnl
AC_LANG_POP(C)
])# ACX_PROG_CC_WARNING_OPTS
# Autoconf include file defining macros related to compile-time warnings.
# Copyright 2004, 2005, 2007, 2009, 2011 Free Software Foundation, Inc.
#This file is part of GCC.
#GCC 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, or (at your option) any later
#version.
#GCC 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 GCC; see the file COPYING3. If not see
#<http://www.gnu.org/licenses/>.
# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS])
# Sets @VARIABLE@ to the subset of the given options which the
# compiler accepts.
AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_LANG_PUSH(C)
m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
save_CFLAGS="$CFLAGS"
for real_option in $1; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in
-Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
*) option=$real_option ;;
esac
AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
[CFLAGS="$option"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[AS_VAR_SET(acx_Woption, yes)],
[AS_VAR_SET(acx_Woption, no)])
])
AS_IF([test AS_VAR_GET(acx_Woption) = yes],
[acx_Var="$acx_Var${acx_Var:+ }$real_option"])
AS_VAR_POPDEF([acx_Woption])dnl
done
CFLAGS="$save_CFLAGS"
m4_popdef([acx_Var])dnl
AC_LANG_POP(C)
])# ACX_PROG_CC_WARNING_OPTS
# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
# Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
# and accepts all of those options simultaneously, otherwise to nothing.
AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_LANG_PUSH(C)
m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
# Do the check with the no- prefix removed from the warning options
# since gcc silently accepts any -Wno-* option on purpose
m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
AS_IF([test "$GCC" = yes],
[AC_CACHE_CHECK([whether $CC supports -pedantic ]acx_Woptions, acx_Pedantic,
[save_CFLAGS="$CFLAGS"
CFLAGS="-pedantic acx_Woptions"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[AS_VAR_SET(acx_Pedantic, yes)],
[AS_VAR_SET(acx_Pedantic, no)])
CFLAGS="$save_CFLAGS"])
AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
[acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
])
AS_VAR_POPDEF([acx_Pedantic])dnl
m4_popdef([acx_Woptions])dnl
m4_popdef([acx_Var])dnl
AC_LANG_POP(C)
])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
# ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
# sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if
# --enable-werror-always was given on the command line, otherwise
# to nothing.
# If the argument is the word "manual" instead of a version number,
# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
# appeared on the configure command line.
AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_LANG_PUSH(C)
m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
AC_ARG_ENABLE(werror-always,
AS_HELP_STRING([--enable-werror-always],
[enable -Werror despite compiler version]),
[], [enable_werror_always=no])
AS_IF([test $enable_werror_always = yes],
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
m4_if($1, [manual],,
[AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
[set fnord `echo $1 | tr '.' ' '`
shift
AC_PREPROC_IFELSE(
[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
< [$]1 * 10000 + [$]2 * 100 + [$]3
#error insufficient
#endif],
[AS_VAR_SET(acx_GCCvers, yes)],
[AS_VAR_SET(acx_GCCvers, no)])])
AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
AS_VAR_POPDEF([acx_GCCvers])])
m4_popdef([acx_Var])dnl
AC_LANG_POP(C)
])# ACX_PROG_CC_WARNINGS_ARE_ERRORS
# ACX_PROG_CXX_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CXXFLAGS])
# Sets @VARIABLE@ to the subset of the given options which the
# compiler accepts.
AC_DEFUN([ACX_PROG_CXX_WARNING_OPTS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_LANG_PUSH(C++)
m4_pushdef([acx_Var], [m4_default([$2], [WARN_CXXFLAGS])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
save_CXXFLAGS="$CXXFLAGS"
for real_option in $1; do
# Do the check with the no- prefix removed since gcc silently
# accepts any -Wno-* option on purpose
case $real_option in
-Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
*) option=$real_option ;;
esac
AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
AC_CACHE_CHECK([whether $CXX supports $option], acx_Woption,
[CXXFLAGS="$option"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[AS_VAR_SET(acx_Woption, yes)],
[AS_VAR_SET(acx_Woption, no)])
])
AS_IF([test AS_VAR_GET(acx_Woption) = yes],
[acx_Var="$acx_Var${acx_Var:+ }$real_option"])
AS_VAR_POPDEF([acx_Woption])dnl
done
CXXFLAGS="$save_CXXFLAGS"
m4_popdef([acx_Var])dnl
AC_LANG_POP(C++)
])# ACX_PROG_CXX_WARNING_OPTS
# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
# Append to VARIABLE "-pedantic" + the argument, if the compiler is G++
# and accepts all of those options simultaneously, otherwise to nothing.
AC_DEFUN([ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_LANG_PUSH(C++)
m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
# Do the check with the no- prefix removed from the warning options
# since gcc silently accepts any -Wno-* option on purpose
m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
AS_IF([test "$GXX" = yes],
[AC_CACHE_CHECK([whether $CXX supports -pedantic ]acx_Woptions, acx_Pedantic,
[save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-pedantic acx_Woptions"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[AS_VAR_SET(acx_Pedantic, yes)],
[AS_VAR_SET(acx_Pedantic, no)])
CXXFLAGS="$save_CXXFLAGS"])
AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
[acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
])
AS_VAR_POPDEF([acx_Pedantic])dnl
m4_popdef([acx_Woptions])dnl
m4_popdef([acx_Var])dnl
AC_LANG_POP(C++)
])# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC
# ACX_PROG_CXX_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
# sets @VARIABLE@ to "-Werror" if the compiler is G++ >=x.y.z, or if
# --enable-werror-always was given on the command line, otherwise
# to nothing.
# If the argument is the word "manual" instead of a version number,
# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
# appeared on the configure command line.
AC_DEFUN([ACX_PROG_CXX_WARNINGS_ARE_ERRORS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_LANG_PUSH(C++)
m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
AC_SUBST(acx_Var)dnl
m4_expand_once([acx_Var=
],m4_quote(acx_Var=))dnl
AC_ARG_ENABLE(werror-always,
AS_HELP_STRING([--enable-werror-always],
[enable -Werror despite compiler version]),
[], [enable_werror_always=no])
AS_IF([test $enable_werror_always = yes],
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
m4_if($1, [manual],,
[AS_VAR_PUSHDEF([acx_GXXvers], [acx_cv_prog_cxx_gxx_$1_or_newer])dnl
AC_CACHE_CHECK([whether $CXX is G++ >=$1], acx_GXXvers,
[set fnord `echo $1 | tr '.' ' '`
shift
AC_PREPROC_IFELSE(
[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
< [$]1 * 10000 + [$]2 * 100 + [$]3
#error insufficient
#endif],
[AS_VAR_SET(acx_GXXvers, yes)],
[AS_VAR_SET(acx_GXXvers, no)])])
AS_IF([test AS_VAR_GET(acx_GXXvers) = yes],
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
AS_VAR_POPDEF([acx_GXXvers])])
m4_popdef([acx_Var])dnl
AC_LANG_POP(C++)
])# ACX_PROG_CXX_WARNINGS_ARE_ERRORS
This source diff could not be displayed because it is too large. You can view the blob instead.
# configure.ac -- Backtrace configure script. # configure.ac -- Backtrace configure script.
# Copyright (C) 2012-2018 Free Software Foundation, Inc. # Copyright (C) 2012-2019 Free Software Foundation, Inc.
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are # modification, are permitted provided that the following conditions are
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
AC_PREREQ(2.64) AC_PREREQ(2.69)
AC_INIT(package-unused, version-unused,, libbacktrace) AC_INIT(package-unused, version-unused,, libbacktrace)
AC_CONFIG_SRCDIR(backtrace.h) AC_CONFIG_SRCDIR(backtrace.h)
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
...@@ -45,6 +45,9 @@ target_alias=${target_alias-$host_alias} ...@@ -45,6 +45,9 @@ target_alias=${target_alias-$host_alias}
AC_USE_SYSTEM_EXTENSIONS AC_USE_SYSTEM_EXTENSIONS
# Default to not building a shared library.
AC_DISABLE_SHARED
libtool_VERSION=1:0:0 libtool_VERSION=1:0:0
AC_SUBST(libtool_VERSION) AC_SUBST(libtool_VERSION)
...@@ -74,11 +77,16 @@ m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) ...@@ -74,11 +77,16 @@ m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
AC_PROG_RANLIB
AC_PROG_AWK AC_PROG_AWK
case "$AWK" in case "$AWK" in
"") AC_MSG_ERROR([can't build without awk]) ;; "") AC_MSG_ERROR([can't build without awk]) ;;
esac esac
AC_CHECK_PROG(DWZ, dwz, dwz)
AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
LT_INIT LT_INIT
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
...@@ -251,6 +259,7 @@ elf64) elfsize=64 ;; ...@@ -251,6 +259,7 @@ elf64) elfsize=64 ;;
*) elfsize=unused *) elfsize=unused
esac esac
AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo")
# XCOFF defines. # XCOFF defines.
xcoffsize= xcoffsize=
...@@ -297,12 +306,12 @@ if test "$have_mmap" = "no"; then ...@@ -297,12 +306,12 @@ if test "$have_mmap" = "no"; then
ALLOC_FILE=alloc.lo ALLOC_FILE=alloc.lo
else else
VIEW_FILE=mmapio.lo VIEW_FILE=mmapio.lo
AC_PREPROC_IFELSE([ AC_PREPROC_IFELSE([AC_LANG_SOURCE([
#include <sys/mman.h> #include <sys/mman.h>
#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
#error no MAP_ANONYMOUS #error no MAP_ANONYMOUS
#endif #endif
], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) ])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
fi fi
AC_SUBST(VIEW_FILE) AC_SUBST(VIEW_FILE)
AC_SUBST(ALLOC_FILE) AC_SUBST(ALLOC_FILE)
...@@ -406,7 +415,7 @@ AC_CACHE_CHECK([whether -pthread is supported], ...@@ -406,7 +415,7 @@ AC_CACHE_CHECK([whether -pthread is supported],
[libgo_cv_lib_pthread], [libgo_cv_lib_pthread],
[CFLAGS_hold=$CFLAGS [CFLAGS_hold=$CFLAGS
CFLAGS="$CFLAGS -pthread" CFLAGS="$CFLAGS -pthread"
AC_COMPILE_IFELSE([[int i;]], AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
[libgo_cv_lib_pthread=yes], [libgo_cv_lib_pthread=yes],
[libgo_cv_lib_pthread=no]) [libgo_cv_lib_pthread=no])
CFLAGS=$CFLAGS_hold]) CFLAGS=$CFLAGS_hold])
...@@ -418,10 +427,19 @@ AC_SUBST(PTHREAD_CFLAGS) ...@@ -418,10 +427,19 @@ AC_SUBST(PTHREAD_CFLAGS)
AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes) AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
AC_CHECK_LIB([z], [compress], []) dnl Test whether the compiler supports the -gdwarf-5 option.
if test $ac_cv_lib_z_compress = "yes"; then AC_CACHE_CHECK([whether -gdwarf-5 is supported],
AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.]) [libbacktrace_cv_lib_dwarf5],
fi [CFLAGS_hold=$CFLAGS
CFLAGS="$CFLAGS -gdwarf-5"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
[libbacktrace_cv_lib_dwarf5=yes],
[libbacktrace_cv_lib_dwarf5=no])
CFLAGS=$CFLAGS_hold])
AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes)
AC_CHECK_LIB([z], [compress],
[AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes) AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
dnl Test whether the linker supports the --compress_debug_sections option. dnl Test whether the linker supports the --compress_debug_sections option.
...@@ -437,6 +455,7 @@ AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes) ...@@ -437,6 +455,7 @@ AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
AC_ARG_VAR(OBJCOPY, [location of objcopy]) AC_ARG_VAR(OBJCOPY, [location of objcopy])
AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,) AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
AC_CHECK_PROG(READELF, readelf, readelf)
AC_CACHE_CHECK([whether objcopy supports debuglink], AC_CACHE_CHECK([whether objcopy supports debuglink],
[libbacktrace_cv_objcopy_debuglink], [libbacktrace_cv_objcopy_debuglink],
[if test -n "${with_target_subdir}"; then [if test -n "${with_target_subdir}"; then
...@@ -464,6 +483,7 @@ else ...@@ -464,6 +483,7 @@ else
fi fi
AC_CONFIG_FILES(Makefile backtrace-supported.h) AC_CONFIG_FILES(Makefile backtrace-supported.h)
AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
# We need multilib support, but only if configuring for the target. # We need multilib support, but only if configuring for the target.
AC_CONFIG_COMMANDS([default], AC_CONFIG_COMMANDS([default],
......
/* edtest.c -- Test for libbacktrace storage allocation stress handling /* edtest.c -- Test for libbacktrace storage allocation stress handling
Copyright (C) 2017-2018 Free Software Foundation, Inc. Copyright (C) 2017-2019 Free Software Foundation, Inc.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
...@@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. */
#include "testlib.h" #include "testlib.h"
static int test1 (void) __attribute__ ((noinline, unused)); static int test1 (void) __attribute__ ((noinline, noclone, unused));
static int test1 (void) __attribute__ ((noinline, unused));
extern int f2 (int); extern int f2 (int);
extern int f3 (int, int); extern int f3 (int, int);
......
/* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2) /* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2)
Copyright (C) 2017-2018 Free Software Foundation, Inc. Copyright (C) 2017-2019 Free Software Foundation, Inc.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
......
/* fileline.c -- Get file and line number information in a backtrace. /* fileline.c -- Get file and line number information in a backtrace.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
...@@ -44,6 +44,9 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -44,6 +44,9 @@ POSSIBILITY OF SUCH DAMAGE. */
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
# define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') # define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
# define HAS_DRIVE_SPEC(f) ((f)[0] != '\0' && (f)[1] == ':')
# define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC(f))
#else #else
# define IS_DIR_SEPARATOR(c) ((c) == '/') # define IS_DIR_SEPARATOR(c) ((c) == '/')
# define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
#endif #endif
...@@ -3,3 +3,6 @@ ...@@ -3,3 +3,6 @@
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } } /\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
/\114\001/ { if (NR == 1) { print "pecoff"; exit } } /\114\001/ { if (NR == 1) { print "pecoff"; exit } }
/\144\206/ { if (NR == 1) { print "pecoff"; exit } } /\144\206/ { if (NR == 1) { print "pecoff"; exit } }
/\001\337/ { if (NR == 1) { print "xcoff32"; exit } }
/\001\367/ { if (NR == 1) { print "xcoff64"; exit } }
#!/bin/sh
# install-debug-info-for-buildid.sh -- Helper script for libbacktrace library
# testing.
# Copyright (C) 2019 Free Software Foundation, Inc.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# (1) Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# (2) Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# (3) The name of the author may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Extract build-id from src, and copy debug info of src to
# $build_id_dir/aa/bb...zz.debug.
set -e
sed=@SED@
awk=@AWK@
grep=@GREP@
objcopy=@OBJCOPY@
readelf=@READELF@
mkdir_p="@MKDIR_P@"
build_id_dir="$1"
src="$2"
buildid=$($readelf -n $src \
| $grep "Build ID" \
| $awk '{print $3}')
prefix=$(echo $buildid \
| $sed 's/^\(.\{2\}\).*/\1/')
remainder=$(echo $buildid \
| $sed 's/^.\{2\}//')
dir=$build_id_dir/$prefix
dst=$dir/$remainder.debug
$mkdir_p $dir
$objcopy --only-keep-debug $src $dst
/* instrumented_alloc.c -- Memory allocation instrumented to fail when
requested, for testing purposes.
Copyright (C) 2018-2019 Free Software Foundation, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
(3) The name of the author may not be used to
endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* Include all the header files of alloc here, to make sure they're not
processed when including alloc.c below, such that the redefinitions of malloc
and realloc are only effective in alloc.c itself. This does not work for
config.h, because it's not wrapped in "#ifndef CONFIG_H\n#define CONFIG_H"
and "#endif" but that does not seem to be harmful. */
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <inttypes.h>
#include "backtrace.h"
#include "internal.h"
extern void *instrumented_malloc (size_t size);
extern void *instrumented_realloc (void *ptr, size_t size);
#define malloc instrumented_malloc
#define realloc instrumented_realloc
#include "alloc.c"
#undef malloc
#undef realloc
static uint64_t nr_allocs = 0;
static uint64_t fail_at_alloc = 0;
extern int at_fail_alloc_p (void);
extern uint64_t get_nr_allocs (void);
extern void set_fail_at_alloc (uint64_t);
void *
instrumented_malloc (size_t size)
{
void *res;
if (at_fail_alloc_p ())
return NULL;
res = malloc (size);
if (res != NULL)
nr_allocs++;
return res;
}
void *
instrumented_realloc (void *ptr, size_t size)
{
void *res;
if (size != 0)
{
if (at_fail_alloc_p ())
return NULL;
}
res = realloc (ptr, size);
if (res != NULL)
nr_allocs++;
return res;
}
int
at_fail_alloc_p (void)
{
return fail_at_alloc == nr_allocs + 1;
}
uint64_t
get_nr_allocs (void)
{
return nr_allocs;
}
void
set_fail_at_alloc (uint64_t nr)
{
fail_at_alloc = nr;
}
/* internal.h -- Internal header file for stack backtrace library. /* internal.h -- Internal header file for stack backtrace library.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -179,7 +179,7 @@ struct backtrace_view ...@@ -179,7 +179,7 @@ struct backtrace_view
/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. Store the /* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. Store the
result in *VIEW. Returns 1 on success, 0 on error. */ result in *VIEW. Returns 1 on success, 0 on error. */
extern int backtrace_get_view (struct backtrace_state *state, int descriptor, extern int backtrace_get_view (struct backtrace_state *state, int descriptor,
off_t offset, size_t size, off_t offset, uint64_t size,
backtrace_error_callback error_callback, backtrace_error_callback error_callback,
void *data, struct backtrace_view *view); void *data, struct backtrace_view *view);
...@@ -257,6 +257,18 @@ extern int backtrace_vector_release (struct backtrace_state *state, ...@@ -257,6 +257,18 @@ extern int backtrace_vector_release (struct backtrace_state *state,
backtrace_error_callback error_callback, backtrace_error_callback error_callback,
void *data); void *data);
/* Free the space managed by VEC. This will reset VEC. */
static inline void
backtrace_vector_free (struct backtrace_state *state,
struct backtrace_vector *vec,
backtrace_error_callback error_callback, void *data)
{
vec->alc += vec->size;
vec->size = 0;
backtrace_vector_release (state, vec, error_callback, data);
}
/* Read initial debug data from a descriptor, and set the /* Read initial debug data from a descriptor, and set the
fileline_data, syminfo_fn, and syminfo_data fields of STATE. fileline_data, syminfo_fn, and syminfo_data fields of STATE.
Return the fileln_fn field in *FILELN_FN--this is done this way so Return the fileln_fn field in *FILELN_FN--this is done this way so
...@@ -274,23 +286,45 @@ extern int backtrace_initialize (struct backtrace_state *state, ...@@ -274,23 +286,45 @@ extern int backtrace_initialize (struct backtrace_state *state,
void *data, void *data,
fileline *fileline_fn); fileline *fileline_fn);
/* An enum for the DWARF sections we care about. */
enum dwarf_section
{
DEBUG_INFO,
DEBUG_LINE,
DEBUG_ABBREV,
DEBUG_RANGES,
DEBUG_STR,
DEBUG_ADDR,
DEBUG_STR_OFFSETS,
DEBUG_LINE_STR,
DEBUG_RNGLISTS,
DEBUG_MAX
};
/* Data for the DWARF sections we care about. */
struct dwarf_sections
{
const unsigned char *data[DEBUG_MAX];
size_t size[DEBUG_MAX];
};
/* DWARF data read from a file, used for .gnu_debugaltlink. */
struct dwarf_data;
/* Add file/line information for a DWARF module. */ /* Add file/line information for a DWARF module. */
extern int backtrace_dwarf_add (struct backtrace_state *state, extern int backtrace_dwarf_add (struct backtrace_state *state,
uintptr_t base_address, uintptr_t base_address,
const unsigned char* dwarf_info, const struct dwarf_sections *dwarf_sections,
size_t dwarf_info_size,
const unsigned char *dwarf_line,
size_t dwarf_line_size,
const unsigned char *dwarf_abbrev,
size_t dwarf_abbrev_size,
const unsigned char *dwarf_ranges,
size_t dwarf_range_size,
const unsigned char *dwarf_str,
size_t dwarf_str_size,
int is_bigendian, int is_bigendian,
struct dwarf_data *fileline_altlink,
backtrace_error_callback error_callback, backtrace_error_callback error_callback,
void *data, fileline *fileline_fn); void *data, fileline *fileline_fn,
struct dwarf_data **fileline_entry);
/* A test-only hook for elf_uncompress_zdebug. */ /* A test-only hook for elf_uncompress_zdebug. */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59 which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# Generated from ltversion.in.
# serial 3134 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.2.7a])
m4_define([LT_PACKAGE_REVISION], [1.3134])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.2.7a'
macro_revision='1.3134'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 4 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
/* mmap.c -- Memory allocation with mmap. /* mmap.c -- Memory allocation with mmap.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -321,5 +321,7 @@ backtrace_vector_release (struct backtrace_state *state, ...@@ -321,5 +321,7 @@ backtrace_vector_release (struct backtrace_state *state,
backtrace_free (state, (char *) vec->base + aligned, alc, backtrace_free (state, (char *) vec->base + aligned, alc,
error_callback, data); error_callback, data);
vec->alc = 0; vec->alc = 0;
if (vec->size == 0)
vec->base = NULL;
return 1; return 1;
} }
/* mmapio.c -- File views using mmap. /* mmapio.c -- File views using mmap.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. */
int int
backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED, backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED,
int descriptor, off_t offset, size_t size, int descriptor, off_t offset, uint64_t size,
backtrace_error_callback error_callback, backtrace_error_callback error_callback,
void *data, struct backtrace_view *view) void *data, struct backtrace_view *view)
{ {
...@@ -60,6 +60,12 @@ backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED, ...@@ -60,6 +60,12 @@ backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED,
off_t pageoff; off_t pageoff;
void *map; void *map;
if ((uint64_t) (size_t) size != size)
{
error_callback (data, "file size too large", 0);
return 0;
}
pagesize = getpagesize (); pagesize = getpagesize ();
inpage = offset % pagesize; inpage = offset % pagesize;
pageoff = offset - inpage; pageoff = offset - inpage;
......
/* backtrace.c -- Entry point for stack backtrace library. /* backtrace.c -- Entry point for stack backtrace library.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* pecoff.c -- Get debug data from a PE/COFFF file for backtraces. /* pecoff.c -- Get debug data from a PE/COFFF file for backtraces.
Copyright (C) 2015-2018 Free Software Foundation, Inc. Copyright (C) 2015-2019 Free Software Foundation, Inc.
Adapted from elf.c by Tristan Gingold, AdaCore. Adapted from elf.c by Tristan Gingold, AdaCore.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -133,19 +133,7 @@ typedef struct { ...@@ -133,19 +133,7 @@ typedef struct {
uint16_t sc; uint16_t sc;
} b_coff_internal_symbol; } b_coff_internal_symbol;
/* An index of sections we care about. */ /* Names of sections, indexed by enum dwarf_section in internal.h. */
enum debug_section
{
DEBUG_INFO,
DEBUG_LINE,
DEBUG_ABBREV,
DEBUG_RANGES,
DEBUG_STR,
DEBUG_MAX
};
/* Names of sections, indexed by enum debug_section. */
static const char * const debug_section_names[DEBUG_MAX] = static const char * const debug_section_names[DEBUG_MAX] =
{ {
...@@ -153,7 +141,11 @@ static const char * const debug_section_names[DEBUG_MAX] = ...@@ -153,7 +141,11 @@ static const char * const debug_section_names[DEBUG_MAX] =
".debug_line", ".debug_line",
".debug_abbrev", ".debug_abbrev",
".debug_ranges", ".debug_ranges",
".debug_str" ".debug_str",
".debug_addr",
".debug_str_offsets",
".debug_line_str",
".debug_rnglists"
}; };
/* Information we gather for the sections we care about. */ /* Information we gather for the sections we care about. */
...@@ -164,8 +156,6 @@ struct debug_section_info ...@@ -164,8 +156,6 @@ struct debug_section_info
off_t offset; off_t offset;
/* Section size. */ /* Section size. */
size_t size; size_t size;
/* Section contents, after read from file. */
const unsigned char *data;
}; };
/* Information we keep for an coff symbol. */ /* Information we keep for an coff symbol. */
...@@ -616,6 +606,7 @@ coff_add (struct backtrace_state *state, int descriptor, ...@@ -616,6 +606,7 @@ coff_add (struct backtrace_state *state, int descriptor,
struct backtrace_view debug_view; struct backtrace_view debug_view;
int debug_view_valid; int debug_view_valid;
uintptr_t image_base; uintptr_t image_base;
struct dwarf_sections dwarf_sections;
*found_sym = 0; *found_sym = 0;
*found_dwarf = 0; *found_dwarf = 0;
...@@ -848,26 +839,20 @@ coff_add (struct backtrace_state *state, int descriptor, ...@@ -848,26 +839,20 @@ coff_add (struct backtrace_state *state, int descriptor,
for (i = 0; i < (int) DEBUG_MAX; ++i) for (i = 0; i < (int) DEBUG_MAX; ++i)
{ {
if (sections[i].size == 0) size_t size = sections[i].size;
sections[i].data = NULL; dwarf_sections.size[i] = size;
if (size == 0)
dwarf_sections.data[i] = NULL;
else else
sections[i].data = ((const unsigned char *) debug_view.data dwarf_sections.data[i] = ((const unsigned char *) debug_view.data
+ (sections[i].offset - min_offset)); + (sections[i].offset - min_offset));
} }
if (!backtrace_dwarf_add (state, /* base_address */ 0, if (!backtrace_dwarf_add (state, /* base_address */ 0, &dwarf_sections,
sections[DEBUG_INFO].data, 0, /* FIXME: is_bigendian */
sections[DEBUG_INFO].size, NULL, /* altlink */
sections[DEBUG_LINE].data, error_callback, data, fileline_fn,
sections[DEBUG_LINE].size, NULL /* returned fileline_entry */))
sections[DEBUG_ABBREV].data,
sections[DEBUG_ABBREV].size,
sections[DEBUG_RANGES].data,
sections[DEBUG_RANGES].size,
sections[DEBUG_STR].data,
sections[DEBUG_STR].size,
0, /* FIXME */
error_callback, data, fileline_fn))
goto fail; goto fail;
*found_dwarf = 1; *found_dwarf = 1;
...@@ -920,7 +905,8 @@ backtrace_initialize (struct backtrace_state *state, ...@@ -920,7 +905,8 @@ backtrace_initialize (struct backtrace_state *state,
if (found_sym) if (found_sym)
backtrace_atomic_store_pointer (&state->syminfo_fn, coff_syminfo); backtrace_atomic_store_pointer (&state->syminfo_fn, coff_syminfo);
else else
__sync_bool_compare_and_swap (&state->syminfo_fn, NULL, coff_nosyms); (void) __sync_bool_compare_and_swap (&state->syminfo_fn, NULL,
coff_nosyms);
} }
if (!state->threaded) if (!state->threaded)
......
/* posix.c -- POSIX file I/O routines for the backtrace library. /* posix.c -- POSIX file I/O routines for the backtrace library.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* print.c -- Print the current backtrace. /* print.c -- Print the current backtrace.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -80,7 +80,7 @@ error_callback (void *data, const char *msg, int errnum) ...@@ -80,7 +80,7 @@ error_callback (void *data, const char *msg, int errnum)
/* Print a backtrace. */ /* Print a backtrace. */
void void __attribute__((noinline))
backtrace_print (struct backtrace_state *state, int skip, FILE *f) backtrace_print (struct backtrace_state *state, int skip, FILE *f)
{ {
struct print_data data; struct print_data data;
......
/* read.c -- File views without mmap. /* read.c -- File views without mmap.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -46,12 +46,18 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -46,12 +46,18 @@ POSSIBILITY OF SUCH DAMAGE. */
int int
backtrace_get_view (struct backtrace_state *state, int descriptor, backtrace_get_view (struct backtrace_state *state, int descriptor,
off_t offset, size_t size, off_t offset, uint64_t size,
backtrace_error_callback error_callback, backtrace_error_callback error_callback,
void *data, struct backtrace_view *view) void *data, struct backtrace_view *view)
{ {
ssize_t got; ssize_t got;
if ((uint64_t) (size_t) size != size)
{
error_callback (data, "file size too large", 0);
return 0;
}
if (lseek (descriptor, offset, SEEK_SET) < 0) if (lseek (descriptor, offset, SEEK_SET) < 0)
{ {
error_callback (data, "lseek", errno); error_callback (data, "lseek", errno);
......
/* simple.c -- The backtrace_simple function. /* simple.c -- The backtrace_simple function.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -90,7 +90,7 @@ simple_unwind (struct _Unwind_Context *context, void *vdata) ...@@ -90,7 +90,7 @@ simple_unwind (struct _Unwind_Context *context, void *vdata)
/* Get a simple stack backtrace. */ /* Get a simple stack backtrace. */
int int __attribute__((noinline))
backtrace_simple (struct backtrace_state *state, int skip, backtrace_simple (struct backtrace_state *state, int skip,
backtrace_simple_callback callback, backtrace_simple_callback callback,
backtrace_error_callback error_callback, void *data) backtrace_error_callback error_callback, void *data)
......
/* sort.c -- Sort without allocating memory /* sort.c -- Sort without allocating memory
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* state.c -- Create the backtrace state. /* state.c -- Create the backtrace state.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* stest.c -- Test for libbacktrace internal sort function /* stest.c -- Test for libbacktrace internal sort function
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2016-01-11.22; # UTC
# Copyright (C) 2011-2017 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 2, 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/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--enable-hard-errors={yes|no}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
END
}
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
*) break;;
esac
shift
done
missing_opts=
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
if test x"$missing_opts" != x; then
usage_error "the following mandatory options are missing:$missing_opts"
fi
if test $# -eq 0; then
usage_error "missing argument"
fi
if test $color_tests = yes; then
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
red='' # Red.
grn='' # Green.
lgn='' # Light green.
blu='' # Blue.
mgn='' # Magenta.
std='' # No color.
else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here.
"$@" >$log_file 2>&1
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
tweaked_estatus=1
else
tweaked_estatus=$estatus
fi
case $tweaked_estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
esac
# Report the test outcome and exit status in the logs, so that one can
# know whether the test passed or failed simply by looking at the '.log'
# file, without the need of also peaking into the corresponding '.trs'
# file (automake bug#11814).
echo "$res $test_name (exit status: $estatus)" >>$log_file
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
/* test_format.c -- Test for libbacktrace library
Copyright (C) 2018-2019 Free Software Foundation, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
(3) The name of the author may not be used to
endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* This program tests the externally visible interfaces of the
libbacktrace library. */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "filenames.h"
#include "backtrace.h"
#include "backtrace-supported.h"
#include "testlib.h"
int
main (int argc ATTRIBUTE_UNUSED, char **argv)
{
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_create, NULL);
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
}
/* testlib.c -- test functions for libbacktrace library /* testlib.c -- test functions for libbacktrace library
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* testlib.h -- Header for test functions for libbacktrace library /* testlib.h -- Header for test functions for libbacktrace library
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* ttest.c -- Test for libbacktrace library /* ttest.c -- Test for libbacktrace library
Copyright (C) 2017-2018 Free Software Foundation, Inc. Copyright (C) 2017-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* unittest.c -- Test for libbacktrace library
Copyright (C) 2018-2019 Free Software Foundation, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
(3) The name of the author may not be used to
endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "filenames.h"
#include "backtrace.h"
#include "backtrace-supported.h"
#include "testlib.h"
#include "internal.h"
static unsigned count;
static void
error_callback (void *vdata ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
int errnum ATTRIBUTE_UNUSED)
{
++count;
}
static int
test1 (void)
{
int res;
int failed;
struct backtrace_vector vec;
memset (&vec, 0, sizeof vec);
backtrace_vector_grow (state, 100, error_callback, NULL, &vec);
vec.alc += vec.size;
vec.size = 0;
count = 0;
res = backtrace_vector_release (state, &vec, error_callback, NULL);
failed = res != 1 || count != 0 || vec.base != NULL;
printf ("%s: unittest backtrace_vector_release size == 0\n",
failed ? "FAIL": "PASS");
if (failed)
++failures;
return failures;
}
int
main (int argc ATTRIBUTE_UNUSED, char **argv)
{
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_create, NULL);
test1 ();
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
}
/* unknown.c -- used when backtrace configury does not know file format. /* unknown.c -- used when backtrace configury does not know file format.
Copyright (C) 2012-2018 Free Software Foundation, Inc. Copyright (C) 2012-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
/* ztest.c -- Test for libbacktrace inflate code. /* ztest.c -- Test for libbacktrace inflate code.
Copyright (C) 2017-2018 Free Software Foundation, Inc. Copyright (C) 2017-2019 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google. Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment