Auto merge of #28004 - Diggsey:win-backtrace, r=alexcrichton

Technically this could also be used for `windows-msvc` targets, as I believe they have *both* dwarf and pdb debug information, but I haven't enabled it there as it should really use the native windows APIs for that, instead of libbacktrace.

I wasn't exactly sure where I should put "gnu" specific stuff, so tell me if I should structure things differently.

This is still a WIP, and I haven't tested properly to make sure I haven't broken msvc/linux builds yet.
This commit is contained in:
bors 2015-09-04 07:08:17 +00:00
commit 9d1f8200e7
25 changed files with 1348 additions and 154 deletions

View File

@ -259,8 +259,10 @@ BACKTRACE_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),backtrace)
BACKTRACE_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(BACKTRACE_NAME_$(1))
BACKTRACE_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/libbacktrace
# We don't use this on platforms that aren't linux-based, so just make the file
# available, the compilation of libstd won't actually build it.
# We don't use this on platforms that aren't linux-based (with the exception of
# msys2/mingw builds on windows, which use it to read the dwarf debug
# information) so just make the file available, the compilation of libstd won't
# actually build it.
ifeq ($$(findstring darwin,$$(OSTYPE_$(1))),darwin)
# See comment above
$$(BACKTRACE_LIB_$(1)):
@ -273,7 +275,7 @@ $$(BACKTRACE_LIB_$(1)):
touch $$@
else
ifeq ($$(CFG_WINDOWSY_$(1)),1)
ifeq ($$(findstring msvc,$(1)),msvc)
# See comment above
$$(BACKTRACE_LIB_$(1)):
touch $$@
@ -296,16 +298,25 @@ endif
# ./configure script. This is done to force libbacktrace to *not* use the
# atomic/sync functionality because it pulls in unnecessary dependencies and we
# never use it anyway.
#
# We also use `env PWD=` to clear the PWD environment variable, and then
# execute the command in a new shell. This is necessary to workaround a
# buildbot/msys2 bug: the shell is launched with PWD set to a windows-style path,
# which results in all further uses of `pwd` also printing a windows-style path,
# which breaks libbacktrace's configure script. Clearing PWD within the same
# shell is not sufficient.
$$(BACKTRACE_BUILD_DIR_$(1))/Makefile: $$(BACKTRACE_DEPS) $$(MKFILE_DEPS)
@$$(call E, configure: libbacktrace for $(1))
$$(Q)rm -rf $$(BACKTRACE_BUILD_DIR_$(1))
$$(Q)mkdir -p $$(BACKTRACE_BUILD_DIR_$(1))
$$(Q)(cd $$(BACKTRACE_BUILD_DIR_$(1)) && \
$$(Q)(cd $$(BACKTRACE_BUILD_DIR_$(1)) && env \
PWD= \
CC="$$(CC_$(1))" \
AR="$$(AR_$(1))" \
RANLIB="$$(AR_$(1)) s" \
CFLAGS="$$(CFG_GCCISH_CFLAGS_$(1):-Werror=) -fno-stack-protector" \
$(S)src/libbacktrace/configure --target=$(1) --host=$(CFG_BUILD))
$(S)src/libbacktrace/configure --build=$(CFG_GNU_TRIPLE_$(CFG_BUILD)) --host=$(CFG_GNU_TRIPLE_$(1)))
$$(Q)echo '#undef HAVE_ATOMIC_FUNCTIONS' >> \
$$(BACKTRACE_BUILD_DIR_$(1))/config.h
$$(Q)echo '#undef HAVE_SYNC_FUNCTIONS' >> \
@ -317,7 +328,7 @@ $$(BACKTRACE_LIB_$(1)): $$(BACKTRACE_BUILD_DIR_$(1))/Makefile $$(MKFILE_DEPS)
INCDIR=$(S)src/libbacktrace
$$(Q)cp $$(BACKTRACE_BUILD_DIR_$(1))/.libs/libbacktrace.a $$@
endif # endif for windowsy
endif # endif for msvc
endif # endif for ios
endif # endif for darwin

View File

@ -1,3 +1,41 @@
2015-08-24 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* configure.ac: Set have_mmap to no on spu-*-* targets.
* configure: Regenerate.
2015-08-13 Ian Lance Taylor <iant@google.com>
* dwarf.c (read_function_entry): Add vec_inlined parameter.
Change all callers.
2015-06-11 Martin Sebor <msebor@redhat.com>
PR sanitizer/65479
* dwarf.c (struct line): Add new field idx.
(line_compare): Use it.
(add_line): Set it.
(read_line_info): Reset it.
2015-05-29 Tristan Gingold <gingold@adacore.com>
* pecoff.c: New file.
* Makefile.am (FORMAT_FILES): Add pecoff.c and dependencies.
* Makefile.in: Regenerate.
* filetype.awk: Detect pecoff.
* configure.ac: Define BACKTRACE_SUPPORTS_DATA on elf platforms.
Add pecoff.
* btest.c (test5): Test enabled only if BACKTRACE_SUPPORTS_DATA is
true.
* backtrace-supported.h.in (BACKTRACE_SUPPORTS_DATA): Define.
* configure: Regenerate.
* pecoff.c: New file.
2015-05-13 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
* Makefile.in: Regenerated with automake-1.11.6.
* aclocal.m4: Likewise.
* configure: Likewise.
2015-01-24 Matthias Klose <doko@ubuntu.com>
* configure.ac: Move AM_ENABLE_MULTILIB before AC_PROG_CC.

View File

@ -56,6 +56,7 @@ BACKTRACE_FILES = \
FORMAT_FILES = \
elf.c \
pecoff.c \
unknown.c
VIEW_FILES = \
@ -124,6 +125,7 @@ fileline.lo: config.h backtrace.h internal.h
mmap.lo: config.h backtrace.h internal.h
mmapio.lo: config.h backtrace.h internal.h
nounwind.lo: config.h internal.h
pecoff.lo: config.h backtrace.h internal.h
posix.lo: config.h backtrace.h internal.h
print.lo: config.h backtrace.h internal.h
read.lo: config.h backtrace.h internal.h

View File

