On Wed, Jul 3, 2013 at 9:58 AM, Mike Frysinger <vap...@gentoo.org> wrote: > On Tuesday 02 July 2013 21:54:17 Luca Clementi wrote: >> Regarding PKG_CHECKS_MODULE I am not too convinced (although I must >> say that I am not an expert of autoconf). >> For example Ubuntu 12.04 the system libunwind7 and libunwind7-dev do >> not include the .pc files needed by PKG_CHECKS_MODULE. > > looks like they're new to the 1.1 release. you should still default to > checking the .pc files. just add fallback logic to support older versions. > > something like this untested snippet: > PKG_CHECK_MODULES([LIBUNWIND], [libunwind-generic], > [CFLAGS="$CFLAGS $LIBUNWIND_CFLAGS" LIBS="$LIBS $LIBUNWIND_LIBS"], > [... AC_CHECK_LIB fallback logic ...])
Hey Mike, I did some tests on this, and they are not just new to 1.1 but they are also missing the: Cflags section. So I can't get the include path from them anyway. So far I have a solution with ac_check_lib that works with both distribution installation and local installation and uses the --with-libunwind=/path/to/unwind flag. Provided the .pc file were not missing the Cflags what would be the advantage of having 10 extra line to manage the checks with pkg_check_modules? Luca diff --git a/Makefile.am b/Makefile.am index 9d611f3..c8ad026 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ ARCH = @arch@ ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = $(WARN_CFLAGS) -AM_CPPFLAGS = -I$(srcdir)/$(OS)/$(ARCH) -I$(srcdir)/$(OS) -I$(builddir)/$(OS) +AM_CPPFLAGS = -I$(srcdir)/$(OS)/$(ARCH) -I$(srcdir)/$(OS) -I$(builddir)/$(OS) $(libunwind_CPPFLAGS) strace_SOURCES = \ bjm.c \ @@ -43,6 +43,14 @@ strace_SOURCES = \ util.c \ vsprintf.c + +if LIB_UNWIND +strace_SOURCES += unwind.c +strace_LDADD = $(libunwind_LIBS) +AM_LDFLAGS = $(libunwind_LDFLAGS) +endif + + noinst_HEADERS = defs.h # Enable this to get link map generated #strace_CFLAGS = $(AM_CFLAGS) -Wl,-Map=strace.mapfile diff --git a/configure.ac b/configure.ac index 03e49fe..526fbda 100644 --- 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]) + +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 + + 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}" + + dnl we have all the dependencies we need we can activate stack tracing + AC_SUBST(libunwind_LIBS) + AC_SUBST(libunwind_LDFLAGS) + AC_SUBST(libunwind_CPPFLAGS) + AC_DEFINE([LIB_UNWIND], 1, [Compile stack tracing functionality]) + AC_MSG_NOTICE([Enabled stack tracing]) +fi +AM_CONDITIONAL([LIB_UNWIND], [test "x$ac_cv_lib_unwind_ptrace__UPT_create" == "xyes"]) + + AC_CHECK_MEMBERS([struct utsname.domainname],,, [#include <sys/utsname.h>]) AC_CHECK_DECLS([sys_errlist]) ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel