unwind: prepare configure subsystem for alternative unwinders
Introduce --enable-stacktrace configure option to control whether -k option support is compiled in, --with-libunwind option remains available to control whether libunwind can be used as an unwinder. * m4/st_demangle.m4: New file. * m4/st_libunwind.m4: Likewise. * m4/st_stacktrace.m4: Likewise. * configure.ac: Replace all libunwind and libiberty checks with a single st_STACKTRACE invocation. * Makefile.am: Conditionalize checks for USE_LIBUNWIND and USE_DEMANGLE on ENABLE_STACKTRACE. [ENABLE_STACKTRACE] (strace_SOURCES): Append unwind.c and unwind.h. * strace.1.in: Replace libunwind with an unwinder-agnostic wording. * defs.h: Replace USE_LIBUNWIND with ENABLE_STACKTRACE. * strace.c: Likewise. (print_version): Print stack-trace instead of stack-unwind. * syscall.c: Replace USE_LIBUNWIND with ENABLE_STACKTRACE. * tests/Makefile.am: Likewise. Replace LIBUNWIND_TESTS with STACKTRACE_TESTS. * tests/strace-V.test: Update expected output.
This commit is contained in:
parent
cbaa5db24d
commit
2713444cb7
@ -349,11 +349,14 @@ strace_SOURCES = \
|
||||
|
||||
strace_SOURCES_check = bpf_attr_check.c
|
||||
|
||||
if ENABLE_STACKTRACE
|
||||
strace_SOURCES += unwind.c unwind.h
|
||||
if USE_LIBUNWIND
|
||||
strace_SOURCES += unwind.c unwind.h unwind-libunwind.c
|
||||
strace_SOURCES += unwind-libunwind.c
|
||||
strace_CPPFLAGS += $(libunwind_CPPFLAGS)
|
||||
strace_LDFLAGS += $(libunwind_LDFLAGS)
|
||||
strace_LDADD += $(libunwind_LIBS)
|
||||
endif
|
||||
if USE_DEMANGLE
|
||||
strace_CPPFLAGS += $(libiberty_CPPFLAGS)
|
||||
strace_LDFLAGS += $(libiberty_LDFLAGS)
|
||||
|
143
configure.ac
143
configure.ac
@ -844,148 +844,7 @@ AC_PATH_PROG([PERL], [perl])
|
||||
|
||||
AC_CHECK_TOOL([READELF], [readelf])
|
||||
|
||||
dnl stack trace with libunwind
|
||||
libunwind_CPPFLAGS=
|
||||
libunwind_LDFLAGS=
|
||||
libunwind_LIBS=
|
||||
AC_ARG_WITH([libunwind],
|
||||
[AS_HELP_STRING([--with-libunwind],
|
||||
[use libunwind to implement stack tracing support])],
|
||||
[case "${withval}" in
|
||||
yes|no|check) ;;
|
||||
*) with_libunwind=yes
|
||||
libunwind_CPPFLAGS="-I${withval}/include"
|
||||
libunwind_LDFLAGS="-L${withval}/lib" ;;
|
||||
esac],
|
||||
[with_libunwind=check]
|
||||
)
|
||||
|
||||
use_libunwind=no
|
||||
AS_IF([test "x$with_libunwind" != xno],
|
||||
[saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $libunwind_CPPFLAGS"
|
||||
|
||||
AC_CHECK_HEADERS([libunwind-ptrace.h],
|
||||
[saved_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $libunwind_LDFLAGS"
|
||||
|
||||
AC_CHECK_LIB([unwind], [backtrace],
|
||||
[libunwind_LIBS="-lunwind $libunwind_LIBS"
|
||||
|
||||
AC_MSG_CHECKING([for unw_create_addr_space in libunwind-generic])
|
||||
saved_LIBS="$LIBS"
|
||||
LIBS="-lunwind-generic $libunwind_LIBS $LIBS"
|
||||
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <libunwind-ptrace.h>]],
|
||||
[[return !unw_create_addr_space(0, 0)]])
|
||||
],
|
||||
[AC_MSG_RESULT([yes])
|
||||
libunwind_LIBS="-lunwind-generic $libunwind_LIBS"
|
||||
|
||||
AC_CHECK_LIB([unwind-ptrace], [_UPT_create],
|
||||
[libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"
|
||||
use_libunwind=yes
|
||||
],
|
||||
[if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find _UPT_create in libunwind-ptrace])
|
||||
fi
|
||||
],
|
||||
[$libunwind_LIBS]
|
||||
)
|
||||
],
|
||||
[AC_MSG_RESULT([no])
|
||||
if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find unw_create_addr_space in libunwind-generic])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
LIBS="$saved_LIBS"
|
||||
],
|
||||
[if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find libunwind])
|
||||
fi
|
||||
],
|
||||
[$libunwind_LIBS]
|
||||
)
|
||||
|
||||
LDFLAGS="$saved_LDFLAGS"
|
||||
],
|
||||
[if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find libunwind-ptrace.h])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
]
|
||||
)
|
||||
|
||||
dnl enable libunwind
|
||||
AC_MSG_CHECKING([whether to enable stack tracing support using libunwind])
|
||||
if test "x$use_libunwind" = xyes; then
|
||||
AC_DEFINE([USE_LIBUNWIND], 1, [Compile stack tracing functionality])
|
||||
AC_SUBST(libunwind_LIBS)
|
||||
AC_SUBST(libunwind_LDFLAGS)
|
||||
AC_SUBST(libunwind_CPPFLAGS)
|
||||
fi
|
||||
AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes])
|
||||
AC_MSG_RESULT([$use_libunwind])
|
||||
|
||||
dnl demangling symbols in the stack trace
|
||||
libiberty_CPPFLAGS=
|
||||
libiberty_LDFLAGS=
|
||||
libiberty_LIBS=
|
||||
AC_ARG_WITH([libiberty],
|
||||
[AS_HELP_STRING([--with-libiberty],
|
||||
[use libiberty to demangle symbols in stack trace])],
|
||||
[case "${withval}" in
|
||||
yes|no|check) ;;
|
||||
*) with_libiberty=yes
|
||||
libiberty_CPPFLAGS="-I${withval}/include"
|
||||
libiberty_LDFLAGS="-L${withval}/lib" ;;
|
||||
esac],
|
||||
[with_libiberty=check]
|
||||
)
|
||||
|
||||
use_libiberty=no
|
||||
AS_IF([test "x$use_libunwind" = xyes && test "x$with_libiberty" != xno],
|
||||
[saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $libiberty_CPPFLAGS"
|
||||
AC_CHECK_HEADERS([demangle.h libiberty/demangle.h],
|
||||
[saved_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $libiberty_LDFLAGS"
|
||||
AC_CHECK_LIB([iberty],[cplus_demangle],
|
||||
[libiberty_LIBS="-liberty"
|
||||
use_libiberty=yes
|
||||
],
|
||||
[if test "x$with_libiberty" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find cplus_demangle in libiberty])
|
||||
fi
|
||||
]
|
||||
)
|
||||
LDFLAGS="$saved_LDFLAGS"
|
||||
],
|
||||
[if test "x$with_libiberty" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find demangle.h])
|
||||
fi
|
||||
]
|
||||
)
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
]
|
||||
)
|
||||
|
||||
dnl enable libiberty
|
||||
AC_MSG_CHECKING([whether to enable demangling symbols in stack trace])
|
||||
if test "x$use_libiberty" = xyes; then
|
||||
AC_DEFINE([USE_DEMANGLE], 1, [Do demangling symbols in stack trace])
|
||||
AC_SUBST(libiberty_LIBS)
|
||||
AC_SUBST(libiberty_LDFLAGS)
|
||||
AC_SUBST(libiberty_CPPFLAGS)
|
||||
fi
|
||||
AM_CONDITIONAL([USE_DEMANGLE], [test "x$use_libiberty" = xyes])
|
||||
AC_MSG_RESULT([$use_libiberty])
|
||||
st_STACKTRACE
|
||||
|
||||
if test "$arch" = mips && test "$no_create" != yes; then
|
||||
mkdir -p linux/mips
|
||||
|
6
defs.h
6
defs.h
@ -222,7 +222,7 @@ struct tcb {
|
||||
unsigned int mmap_cache_size;
|
||||
unsigned int mmap_cache_generation;
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
void *unwind_ctx;
|
||||
struct unwind_queue_t *unwind_queue;
|
||||
#endif
|
||||
@ -377,7 +377,7 @@ extern struct path_set {
|
||||
#define tracing_paths (global_path_set.num_selected != 0)
|
||||
extern unsigned xflag;
|
||||
extern unsigned followfork;
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
/* if this is true do the stack trace for every system call */
|
||||
extern bool stack_trace_enabled;
|
||||
#endif
|
||||
@ -732,7 +732,7 @@ extern void ts_sub(struct timespec *, const struct timespec *, const struct time
|
||||
extern void ts_mul(struct timespec *, const struct timespec *, int);
|
||||
extern void ts_div(struct timespec *, const struct timespec *, int);
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
extern void unwind_init(void);
|
||||
extern void unwind_tcb_init(struct tcb *);
|
||||
extern void unwind_tcb_fin(struct tcb *);
|
||||
|
82
m4/st_demangle.m4
Normal file
82
m4/st_demangle.m4
Normal file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/m4
|
||||
#
|
||||
# Copyright (c) 2017-2018 The strace developers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
AC_DEFUN([st_DEMANGLE], [dnl
|
||||
|
||||
AC_ARG_WITH([libiberty],
|
||||
[AS_HELP_STRING([--with-libiberty],
|
||||
[use libiberty to demangle symbols in stack trace])],
|
||||
[case "${withval}" in
|
||||
yes|no|check) ;;
|
||||
*) with_libiberty=yes
|
||||
libiberty_CPPFLAGS="-I${withval}/include"
|
||||
libiberty_LDFLAGS="-L${withval}/lib" ;;
|
||||
esac],
|
||||
[with_libiberty=check]
|
||||
)
|
||||
|
||||
libiberty_CPPFLAGS=
|
||||
libiberty_LDFLAGS=
|
||||
libiberty_LIBS=
|
||||
use_libiberty=no
|
||||
|
||||
AS_IF([test "x$with_libiberty" != xno],
|
||||
[saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $libiberty_CPPFLAGS"
|
||||
AC_CHECK_HEADERS([demangle.h libiberty/demangle.h],
|
||||
[saved_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $libiberty_LDFLAGS"
|
||||
AC_CHECK_LIB([iberty],[cplus_demangle],
|
||||
[libiberty_LIBS="-liberty"
|
||||
use_libiberty=yes
|
||||
],
|
||||
[if test "x$with_libiberty" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find cplus_demangle in libiberty])
|
||||
fi
|
||||
]
|
||||
)
|
||||
LDFLAGS="$saved_LDFLAGS"
|
||||
],
|
||||
[if test "x$with_libiberty" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find demangle.h])
|
||||
fi
|
||||
]
|
||||
)
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([whether to enable symbols demangling in stack trace])
|
||||
if test "x$use_libiberty" = xyes; then
|
||||
AC_DEFINE([USE_DEMANGLE], 1, [Do symbols demangling in stack trace])
|
||||
AC_SUBST(libiberty_LIBS)
|
||||
AC_SUBST(libiberty_LDFLAGS)
|
||||
AC_SUBST(libiberty_CPPFLAGS)
|
||||
fi
|
||||
AC_MSG_RESULT([$use_libiberty])
|
||||
|
||||
])
|
119
m4/st_libunwind.m4
Normal file
119
m4/st_libunwind.m4
Normal file
@ -0,0 +1,119 @@
|
||||
#!/usr/bin/m4
|
||||
#
|
||||
# Copyright (c) 2013-2018 The strace developers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
AC_DEFUN([st_ARG_LIBUNWIND], [dnl
|
||||
|
||||
AC_ARG_WITH([libunwind],
|
||||
[AS_HELP_STRING([--with-libunwind],
|
||||
[use libunwind to implement stack tracing support])],
|
||||
[case "${withval}" in
|
||||
yes|no|check) ;;
|
||||
*) with_libunwind=yes
|
||||
libunwind_CPPFLAGS="-I${withval}/include"
|
||||
libunwind_LDFLAGS="-L${withval}/lib" ;;
|
||||
esac],
|
||||
[with_libunwind=check]
|
||||
)
|
||||
|
||||
])
|
||||
|
||||
AC_DEFUN([st_LIBUNWIND], [dnl
|
||||
|
||||
libunwind_CPPFLAGS=
|
||||
libunwind_LDFLAGS=
|
||||
libunwind_LIBS=
|
||||
|
||||
AS_IF([test "x$with_libunwind" != xno && test "x$use_unwinder" = x],
|
||||
[saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $libunwind_CPPFLAGS"
|
||||
|
||||
AC_CHECK_HEADERS([libunwind-ptrace.h],
|
||||
[saved_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $libunwind_LDFLAGS"
|
||||
|
||||
AC_CHECK_LIB([unwind], [backtrace],
|
||||
[libunwind_LIBS="-lunwind $libunwind_LIBS"
|
||||
|
||||
AC_MSG_CHECKING([for unw_create_addr_space in libunwind-generic])
|
||||
saved_LIBS="$LIBS"
|
||||
LIBS="-lunwind-generic $libunwind_LIBS $LIBS"
|
||||
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <libunwind-ptrace.h>]],
|
||||
[[return !unw_create_addr_space(0, 0)]])
|
||||
],
|
||||
[AC_MSG_RESULT([yes])
|
||||
libunwind_LIBS="-lunwind-generic $libunwind_LIBS"
|
||||
|
||||
AC_CHECK_LIB([unwind-ptrace], [_UPT_create],
|
||||
[libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"
|
||||
use_unwinder=libunwind
|
||||
],
|
||||
[if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find _UPT_create in libunwind-ptrace])
|
||||
fi
|
||||
],
|
||||
[$libunwind_LIBS]
|
||||
)
|
||||
],
|
||||
[AC_MSG_RESULT([no])
|
||||
if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find unw_create_addr_space in libunwind-generic])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
LIBS="$saved_LIBS"
|
||||
],
|
||||
[if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find libunwind])
|
||||
fi
|
||||
],
|
||||
[$libunwind_LIBS]
|
||||
)
|
||||
|
||||
LDFLAGS="$saved_LDFLAGS"
|
||||
],
|
||||
[if test "x$with_libunwind" != xcheck; then
|
||||
AC_MSG_FAILURE([failed to find libunwind-ptrace.h])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
]
|
||||
)
|
||||
|
||||
if test "x$use_unwinder" = xlibunwind; then
|
||||
AC_DEFINE([USE_LIBUNWIND], 1,
|
||||
[Whether to use libunwind for stack tracing])
|
||||
AC_SUBST(libunwind_LIBS)
|
||||
AC_SUBST(libunwind_LDFLAGS)
|
||||
AC_SUBST(libunwind_CPPFLAGS)
|
||||
fi
|
||||
|
||||
])
|
67
m4/st_stacktrace.m4
Normal file
67
m4/st_stacktrace.m4
Normal file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/m4
|
||||
#
|
||||
# Copyright (c) 2018 The strace developers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
AC_DEFUN([st_STACKTRACE], [dnl
|
||||
|
||||
AC_ARG_ENABLE([stacktrace],
|
||||
[AS_HELP_STRING([--enable-stacktrace=yes|no|check],
|
||||
[whether to enable stack tracing support, default is check])],
|
||||
[case "$enableval" in
|
||||
yes|no|check) enable_stacktrace="$enableval" ;;
|
||||
*) AC_MSG_ERROR([bad value $enableval for enable-stacktrace option.
|
||||
Valid options are: yes, no, check.])
|
||||
;;
|
||||
esac],
|
||||
[enable_stacktrace=check])
|
||||
|
||||
use_unwinder=
|
||||
dnl Whether to enable stack tracing support?
|
||||
|
||||
AS_IF([test x"$enable_stacktrace" != xno],
|
||||
[st_ARG_LIBUNWIND
|
||||
AS_IF([test "x$use_unwinder" = x], [st_LIBUNWIND])
|
||||
AS_IF([test x"$enable_stacktrace$use_unwinder" = xyes],
|
||||
[AC_MSG_ERROR([stack tracing support requires an unwinder])])])
|
||||
|
||||
AC_MSG_CHECKING([whether to enable stack tracing support])
|
||||
AM_CONDITIONAL([ENABLE_STACKTRACE], [test "x$use_unwinder" != x])
|
||||
AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_unwinder" = xlibunwind])
|
||||
|
||||
use_libiberty=
|
||||
AS_IF([test "x$use_unwinder" != x],
|
||||
[AC_DEFINE([ENABLE_STACKTRACE], [1],
|
||||
[Define to enable stack tracing support])
|
||||
AC_DEFINE_UNQUOTED([USE_UNWINDER], ["$use_unwinder"],
|
||||
[The unwinder to use for stack tracing support])
|
||||
AC_MSG_RESULT([yes, using $use_unwinder])
|
||||
dnl As stack tracing support is enabled, check for a demangler.
|
||||
st_DEMANGLE],
|
||||
[AC_MSG_RESULT([no])])
|
||||
|
||||
AM_CONDITIONAL([USE_DEMANGLE], [test "x$use_libiberty" = xyes])
|
||||
|
||||
])
|
@ -257,7 +257,7 @@ Print the instruction pointer at the time of the system call.
|
||||
Print the execution stack trace of the traced processes after each system call (experimental).
|
||||
This option is available only if
|
||||
.B strace
|
||||
is built with libunwind.
|
||||
is built using \-\-enable\-stacktrace configure option.
|
||||
.TP
|
||||
.BI "\-o " filename
|
||||
Write the trace output to the file
|
||||
|
24
strace.c
24
strace.c
@ -65,7 +65,7 @@ extern char **environ;
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
/* if this is true do the stack trace for every system call */
|
||||
bool stack_trace_enabled;
|
||||
#endif
|
||||
@ -203,12 +203,12 @@ static void
|
||||
print_version(void)
|
||||
{
|
||||
static const char features[] =
|
||||
#ifdef USE_LIBUNWIND
|
||||
" stack-unwind"
|
||||
#endif /* USE_LIBUNWIND */
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
" stack-trace=" USE_UNWINDER
|
||||
#endif
|
||||
#ifdef USE_DEMANGLE
|
||||
" stack-demangle"
|
||||
#endif /* USE_DEMANGLE */
|
||||
#endif
|
||||
#if SUPPORTED_PERSONALITIES > 1
|
||||
# if defined HAVE_M32_MPERS
|
||||
" m32-mpers"
|
||||
@ -248,7 +248,7 @@ Output format:\n\
|
||||
-a column alignment COLUMN for printing syscall results (default %d)\n\
|
||||
-i print instruction pointer at time of syscall\n\
|
||||
"
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
"\
|
||||
-k obtain stack trace between each syscall (experimental)\n\
|
||||
"
|
||||
@ -753,7 +753,7 @@ alloctcb(int pid)
|
||||
tcp->currpers = current_personality;
|
||||
#endif
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
if (stack_trace_enabled)
|
||||
unwind_tcb_init(tcp);
|
||||
#endif
|
||||
@ -810,7 +810,7 @@ droptcb(struct tcb *tcp)
|
||||
|
||||
free_tcb_priv_data(tcp);
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
if (stack_trace_enabled) {
|
||||
unwind_tcb_fin(tcp);
|
||||
}
|
||||
@ -1592,7 +1592,7 @@ init(int argc, char *argv[])
|
||||
#endif
|
||||
qualify("signal=all");
|
||||
while ((c = getopt(argc, argv, "+"
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
"k"
|
||||
#endif
|
||||
"a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxyz")) != EOF) {
|
||||
@ -1653,7 +1653,7 @@ init(int argc, char *argv[])
|
||||
if (opt_intr <= 0)
|
||||
error_opt_arg(c, optarg);
|
||||
break;
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
case 'k':
|
||||
stack_trace_enabled = true;
|
||||
break;
|
||||
@ -1754,7 +1754,7 @@ init(int argc, char *argv[])
|
||||
if (cflag == CFLAG_ONLY_STATS) {
|
||||
if (iflag)
|
||||
error_msg("-%c has no effect with -c", 'i');
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
if (stack_trace_enabled)
|
||||
error_msg("-%c has no effect with -c", 'k');
|
||||
#endif
|
||||
@ -1774,7 +1774,7 @@ init(int argc, char *argv[])
|
||||
|
||||
set_sighandler(SIGCHLD, SIG_DFL, ¶ms_for_tracee.child_sa);
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
if (stack_trace_enabled) {
|
||||
unsigned int tcbi;
|
||||
|
||||
|
@ -705,7 +705,7 @@ syscall_entering_trace(struct tcb *tcp, unsigned int *sig)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
if (stack_trace_enabled) {
|
||||
if (tcp->s_ent->sys_flags & STACKTRACE_CAPTURE_ON_ENTER)
|
||||
unwind_tcb_capture(tcp);
|
||||
@ -959,7 +959,7 @@ syscall_exiting_trace(struct tcb *tcp, struct timespec *ts, int res)
|
||||
dumpio(tcp);
|
||||
line_ended();
|
||||
|
||||
#ifdef USE_LIBUNWIND
|
||||
#ifdef ENABLE_STACKTRACE
|
||||
if (stack_trace_enabled)
|
||||
unwind_tcb_print(tcp);
|
||||
#endif
|
||||
|
@ -202,13 +202,13 @@ stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
|
||||
|
||||
include gen_tests.am
|
||||
|
||||
if USE_LIBUNWIND
|
||||
LIBUNWIND_TESTS = strace-k.test
|
||||
if ENABLE_STACKTRACE
|
||||
STACKTRACE_TESTS = strace-k.test
|
||||
if USE_DEMANGLE
|
||||
LIBUNWIND_TESTS += strace-k-demangle.test
|
||||
STACKTRACE_TESTS += strace-k-demangle.test
|
||||
endif
|
||||
else
|
||||
LIBUNWIND_TESTS =
|
||||
STACKTRACE_TESTS =
|
||||
endif
|
||||
|
||||
DECODER_TESTS = \
|
||||
@ -324,11 +324,11 @@ MISC_TESTS = \
|
||||
threads-execve.test \
|
||||
# end of MISC_TESTS
|
||||
|
||||
TESTS = $(GEN_TESTS) $(DECODER_TESTS) $(MISC_TESTS) $(LIBUNWIND_TESTS)
|
||||
TESTS = $(GEN_TESTS) $(DECODER_TESTS) $(MISC_TESTS) $(STACKTRACE_TESTS)
|
||||
|
||||
XFAIL_TESTS_ =
|
||||
XFAIL_TESTS_m32 = $(LIBUNWIND_TESTS)
|
||||
XFAIL_TESTS_mx32 = $(LIBUNWIND_TESTS)
|
||||
XFAIL_TESTS_m32 = $(STACKTRACE_TESTS)
|
||||
XFAIL_TESTS_mx32 = $(STACKTRACE_TESTS)
|
||||
XFAIL_TESTS_x86_64 = int_0x80.gen.test
|
||||
XFAIL_TESTS_x32 = int_0x80.gen.test
|
||||
XFAIL_TESTS = $(XFAIL_TESTS_$(MPERS_NAME)) $(XFAIL_TESTS_$(ARCH))
|
||||
|
@ -38,7 +38,8 @@ config_year=$(getstr COPYRIGHT_YEAR)
|
||||
exit 1
|
||||
}
|
||||
|
||||
option_unwind=$(getoption USE_LIBUNWIND " stack-unwind")
|
||||
option_unwind=$(getoption ENABLE_STACKTRACE \
|
||||
" stack-trace=$(getstr USE_UNWINDER)")
|
||||
option_demangle=$(getoption USE_DEMANGLE " stack-demangle")
|
||||
|
||||
option_m32=
|
||||
|
Loading…
x
Reference in New Issue
Block a user