[PATCHv2] print stack trace after each syscall

Dmitry V. Levin ldv at altlinux.org
Mon Jul 8 22:08:22 UTC 2013


On Mon, Jul 08, 2013 at 12:24:14AM -0700, Luca Clementi wrote:
[...]
> --- a/configure.ac
> +++ b/configure.ac
> @@ -261,6 +261,63 @@ AC_CHECK_MEMBERS([struct sigcontext.sc_hi2],,, [#include <signal.h>
>  # include <asm/sigcontext.h>
>  #endif])
>  
> +
> +dnl stack trace with libunwind
> +AC_ARG_WITH([libunwind],
> +	    [AS_HELP_STRING([--with-libunwind],
> +			    [libunwind is used to display system call stacktrace])],
> +	    [case "${withval}" in
> +	     (yes|no) enable_libunwind=$withval;;
> +	     (*)      enable_libunwind=yes
> +		      libunwind_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
> +		      libunwind_LDFLAGS="-L${withval}/lib" ;;
> +	     esac],
> +	    [enable_libunwind=maybe])

If the option is called --with-libunwind, then the options's argument
variable should be called with_libunwind.  BTW, do you really need this
libunwind_CPPFLAGS/libunwind_LDFLAGS stuff?  Wouldn't a simple tristate
(yes|no|check) be enough?

> +AS_IF([test "x$enable_libunwind" != xno],
> +	[saved_CPPFLAGS="${CPPFLAGS}"
> +	CPPFLAGS="${CPPFLAGS} ${libunwind_CPPFLAGS}"
> +	AC_CHECK_HEADERS([libunwind-ptrace.h libunwind.h])
> +	CPPFLAGS="${saved_CPPFLAGS}" ])
> +
> +if test "x$ac_cv_header_libunwind_ptrace_h" = "xyes" &&
> +	test "x$ac_cv_header_libunwind_h" = "xyes"; then

If --with-libunwind was given and one of these header files is not
available, configure should fail.

> +	dnl code is taken from ltrace
> +	case "${host_cpu}" in
> +		arm*|sa110)         UNWIND_ARCH="arm" ;;
> +		i?86)               UNWIND_ARCH="x86" ;;
> +		powerpc)            UNWIND_ARCH="ppc32" ;;
> +		powerpc64)          UNWIND_ARCH="ppc64" ;;
> +		mips*)              UNWIND_ARCH="mips" ;;
> +		*)                  UNWIND_ARCH="${host_cpu}" ;;
> +	esac
> +
> +	saved_LDFLAGS="${LDFLAGS}"
> +	LDFLAGS="${LDFLAGS} ${libunwind_LDFLAGS}"
> +	AC_CHECK_LIB([unwind], [backtrace],
> +		     [libunwind_LIBS="-lunwind"],
> +		     [AC_MSG_FAILURE([Unable to find libunwind])])
> +        AC_CHECK_LIB([unwind-generic], [_U${UNWIND_ARCH}_create_addr_space],
> +		     [libunwind_LIBS="-lunwind-generic $libunwind_LIBS"],
> +		     [AC_MSG_FAILURE([Unable to find libunwind-generic])],
> +		     [$libunwind_LIBS])
> +	AC_CHECK_LIB([unwind-ptrace], [_UPT_create],
> +		     [libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"],
> +		     [AC_MSG_FAILURE([Unable to find libunwind-ptrace])],
> +		     [$libunwind_LIBS])
> +	LDFLAGS="${saved_LDFLAGS}"

If --with-libunwind was not given and one of these symbols is not
available, configure should not fail.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20130709/e0f4af41/attachment.bin>


More information about the Strace-devel mailing list