@ -1,9 +1,9 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This Makefile.in 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.
@ -16,7 +16,7 @@
@SET_MAKE@
# Makefile.am -- Backtrace Makefile.
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
# Copyright (C) 2012-2015 Free Software Foundation, Inc.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@ -47,6 +47,23 @@
# POSSIBILITY OF SUCH DAMAGE.
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -126,6 +143,11 @@ MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
@ -277,6 +299,7 @@ BACKTRACE_FILES = \
FORMAT_FILES = \
elf.c \
pecoff.c \
unknown.c
VIEW_FILES = \
@ -324,7 +347,7 @@ all: config.h
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
am--refresh:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
@ -360,10 +383,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
@if test ! -f $@; then rm -f stamp-h1; else :; fi
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
@ -386,7 +407,7 @@ clean-noinstLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES)
libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) $(EXTRA_libbacktrace_la_DEPENDENCIES)
$(LINK) $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@ -397,10 +418,10 @@ clean-checkPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES)
btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) $(EXTRA_btest_DEPENDENCIES)
@rm -f btest$(EXEEXT)
$(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS)
stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES)
stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES) $(EXTRA_stest_DEPENDENCIES)
@rm -f stest$(EXEEXT)
$(LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS)
@ -584,14 +605,15 @@ check-TESTS: $(TESTS)
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
if test "$$failed" -eq 0; then \
echo "$$grn$$dashes"; \
col="$$grn"; \
else \
echo "$$red$$dashes"; \
col="$$red"; \
fi; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
echo "$$dashes$$std"; \
echo "$${col}$$dashes$${std}"; \
echo "$${col}$$banner$${std}"; \
test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
test -z "$$report" || echo "$${col}$$report$${std}"; \
echo "$${col}$$dashes$${std}"; \
test "$$failed" -eq 0; \
else :; fi
check-am: all-am
@ -610,10 +632,15 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
@ -727,6 +754,7 @@ fileline.lo: config.h backtrace.h internal.h
mmap.lo: config.h backtrace.h internal.h
mmapio.lo: config.h backtrace.h internal.h
nounwind.lo: config.h internal.h
pecoff.lo: config.h backtrace.h internal.h
posix.lo: config.h backtrace.h internal.h
print.lo: config.h backtrace.h internal.h
read.lo: config.h backtrace.h internal.h

View File

@ -1,7 +1,8 @@
# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# 2005, 2006, 2007, 2008, 2009, 2010, 2011 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.
@ -19,12 +20,15 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 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 1
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
@ -34,7 +38,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.11.1], [],
m4_if([$1], [1.11.6], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -50,19 +54,21 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.11.1])dnl
[AM_AUTOMAKE_VERSION([1.11.6])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001, 2003, 2005, 2011 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 1
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
@ -283,12 +289,15 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
# Copyright (C) 2001, 2003, 2005, 2008, 2011 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 1
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
@ -307,8 +316,8 @@ AC_SUBST(install_sh)])
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008
# Free Software Foundation, Inc.
# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008,
# 2011 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -328,7 +337,7 @@ AC_DEFUN([AM_MAINTAINER_MODE],
[disable], [m4_define([am_maintainer_other], [enable])],
[m4_define([am_maintainer_other], [enable])
m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles])
AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode's default is 'disable' unless 'enable' is passed
AC_ARG_ENABLE([maintainer-mode],
[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful
@ -387,12 +396,15 @@ else
fi
])
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# Copyright (C) 2003, 2004, 2005, 2006, 2011 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 1
# AM_PROG_MKDIR_P
# ---------------
# Check for `mkdir -p'.
@ -415,13 +427,14 @@ esac
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc.
# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 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 4
# serial 5
# _AM_MANGLE_OPTION(NAME)
# -----------------------
@ -429,13 +442,13 @@ AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# --------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# ------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
@ -511,12 +524,14 @@ Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001, 2003, 2005, 2011 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 1
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
@ -539,13 +554,13 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
# Copyright (C) 2006, 2008, 2010 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 2
# serial 3
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
@ -554,13 +569,13 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])])
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# --------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -582,10 +597,11 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
[# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AC_SUBST([AMTAR], ['$${TAR-tar}'])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])

View File

@ -59,3 +59,8 @@ POSSIBILITY OF SUCH DAMAGE. */
as 0. */
#define BACKTRACE_SUPPORTS_THREADS @BACKTRACE_SUPPORTS_THREADS@
/* BACKTRACE_SUPPORTS_DATA will be #defined'd as 1 if the backtrace_syminfo
will work for variables. It will always work for functions. */
#define BACKTRACE_SUPPORTS_DATA @BACKTRACE_SUPPORTS_DATA@

View File

@ -616,6 +616,8 @@ f33 (int f1line, int f2line)
return failures;
}
#if BACKTRACE_SUPPORTS_DATA
int global = 1;
static int
@ -684,6 +686,8 @@ test5 (void)
return failures;
}
#endif /* BACKTRACE_SUPPORTS_DATA */
static void
error_callback_create (void *data ATTRIBUTE_UNUSED, const char *msg,
int errnum)
@ -708,7 +712,9 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
test2 ();
test3 ();
test4 ();
#if BACKTRACE_SUPPORTS_DATA
test5 ();
#endif
#endif
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);

View File

@ -607,6 +607,7 @@ NATIVE_TRUE
BACKTRACE_USES_MALLOC
ALLOC_FILE
VIEW_FILE
BACKTRACE_SUPPORTS_DATA
BACKTRACE_SUPPORTED
FORMAT_FILE
BACKTRACE_SUPPORTS_THREADS
@ -3973,7 +3974,7 @@ am_lf='
'
case `pwd` in
*[\\\"\#\$\&\'\`$am_lf]*)
as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
as_fn_error "unsafe absolute working directory name: \``pwd`'" "$LINENO" 5;;
esac
case $srcdir in
*[\\\"\#\$\&\'\`$am_lf\ \ ]*)
@ -4326,11 +4327,11 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
# Always define AMTAR for backward compatibility.
# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AMTAR='$${TAR-tar}'
AMTAR=${AMTAR-"${am_missing_run}tar"}
am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
@ -11129,7 +11130,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11132 "configure"
#line 11133 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11235,7 +11236,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11238 "configure"
#line 11239 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11569,6 +11570,12 @@ $as_echo "$libbacktrace_cv_c_random_seed_string" >&6; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
WARN_FLAGS=
save_CFLAGS="$CFLAGS"
for real_option in -W -Wall -Wwrite-strings -Wstrict-prototypes \
@ -11615,6 +11622,12 @@ $as_echo "$ac_res" >&6; }
fi
done
CFLAGS="$save_CFLAGS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "${with_target_subdir}"; then
@ -11826,8 +11839,12 @@ $as_echo "$libbacktrace_cv_sys_filetype" >&6; }
# Match the file type to decide what files to compile.
FORMAT_FILE=
backtrace_supports_data=yes
case "$libbacktrace_cv_sys_filetype" in
elf*) FORMAT_FILE="elf.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine output file type" >&5
$as_echo "$as_me: WARNING: could not determine output file type" >&2;}
FORMAT_FILE="unknown.lo"
@ -11841,6 +11858,7 @@ elfsize=
case "$libbacktrace_cv_sys_filetype" in
elf32) elfsize=32 ;;
elf64) elfsize=64 ;;
*) elfsize=unused
esac
cat >>confdefs.h <<_ACEOF
@ -11854,6 +11872,12 @@ if test "$backtrace_supported" = "yes"; then
fi
BACKTRACE_SUPPORTS_DATA=0
if test "$backtrace_supports_data" = "yes"; then
BACKTRACE_SUPPORTS_DATA=1
fi
inttype_headers=`echo inttypes.h sys/inttypes.h | sed -e 's/,/ /g'`
@ -12280,6 +12304,12 @@ else
# When built as a GCC target library, we can't do a link test. We
# simply assume that if we have mman.h, we have mmap.
have_mmap=yes
case "${host}" in
spu-*-*)
# The SPU does not have mmap, but it has a sys/mman.h header file
# containing "mmap_eaddr" and the mmap flags, confusing the test.
have_mmap=no ;;
esac
else
ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
if test "x$ac_cv_func_mmap" = x""yes; then :

View File

@ -229,8 +229,12 @@ libbacktrace_cv_sys_filetype=$filetype])
# Match the file type to decide what files to compile.
FORMAT_FILE=
backtrace_supports_data=yes
case "$libbacktrace_cv_sys_filetype" in
elf*) FORMAT_FILE="elf.lo" ;;
pecoff) FORMAT_FILE="pecoff.lo"
backtrace_supports_data=no
;;
*) AC_MSG_WARN([could not determine output file type])
FORMAT_FILE="unknown.lo"
backtrace_supported=no
@ -243,6 +247,7 @@ elfsize=
case "$libbacktrace_cv_sys_filetype" in
elf32) elfsize=32 ;;
elf64) elfsize=64 ;;
*) elfsize=unused
esac
AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
@ -252,6 +257,12 @@ if test "$backtrace_supported" = "yes"; then
fi
AC_SUBST(BACKTRACE_SUPPORTED)
BACKTRACE_SUPPORTS_DATA=0
if test "$backtrace_supports_data" = "yes"; then
BACKTRACE_SUPPORTS_DATA=1
fi
AC_SUBST(BACKTRACE_SUPPORTS_DATA)
GCC_HEADER_STDINT(gstdint.h)
AC_CHECK_HEADERS(sys/mman.h)
@ -262,6 +273,12 @@ else
# When built as a GCC target library, we can't do a link test. We
# simply assume that if we have mman.h, we have mmap.
have_mmap=yes
case "${host}" in
spu-*-*)
# The SPU does not have mmap, but it has a sys/mman.h header file
# containing "mmap_eaddr" and the mmap flags, confusing the test.
have_mmap=no ;;
esac
else
AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
fi

View File

@ -211,6 +211,10 @@ struct line
const char *filename;
/* Line number. */
int lineno;
/* Index of the object in the original array read from the DWARF
section, before it has been sorted. The index makes it possible
to use Quicksort and maintain stability. */
int idx;
};
/* A growable vector of line number information. This is used while
@ -940,9 +944,10 @@ unit_addrs_search (const void *vkey, const void *ventry)
return 0;
}
/* Sort the line vector by PC. We want a stable sort here. We know
that the pointers are into the same array, so it is safe to compare
them directly. */
/* Sort the line vector by PC. We want a stable sort here to maintain
the order of lines for the same PC values. Since the sequence is
being sorted in place, their addresses cannot be relied on to
maintain stability. That is the purpose of the index member. */
static int
line_compare (const void *v1, const void *v2)
@ -954,9 +959,9 @@ line_compare (const void *v1, const void *v2)
return -1;
else if (ln1->pc > ln2->pc)
return 1;
else if (ln1 < ln2)
else if (ln1->idx < ln2->idx)
return -1;
else if (ln1 > ln2)
else if (ln1->idx > ln2->idx)
return 1;
else
return 0;
@ -1551,6 +1556,7 @@ add_line (struct backtrace_state *state, struct dwarf_data *ddata,
ln->filename = filename;
ln->lineno = lineno;
ln->idx = vec->count;
++vec->count;
@ -2011,6 +2017,7 @@ read_line_info (struct backtrace_state *state, struct dwarf_data *ddata,
ln->pc = (uintptr_t) -1;
ln->filename = NULL;
ln->lineno = 0;
ln->idx = 0;
if (!backtrace_vector_release (state, &vec.vec, error_callback, data))
goto fail;
@ -2243,7 +2250,8 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
struct unit *u, uint64_t base, struct dwarf_buf *unit_buf,
const struct line_header *lhdr,
backtrace_error_callback error_callback, void *data,
struct function_vector *vec)
struct function_vector *vec_function,
struct function_vector *vec_inlined)
{
while (unit_buf->left > 0)
{
@ -2251,6 +2259,7 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
const struct abbrev *abbrev;
int is_function;
struct function *function;
struct function_vector *vec;
size_t i;
uint64_t lowpc;
int have_lowpc;
@ -2272,6 +2281,11 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
|| abbrev->tag == DW_TAG_entry_point
|| abbrev->tag == DW_TAG_inlined_subroutine);
if (abbrev->tag == DW_TAG_inlined_subroutine)
vec = vec_inlined;
else
vec = vec_function;
function = NULL;
if (is_function)
{
@ -2451,7 +2465,8 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
if (!is_function)
{
if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr,
error_callback, data, vec))
error_callback, data, vec_function,
vec_inlined))
return 0;
}
else
@ -2464,7 +2479,8 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
memset (&fvec, 0, sizeof fvec);
if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr,
error_callback, data, &fvec))
error_callback, data, vec_function,
&fvec))
return 0;
if (fvec.count > 0)
@ -2528,7 +2544,7 @@ read_function_info (struct backtrace_state *state, struct dwarf_data *ddata,
while (unit_buf.left > 0)
{
if (!read_function_entry (state, ddata, u, 0, &unit_buf, lhdr,
error_callback, data, pfvec))
error_callback, data, pfvec, pfvec))
return;
}

View File

@ -1,3 +1,5 @@
# An awk script to determine the type of a file.
/\177ELF\001/ { if (NR == 1) { print "elf32"; exit } }
/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
/\114\001/ { if (NR == 1) { print "pecoff"; exit } }
/\144\206/ { if (NR == 1) { print "pecoff"; exit } }

937
src/libbacktrace/pecoff.c Normal file
View File

@ -0,0 +1,937 @@
/* pecoff.c -- Get debug data from a PE/COFFF file for backtraces.
Copyright (C) 2015 Free Software Foundation, Inc.
Adapted from elf.c by Tristan Gingold, AdaCore.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
(1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
(3) The name of the author may not be used to
endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "backtrace.h"
#include "internal.h"
/* Coff file header. */
typedef struct {
uint16_t machine;
uint16_t number_of_sections;
uint32_t time_date_stamp;
uint32_t pointer_to_symbol_table;
uint32_t number_of_symbols;
uint16_t size_of_optional_header;
uint16_t characteristics;
} b_coff_file_header;
/* Coff optional header. */
typedef struct {
uint16_t magic;
uint8_t major_linker_version;
uint8_t minor_linker_version;
uint32_t size_of_code;
uint32_t size_of_initialized_data;
uint32_t size_of_uninitialized_data;
uint32_t address_of_entry_point;
uint32_t base_of_code;
union {
struct {
uint32_t base_of_data;
uint32_t image_base;
} pe;
struct {
uint64_t image_base;
} pep;
} u;
} b_coff_optional_header;
/* Values of magic in optional header. */
#define PE_MAGIC 0x10b /* PE32 executable. */
#define PEP_MAGIC 0x20b /* PE32+ executable (for 64bit targets). */
/* Coff section header. */
typedef struct {
char name[8];
uint32_t virtual_size;
uint32_t virtual_address;
uint32_t size_of_raw_data;
uint32_t pointer_to_raw_data;
uint32_t pointer_to_relocations;
uint32_t pointer_to_line_numbers;
uint16_t number_of_relocations;
uint16_t number_of_line_numbers;
uint32_t characteristics;
} b_coff_section_header;
/* Coff symbol name. */
typedef union {
char short_name[8];
struct {
unsigned char zeroes[4];
unsigned char off[4];
} long_name;
} b_coff_name;
/* Coff symbol (external representation which is unaligned). */
typedef struct {
b_coff_name name;
unsigned char value[4];
unsigned char section_number[2];
unsigned char type[2];
unsigned char storage_class;
unsigned char number_of_aux_symbols;
} b_coff_external_symbol;
/* Symbol types. */
#define N_TBSHFT 4 /* Shift for the derived type. */
#define IMAGE_SYM_DTYPE_FUNCTION 2 /* Function derived type. */
/* Size of a coff symbol. */
#define SYM_SZ 18
/* Coff symbol, internal representation (aligned). */
typedef struct {
const char *name;
uint32_t value;
int16_t sec;
uint16_t type;
uint16_t sc;
} b_coff_internal_symbol;
/* An index of sections we care about. */
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] =
{
".debug_info",
".debug_line",
".debug_abbrev",
".debug_ranges",
".debug_str"
};
/* Information we gather for the sections we care about. */
struct debug_section_info
{
/* Section file offset. */
off_t offset;
/* Section size. */
size_t size;
/* Section contents, after read from file. */
const unsigned char *data;
};
/* Information we keep for an coff symbol. */
struct coff_symbol
{
/* The name of the symbol. */
const char *name;
/* The address of the symbol. */
uintptr_t address;
};
/* Information to pass to coff_syminfo. */
struct coff_syminfo_data
{
/* Symbols for the next module. */
struct coff_syminfo_data *next;
/* The COFF symbols, sorted by address. */
struct coff_symbol *symbols;
/* The number of symbols. */
size_t count;
};
/* A dummy callback function used when we can't find any debug info. */
static int
coff_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED,
uintptr_t pc ATTRIBUTE_UNUSED,
backtrace_full_callback callback ATTRIBUTE_UNUSED,
backtrace_error_callback error_callback, void *data)
{
error_callback (data, "no debug info in PE/COFF executable", -1);
return 0;
}
/* A dummy callback function used when we can't find a symbol
table. */
static void
coff_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED,
uintptr_t addr ATTRIBUTE_UNUSED,
backtrace_syminfo_callback callback ATTRIBUTE_UNUSED,
backtrace_error_callback error_callback, void *data)
{
error_callback (data, "no symbol table in PE/COFF executable", -1);
}
/* Read a potentially unaligned 4 byte word at P, using native endianness. */
static uint32_t
coff_read4 (const unsigned char *p)
{
uint32_t res;
memcpy (&res, p, 4);
return res;
}
/* Read a potentially unaligned 2 byte word at P, using native endianness.
All 2 byte word in symbols are always aligned, but for coherency all
fields are declared as char arrays. */
static uint16_t
coff_read2 (const unsigned char *p)
{
uint16_t res;
memcpy (&res, p, sizeof (res));
return res;
}
/* Return the length (without the trailing 0) of a COFF short name. */
static size_t
coff_short_name_len (const char *name)
{
int i;
for (i = 0; i < 8; i++)
if (name[i] == 0)
return i;
return 8;
}
/* Return true iff COFF short name CNAME is the same as NAME (a NUL-terminated
string). */
static int
coff_short_name_eq (const char *name, const char *cname)
{
int i;
for (i = 0; i < 8; i++)
{
if (name[i] != cname[i])
return 0;
if (name[i] == 0)
return 1;
}
return name[8] == 0;
}
/* Return true iff NAME is the same as string at offset OFF. */
static int
coff_long_name_eq (const char *name, unsigned int off,
struct backtrace_view *str_view)
{
if (off >= str_view->len)
return 0;
return strcmp (name, (const char *)str_view->data + off) == 0;
}
/* Compare struct coff_symbol for qsort. */
static int
coff_symbol_compare (const void *v1, const void *v2)
{
const struct coff_symbol *e1 = (const struct coff_symbol *) v1;
const struct coff_symbol *e2 = (const struct coff_symbol *) v2;
if (e1->address < e2->address)
return -1;
else if (e1->address > e2->address)
return 1;
else
return 0;
}
/* Convert SYM to internal (and aligned) format ISYM, using string table
from STRTAB and STRTAB_SIZE, and number of sections SECTS_NUM.
Return -1 in case of error (invalid section number or string index). */
static int
coff_expand_symbol (b_coff_internal_symbol *isym,
const b_coff_external_symbol *sym,
uint16_t sects_num,
const unsigned char *strtab, size_t strtab_size)
{
isym->type = coff_read2 (sym->type);
isym->sec = coff_read2 (sym->section_number);
isym->sc = sym->storage_class;
if (isym->sec > 0 && (uint16_t) isym->sec > sects_num)
return -1;
if (sym->name.short_name[0] != 0)
isym->name = sym->name.short_name;
else
{
uint32_t off = coff_read4 (sym->name.long_name.off);
if (off >= strtab_size)
return -1;
isym->name = (const char *) strtab + off;
}
return 0;
}
/* Return true iff SYM is a defined symbol for a function. Data symbols
aren't considered because they aren't easily identified (same type as
section names, presence of symbols defined by the linker script). */
static int
coff_is_function_symbol (const b_coff_internal_symbol *isym)
{
return (isym->type >> N_TBSHFT) == IMAGE_SYM_DTYPE_FUNCTION
&& isym->sec > 0;
}
/* Initialize the symbol table info for coff_syminfo. */
static int
coff_initialize_syminfo (struct backtrace_state *state,
uintptr_t base_address,
const b_coff_section_header *sects, size_t sects_num,
const b_coff_external_symbol *syms, size_t syms_size,
const unsigned char *strtab, size_t strtab_size,
backtrace_error_callback error_callback,
void *data, struct coff_syminfo_data *sdata)
{
size_t syms_count;
char *coff_symstr;
size_t coff_symstr_len;
size_t coff_symbol_count;
size_t coff_symbol_size;
struct coff_symbol *coff_symbols;
struct coff_symbol *coff_sym;
char *coff_str;
size_t i;
syms_count = syms_size / SYM_SZ;
/* We only care about function symbols. Count them. Also count size of
strings for in-symbol names. */
coff_symbol_count = 0;
coff_symstr_len = 0;
for (i = 0; i < syms_count; ++i)
{
const b_coff_external_symbol *asym = &syms[i];
b_coff_internal_symbol isym;
if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size) < 0)
{
error_callback (data, "invalid section or offset in coff symbol", 0);
return 0;
}
if (coff_is_function_symbol (&isym))
{
++coff_symbol_count;
if (asym->name.short_name[0] != 0)
coff_symstr_len += coff_short_name_len (asym->name.short_name) + 1;
}
i += asym->number_of_aux_symbols;
}
coff_symbol_size = (coff_symbol_count + 1) * sizeof (struct coff_symbol);
coff_symbols = ((struct coff_symbol *)
backtrace_alloc (state, coff_symbol_size, error_callback,
data));
if (coff_symbols == NULL)
return 0;
/* Allocate memory for symbols strings. */
if (coff_symstr_len > 0)
{
coff_symstr = ((char *)
backtrace_alloc (state, coff_symstr_len, error_callback,
data));
if (coff_symstr == NULL)
{
backtrace_free (state, coff_symbols, coff_symbol_size,
error_callback, data);
return 0;
}
}
else
coff_symstr = NULL;
/* Copy symbols. */
coff_sym = coff_symbols;
coff_str = coff_symstr;
for (i = 0; i < syms_count; ++i)
{
const b_coff_external_symbol *asym = &syms[i];
b_coff_internal_symbol isym;
if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size))
{
/* Should not fail, as it was already tested in the previous
loop. */
abort ();
}
if (coff_is_function_symbol (&isym))
{
const char *name;
int16_t secnum;
if (asym->name.short_name[0] != 0)
{
size_t len = coff_short_name_len (isym.name);
name = coff_str;
memcpy (coff_str, isym.name, len);
coff_str[len] = 0;
coff_str += len + 1;
}
else
name = isym.name;
/* Strip leading '_'. */
if (name[0] == '_')
name++;
/* Symbol value is section relative, so we need to read the address
of its section. */
secnum = coff_read2 (asym->section_number);
coff_sym->name = name;
coff_sym->address = (coff_read4 (asym->value)
+ sects[secnum - 1].virtual_address
+ base_address);
coff_sym++;
}
i += asym->number_of_aux_symbols;
}
/* End of symbols marker. */
coff_sym->name = NULL;
coff_sym->address = -1;
backtrace_qsort (coff_symbols, coff_symbol_count,
sizeof (struct coff_symbol), coff_symbol_compare);
sdata->next = NULL;
sdata->symbols = coff_symbols;
sdata->count = coff_symbol_count;
return 1;
}
/* Add EDATA to the list in STATE. */
static void
coff_add_syminfo_data (struct backtrace_state *state,
struct coff_syminfo_data *sdata)
{
if (!state->threaded)
{
struct coff_syminfo_data **pp;
for (pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data;
*pp != NULL;
pp = &(*pp)->next)
;
*pp = sdata;
}
else
{
while (1)
{
struct coff_syminfo_data **pp;
pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data;
while (1)
{
struct coff_syminfo_data *p;
p = backtrace_atomic_load_pointer (pp);
if (p == NULL)
break;
pp = &p->next;
}
if (__sync_bool_compare_and_swap (pp, NULL, sdata))
break;
}
}
}
/* Compare an ADDR against an elf_symbol for bsearch. We allocate one
extra entry in the array so that this can look safely at the next
entry. */
static int
coff_symbol_search (const void *vkey, const void *ventry)
{
const uintptr_t *key = (const uintptr_t *) vkey;
const struct coff_symbol *entry = (const struct coff_symbol *) ventry;
uintptr_t addr;
addr = *key;
if (addr < entry->address)
return -1;
else if (addr >= entry[1].address)
return 1;
else
return 0;
}
/* Return the symbol name and value for an ADDR. */
static void
coff_syminfo (struct backtrace_state *state, uintptr_t addr,
backtrace_syminfo_callback callback,
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
void *data)
{
struct coff_syminfo_data *sdata;
struct coff_symbol *sym = NULL;
if (!state->threaded)
{
for (sdata = (struct coff_syminfo_data *) state->syminfo_data;
sdata != NULL;
sdata = sdata->next)
{
sym = ((struct coff_symbol *)
bsearch (&addr, sdata->symbols, sdata->count,
sizeof (struct coff_symbol), coff_symbol_search));
if (sym != NULL)
break;
}
}
else
{
struct coff_syminfo_data **pp;
pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data;
while (1)
{
sdata = backtrace_atomic_load_pointer (pp);
if (sdata == NULL)
break;
sym = ((struct coff_symbol *)
bsearch (&addr, sdata->symbols, sdata->count,
sizeof (struct coff_symbol), coff_symbol_search));
if (sym != NULL)
break;
pp = &sdata->next;
}
}
if (sym == NULL)
callback (data, addr, NULL, 0, 0);
else
callback (data, addr, sym->name, sym->address, 0);
}
/* Add the backtrace data for one PE/COFF file. Returns 1 on success,
0 on failure (in both cases descriptor is closed). */
static int
coff_add (struct backtrace_state *state, int descriptor,
backtrace_error_callback error_callback, void *data,
fileline *fileline_fn, int *found_sym, int *found_dwarf)
{
struct backtrace_view fhdr_view;
off_t fhdr_off;
int magic_ok;
b_coff_file_header fhdr;
off_t opt_sects_off;
size_t opt_sects_size;
unsigned int sects_num;
struct backtrace_view sects_view;
int sects_view_valid;
const b_coff_optional_header *opt_hdr;
const b_coff_section_header *sects;
struct backtrace_view str_view;
int str_view_valid;
size_t str_size;
off_t str_off;
struct backtrace_view syms_view;
off_t syms_off;
size_t syms_size;
int syms_view_valid;
unsigned int syms_num;
unsigned int i;
struct debug_section_info sections[DEBUG_MAX];
off_t min_offset;
off_t max_offset;
struct backtrace_view debug_view;
int debug_view_valid;
uintptr_t image_base;
*found_sym = 0;
*found_dwarf = 0;
sects_view_valid = 0;
syms_view_valid = 0;
str_view_valid = 0;
debug_view_valid = 0;
/* Map the MS-DOS stub (if any) and extract file header offset. */
if (!backtrace_get_view (state, descriptor, 0, 0x40, error_callback,
data, &fhdr_view))
goto fail;
{
const char *vptr = (const char *)fhdr_view.data;
if (vptr[0] == 'M' && vptr[1] == 'Z')
memcpy (&fhdr_off, vptr + 0x3c, 4);
else
fhdr_off = 0;
}
backtrace_release_view (state, &fhdr_view, error_callback, data);
/* Map the coff file header. */
if (!backtrace_get_view (state, descriptor, fhdr_off,
sizeof (b_coff_file_header) + 4,
error_callback, data, &fhdr_view))
goto fail;
if (fhdr_off != 0)
{
const char *magic = (const char *) fhdr_view.data;
magic_ok = memcmp (magic, "PE\0", 4) == 0;
fhdr_off += 4;
memcpy (&fhdr, fhdr_view.data + 4, sizeof fhdr);
}
else
{
memcpy (&fhdr, fhdr_view.data, sizeof fhdr);
/* TODO: test fhdr.machine for coff but non-PE platforms. */
magic_ok = 0;
}
backtrace_release_view (state, &fhdr_view, error_callback, data);
if (!magic_ok)
{
error_callback (data, "executable file is not COFF", 0);
goto fail;
}
sects_num = fhdr.number_of_sections;
syms_num = fhdr.number_of_symbols;
opt_sects_off = fhdr_off + sizeof (fhdr);
opt_sects_size = (fhdr.size_of_optional_header
+ sects_num * sizeof (b_coff_section_header));
/* To translate PC to file/line when using DWARF, we need to find
the .debug_info and .debug_line sections. */
/* Read the optional header and the section headers. */
if (!backtrace_get_view (state, descriptor, opt_sects_off, opt_sects_size,
error_callback, data, &sects_view))
goto fail;
sects_view_valid = 1;
opt_hdr = (const b_coff_optional_header *) sects_view.data;
sects = (const b_coff_section_header *)
(sects_view.data + fhdr.size_of_optional_header);
if (fhdr.size_of_optional_header > sizeof (*opt_hdr))
{
if (opt_hdr->magic == PE_MAGIC)
image_base = opt_hdr->u.pe.image_base;
else if (opt_hdr->magic == PEP_MAGIC)
image_base = opt_hdr->u.pep.image_base;
else
{
error_callback (data, "bad magic in PE optional header", 0);
goto fail;
}
}
else
image_base = 0;
/* Read the symbol table and the string table. */
if (fhdr.pointer_to_symbol_table == 0)
{
/* No symbol table, no string table. */
str_off = 0;
str_size = 0;
syms_num = 0;
syms_size = 0;
}
else
{
/* Symbol table is followed by the string table. The string table
starts with its length (on 4 bytes).
Map the symbol table and the length of the string table. */
syms_off = fhdr.pointer_to_symbol_table;
syms_size = syms_num * SYM_SZ;
if (!backtrace_get_view (state, descriptor, syms_off, syms_size + 4,
error_callback, data, &syms_view))
goto fail;
syms_view_valid = 1;
memcpy (&str_size, syms_view.data + syms_size, 4);
str_off = syms_off + syms_size;
if (str_size > 4)
{
/* Map string table (including the length word). */
if (!backtrace_get_view (state, descriptor, str_off, str_size,
error_callback, data, &str_view))
goto fail;
str_view_valid = 1;
}
}
memset (sections, 0, sizeof sections);
/* Look for the symbol table. */
for (i = 0; i < sects_num; ++i)
{
const b_coff_section_header *s = sects + i;
unsigned int str_off;
int j;
if (s->name[0] == '/')
{
/* Extended section name. */
str_off = atoi (s->name + 1);
}
else
str_off = 0;
for (j = 0; j < (int) DEBUG_MAX; ++j)
{
const char *dbg_name = debug_section_names[j];
int match;
if (str_off != 0)
match = coff_long_name_eq (dbg_name, str_off, &str_view);
else
match = coff_short_name_eq (dbg_name, s->name);
if (match)
{
sections[j].offset = s->pointer_to_raw_data;
sections[j].size = s->virtual_size <= s->size_of_raw_data ?
s->virtual_size : s->size_of_raw_data;
break;
}
}
}
if (syms_num != 0)
{
struct coff_syminfo_data *sdata;
sdata = ((struct coff_syminfo_data *)
backtrace_alloc (state, sizeof *sdata, error_callback, data));
if (sdata == NULL)
goto fail;
if (!coff_initialize_syminfo (state, image_base,
sects, sects_num,
syms_view.data, syms_size,
str_view.data, str_size,
error_callback, data, sdata))
{
backtrace_free (state, sdata, sizeof *sdata, error_callback, data);
goto fail;
}
*found_sym = 1;
coff_add_syminfo_data (state, sdata);
}
backtrace_release_view (state, &sects_view, error_callback, data);
sects_view_valid = 0;
backtrace_release_view (state, &syms_view, error_callback, data);
syms_view_valid = 0;
/* Read all the debug sections in a single view, since they are
probably adjacent in the file. We never release this view. */
min_offset = 0;
max_offset = 0;
for (i = 0; i < (int) DEBUG_MAX; ++i)
{
off_t end;
if (sections[i].size == 0)
continue;
if (min_offset == 0 || sections[i].offset < min_offset)
min_offset = sections[i].offset;
end = sections[i].offset + sections[i].size;
if (end > max_offset)
max_offset = end;
}
if (min_offset == 0 || max_offset == 0)
{
if (!backtrace_close (descriptor, error_callback, data))
goto fail;
*fileline_fn = coff_nodebug;
return 1;
}
if (!backtrace_get_view (state, descriptor, min_offset,
max_offset - min_offset,
error_callback, data, &debug_view))
goto fail;
debug_view_valid = 1;
/* We've read all we need from the executable. */
if (!backtrace_close (descriptor, error_callback, data))
goto fail;
descriptor = -1;
for (i = 0; i < (int) DEBUG_MAX; ++i)
{
if (sections[i].size == 0)
sections[i].data = NULL;
else
sections[i].data = ((const unsigned char *) debug_view.data
+ (sections[i].offset - min_offset));
}
if (!backtrace_dwarf_add (state, /* base_address */ 0,
sections[DEBUG_INFO].data,
sections[DEBUG_INFO].size,
sections[DEBUG_LINE].data,
sections[DEBUG_LINE].size,
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;
*found_dwarf = 1;
return 1;
fail:
if (sects_view_valid)
backtrace_release_view (state, &sects_view, error_callback, data);
if (str_view_valid)
backtrace_release_view (state, &str_view, error_callback, data);
if (syms_view_valid)
backtrace_release_view (state, &syms_view, error_callback, data);
if (debug_view_valid)
backtrace_release_view (state, &debug_view, error_callback, data);
if (descriptor != -1)
backtrace_close (descriptor, error_callback, data);
return 0;
}
/* Initialize the backtrace data we need from an ELF executable. At
the ELF level, all we need to do is find the debug info
sections. */
int
backtrace_initialize (struct backtrace_state *state, int descriptor,
backtrace_error_callback error_callback,
void *data, fileline *fileline_fn)
{
int ret;
int found_sym;
int found_dwarf;
fileline coff_fileline_fn;
ret = coff_add (state, descriptor, error_callback, data,
&coff_fileline_fn, &found_sym, &found_dwarf);
if (!ret)
return 0;
if (!state->threaded)
{
if (found_sym)
state->syminfo_fn = coff_syminfo;
else if (state->syminfo_fn == NULL)
state->syminfo_fn = coff_nosyms;
}
else
{
if (found_sym)
backtrace_atomic_store_pointer (&state->syminfo_fn, coff_syminfo);
else
__sync_bool_compare_and_swap (&state->syminfo_fn, NULL, coff_nosyms);
}
if (!state->threaded)
{
if (state->fileline_fn == NULL || state->fileline_fn == coff_nodebug)
*fileline_fn = coff_fileline_fn;
}
else
{
fileline current_fn;
current_fn = backtrace_atomic_load_pointer (&state->fileline_fn);
if (current_fn == NULL || current_fn == coff_nodebug)
*fileline_fn = coff_fileline_fn;
}
return 1;
}

View File

@ -8,9 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use io::prelude::*;
use io;
use io::prelude::*;
use str;
use libc;
#[cfg(target_pointer_width = "64")]
pub const HEX_WIDTH: usize = 18;
@ -18,6 +19,31 @@ pub const HEX_WIDTH: usize = 18;
#[cfg(target_pointer_width = "32")]
pub const HEX_WIDTH: usize = 10;
// These output functions should now be used everywhere to ensure consistency.
pub fn output(w: &mut Write, idx: isize, addr: *mut libc::c_void,
s: Option<&[u8]>) -> io::Result<()> {
try!(write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH));
match s.and_then(|s| str::from_utf8(s).ok()) {
Some(string) => try!(demangle(w, string)),
None => try!(write!(w, "<unknown>")),
}
w.write_all(&['\n' as u8])
}
#[allow(dead_code)]
pub fn output_fileline(w: &mut Write, file: &[u8], line: libc::c_int,
more: bool) -> io::Result<()> {
let file = str::from_utf8(file).unwrap_or("<unknown>");
// prior line: " ##: {:2$} - func"
try!(write!(w, " {:3$}at {}:{}", "", file, line, HEX_WIDTH));
if more {
try!(write!(w, " <... and possibly more>"));
}
w.write_all(&['\n' as u8])
}
// All rust symbols are in theory lists of "::"-separated identifiers. Some
// assemblers, however, can't handle these characters in symbol names. To get
// around this, we use C++-style mangling. The mangling method is:

View File

@ -11,13 +11,12 @@
use io;
use io::prelude::*;
use libc;
use sys_common::backtrace::{output, output_fileline};
use sys::backtrace::{output, output_fileline};
pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void,
symaddr: *mut libc::c_void) -> io::Result<()> {
use env;
use ffi::CStr;
use os::unix::prelude::*;
use ptr;
////////////////////////////////////////////////////////////////////////
@ -129,14 +128,15 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void,
let selfname = if cfg!(target_os = "freebsd") ||
cfg!(target_os = "dragonfly") ||
cfg!(target_os = "bitrig") ||
cfg!(target_os = "openbsd") {
cfg!(target_os = "openbsd") ||
cfg!(target_os = "windows") {
env::current_exe().ok()
} else {
None
};
let filename = match selfname {
let filename = match selfname.as_ref().and_then(|s| s.as_os_str().to_bytes()) {
Some(path) => {
let bytes = path.as_os_str().as_bytes();
let bytes = path;
if bytes.len() < LAST_FILENAME.len() {
let i = bytes.iter();
for (slot, val) in LAST_FILENAME.iter_mut().zip(i) {

View File

@ -0,0 +1,15 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
pub mod libbacktrace;

View File

@ -23,6 +23,10 @@ pub mod thread_info;
pub mod thread_local;
pub mod wtf8;
#[cfg(any(all(unix, not(any(target_os = "macos", target_os = "ios"))),
all(windows, target_env = "gnu")))]
pub mod gnu;
// common error constructors
/// A trait for viewing representations from std types

View File

@ -85,36 +85,7 @@
pub use self::tracing::write;
use io;
use io::prelude::*;
use libc;
use str;
use sys_common::backtrace::{demangle, HEX_WIDTH};
// tracing impls:
mod tracing;
// symbol resolvers:
mod printing;
pub fn output(w: &mut Write, idx: isize, addr: *mut libc::c_void,
s: Option<&[u8]>) -> io::Result<()> {
try!(write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH));
match s.and_then(|s| str::from_utf8(s).ok()) {
Some(string) => try!(demangle(w, string)),
None => try!(write!(w, "<unknown>")),
}
w.write_all(&['\n' as u8])
}
#[allow(dead_code)]
pub fn output_fileline(w: &mut Write, file: &[u8], line: libc::c_int,
more: bool) -> io::Result<()> {
let file = str::from_utf8(file).unwrap_or("<unknown>");
// prior line: " ##: {:2$} - func"
try!(write!(w, " {:3$}at {}:{}", "", file, line, HEX_WIDTH));
if more {
try!(write!(w, " <... and possibly more>"));
}
w.write_all(&['\n' as u8])
}

View File

@ -14,7 +14,7 @@ use libc;
pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void,
_symaddr: *mut libc::c_void) -> io::Result<()> {
use sys::backtrace::{output};
use sys_common::backtrace::{output};
use intrinsics;
use ffi::CStr;

View File

@ -0,0 +1,11 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub use sys_common::gnu::libbacktrace::print;

View File

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub use self::imp::*;
pub use self::imp::print;
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[path = "dladdr.rs"]
mod imp;
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
#[path = "libbacktrace.rs"]
#[path = "gnu.rs"]
mod imp;

View File

@ -27,17 +27,28 @@
use io::prelude::*;
use dynamic_lib::DynamicLibrary;
use ffi::CStr;
use intrinsics;
use io;
use libc;
use mem;
use path::Path;
use ptr;
use str;
use sync::StaticMutex;
use sys_common::backtrace::*;
macro_rules! sym{ ($lib:expr, $e:expr, $t:ident) => (unsafe {
let lib = $lib;
match lib.symbol($e) {
Ok(f) => $crate::mem::transmute::<*mut u8, $t>(f),
Err(..) => return Ok(())
}
}) }
#[cfg(target_env = "msvc")]
#[path = "printing/msvc.rs"]
mod printing;
#[cfg(target_env = "gnu")]
#[path = "printing/gnu.rs"]
mod printing;
#[allow(non_snake_case)]
extern "system" {
@ -302,23 +313,15 @@ pub fn write(w: &mut Write) -> io::Result<()> {
// Open up dbghelp.dll, we don't link to it explicitly because it can't
// always be found. Additionally, it's nice having fewer dependencies.
let path = Path::new("dbghelp.dll");
let lib = match DynamicLibrary::open(Some(&path)) {
let dbghelp = match DynamicLibrary::open(Some(&path)) {
Ok(lib) => lib,
Err(..) => return Ok(()),
};
macro_rules! sym{ ($e:expr, $t:ident) => (unsafe {
match lib.symbol($e) {
Ok(f) => mem::transmute::<*mut u8, $t>(f),
Err(..) => return Ok(())
}
}) }
// Fetch the symbols necessary from dbghelp.dll
let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn);
let SymInitialize = sym!("SymInitialize", SymInitializeFn);
let SymCleanup = sym!("SymCleanup", SymCleanupFn);
let StackWalk64 = sym!("StackWalk64", StackWalk64Fn);
let SymInitialize = sym!(&dbghelp, "SymInitialize", SymInitializeFn);
let SymCleanup = sym!(&dbghelp, "SymCleanup", SymCleanupFn);
let StackWalk64 = sym!(&dbghelp, "StackWalk64", StackWalk64Fn);
// Allocate necessary structures for doing the stack walk
let process = unsafe { GetCurrentProcess() };
@ -334,7 +337,9 @@ pub fn write(w: &mut Write) -> io::Result<()> {
let _c = Cleanup { handle: process, SymCleanup: SymCleanup };
// And now that we're done with all the setup, do the stack walking!
let mut i = 0;
// Start from -1 to avoid printing this stack frame, which will
// always be exactly the same.
let mut i = -1;
try!(write!(w, "stack backtrace:\n"));
while StackWalk64(image, process, thread, &mut frame, &mut context,
ptr::null_mut(),
@ -346,28 +351,10 @@ pub fn write(w: &mut Write) -> io::Result<()> {
frame.AddrReturn.Offset == 0 { break }
i += 1;
try!(write!(w, " {:2}: {:#2$x}", i, addr, HEX_WIDTH));
let mut info: SYMBOL_INFO = unsafe { intrinsics::init() };
info.MaxNameLen = MAX_SYM_NAME as libc::c_ulong;
// the struct size in C. the value is different to
// `size_of::<SYMBOL_INFO>() - MAX_SYM_NAME + 1` (== 81)
// due to struct alignment.
info.SizeOfStruct = 88;
let mut displacement = 0u64;
let ret = SymFromAddr(process, addr as u64, &mut displacement,
&mut info);
if ret == libc::TRUE {
try!(write!(w, " - "));
let ptr = info.Name.as_ptr() as *const libc::c_char;
let bytes = unsafe { CStr::from_ptr(ptr).to_bytes() };
match str::from_utf8(bytes) {
Ok(s) => try!(demangle(w, s)),
Err(..) => try!(w.write_all(&bytes[..bytes.len()-1])),
}
if i >= 0 {
try!(printing::print(w, i, addr-1, &dbghelp, process));
}
try!(w.write_all(&['\n' as u8]));
}
Ok(())

View File

@ -0,0 +1,22 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use dynamic_lib::DynamicLibrary;
use io;
use io::prelude::*;
use libc;
use sys_common::gnu::libbacktrace;
pub fn print(w: &mut Write, i: isize, addr: u64, _: &DynamicLibrary, _: libc::HANDLE)
-> io::Result<()> {
let addr = addr as usize as *mut libc::c_void;
libbacktrace::print(w, i, addr, addr)
}

View File

@ -0,0 +1,42 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use sys_common::backtrace::output;
use ffi::CStr;
use dynamic_lib::DynamicLibrary;
use super::{SymFromAddrFn, SYMBOL_INFO, MAX_SYM_NAME};
use io;
use io::prelude::*;
use intrinsics;
use libc;
pub fn print(w: &mut Write, i: isize, addr: u64, dbghelp: &DynamicLibrary, process: libc::HANDLE)
-> io::Result<()> {
let SymFromAddr = sym!(dbghelp, "SymFromAddr", SymFromAddrFn);
let mut info: SYMBOL_INFO = unsafe { intrinsics::init() };
info.MaxNameLen = MAX_SYM_NAME as libc::c_ulong;
// the struct size in C. the value is different to
// `size_of::<SYMBOL_INFO>() - MAX_SYM_NAME + 1` (== 81)
// due to struct alignment.
info.SizeOfStruct = 88;
let mut displacement = 0u64;
let ret = SymFromAddr(process, addr as u64, &mut displacement, &mut info);
let name = if ret == libc::TRUE {
let ptr = info.Name.as_ptr() as *const libc::c_char;
Some(unsafe { CStr::from_ptr(ptr).to_bytes() })
} else {
None
};
output(w, i, addr as usize as *mut libc::c_void, name)
}

View File

@ -27,11 +27,12 @@ macro_rules! pos {
() => ((file!(), line!()))
}
#[cfg(all(unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android"),
not(all(target_os = "linux", target_arch = "arm"))))]
#[cfg(any(all(unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android"),
not(all(target_os = "linux", target_arch = "arm"))),
all(windows, target_env = "gnu", not(target_arch = "x86"))))]
macro_rules! dump_and_die {
($($pos:expr),*) => ({
// FIXME(#18285): we cannot include the current position because
@ -42,11 +43,12 @@ macro_rules! dump_and_die {
}
// this does not work on Windows, Android, OSX or iOS
#[cfg(any(not(unix),
target_os = "macos",
target_os = "ios",
target_os = "android",
all(target_os = "linux", target_arch = "arm")))]
#[cfg(not(any(all(unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android"),
not(all(target_os = "linux", target_arch = "arm"))),
all(windows, target_env = "gnu", not(target_arch = "x86")))))]
macro_rules! dump_and_die {
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
}
@ -165,3 +167,4 @@ fn main() {
run_test(&args[0]);
}
}

View File

@ -9,8 +9,8 @@
// except according to those terms.
// no-pretty-expanded FIXME #15189
// ignore-windows FIXME #13259
// ignore-android FIXME #17520
// ignore-msvc FIXME #28133
use std::env;
use std::process::{Command, Stdio};
@ -89,6 +89,7 @@ fn runtest(me: &str) {
"bad output4: {}", s);
}
#[cfg(not(all(windows, target_arch = "x86")))]
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "fail" {
@ -99,3 +100,7 @@ fn main() {
runtest(&args[0]);
}
}
// See issue 28218
#[cfg(all(windows, target_arch = "x86"))]
fn main() {}