|
|
5cd83f |
diff -u ltrace-0.7.91/configure.ac ltrace-0.7.91-pm/configure.ac
|
|
|
5cd83f |
--- ltrace-0.7.91/configure.ac 2015-01-09 00:38:17.977190726 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/configure.ac 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -128,6 +128,51 @@
|
|
|
5cd83f |
AC_CHECK_HEADERS(selinux/selinux.h)
|
|
|
5cd83f |
AC_CHECK_LIB(selinux, security_get_boolean_active)
|
|
|
5cd83f |
|
|
|
5cd83f |
+dnl Whether (and which) elfutils libdw.so to use for unwinding.
|
|
|
5cd83f |
+AC_ARG_WITH(elfutils,
|
|
|
5cd83f |
+ AS_HELP_STRING([--with-elfutils], [Use elfutils libdwfl unwinding support]),
|
|
|
5cd83f |
+ [case "${withval}" in
|
|
|
5cd83f |
+ (yes|no) enable_elfutils=$withval;;
|
|
|
5cd83f |
+ (*) enable_elfutils=yes
|
|
|
5cd83f |
+ AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
|
|
|
5cd83f |
+ AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
|
|
|
5cd83f |
+ elfutils_LD_LIBRARY_PATH="${withval}/lib:${withval}/lib/elfutils"
|
|
|
5cd83f |
+ ;;
|
|
|
5cd83f |
+esac],[enable_elfutils=maybe])
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+dnl Check whether we have the elfutils libdwfl.h header installed.
|
|
|
5cd83f |
+saved_CPPFLAGS="${CPPFLAGS}"
|
|
|
5cd83f |
+CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
|
|
|
5cd83f |
+AC_CHECK_HEADERS([elfutils/libdwfl.h],[have_libdwfl_h=yes])
|
|
|
5cd83f |
+CPPFLAGS="${saved_CPPFLAGS}"
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+dnl And whether libdw.so provides the unwinding functions.
|
|
|
5cd83f |
+saved_LDFLAGS="${LDFLAGS}"
|
|
|
5cd83f |
+LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
|
|
|
5cd83f |
+AC_CHECK_LIB([dw], [dwfl_getthread_frames], [have_libdw_dwfl_frames=yes])
|
|
|
5cd83f |
+LDFLAGS="${saved_LDFLAGS}"
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+AC_MSG_CHECKING([whether to use elfutils libdwfl unwinding support])
|
|
|
5cd83f |
+case "${enable_elfutils}" in
|
|
|
5cd83f |
+(yes|maybe)
|
|
|
5cd83f |
+ if test x$have_libdwfl_h = xyes -a x$have_libdw_dwfl_frames = xyes; then
|
|
|
5cd83f |
+ enable_elfutils=yes
|
|
|
5cd83f |
+ elif test $enable_elfutils = maybe; then
|
|
|
5cd83f |
+ enable_elfutils=no
|
|
|
5cd83f |
+ else
|
|
|
5cd83f |
+ AC_MSG_RESULT([$enable_elfutils])
|
|
|
5cd83f |
+ AC_MSG_ERROR([Missing elfutils/libdwfl.h or dwfl_getthread_frames not in libdw.so])
|
|
|
5cd83f |
+ fi
|
|
|
5cd83f |
+ ;;
|
|
|
5cd83f |
+(*) ;;
|
|
|
5cd83f |
+esac
|
|
|
5cd83f |
+AC_MSG_RESULT([$enable_elfutils])
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+if test x"$enable_elfutils" = xyes; then
|
|
|
5cd83f |
+ libdw_LIBS=-ldw
|
|
|
5cd83f |
+ AC_SUBST(libdw_LIBS)
|
|
|
5cd83f |
+ AC_DEFINE([HAVE_LIBDW], [1], [we have elfutils libdw])
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
|
|
|
5cd83f |
# HAVE_LIBUNWIND
|
|
|
5cd83f |
AC_ARG_WITH(libunwind,
|
|
|
5cd83f |
@@ -193,6 +238,13 @@
|
|
|
5cd83f |
LDFLAGS="${saved_LDFLAGS}"
|
|
|
5cd83f |
fi
|
|
|
5cd83f |
|
|
|
5cd83f |
+if test x"$enable_elfutils" = xyes -a x"$enable_libunwind" = xyes; then
|
|
|
5cd83f |
+ AC_MSG_ERROR([Cannot enable both --with-libunwind and --with-elfutils])
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+if test x"$enable_elfutils" = xyes -o x"$enable_libunwind" = xyes; then
|
|
|
5cd83f |
+ AC_DEFINE([HAVE_UNWINDER], [1], [we have an unwinder available])
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
|
|
|
5cd83f |
saved_CPPFLAGS="${CPPFLAGS}"
|
|
|
5cd83f |
saved_LDFLAGS="${LDFLAGS}"
|
|
|
5cd83f |
@@ -340,6 +392,7 @@
|
|
|
5cd83f |
AC_SUBST(AM_CFLAGS)
|
|
|
5cd83f |
AC_SUBST(AM_LDFLAGS)
|
|
|
5cd83f |
AC_SUBST(libelf_LD_LIBRARY_PATH)
|
|
|
5cd83f |
+AC_SUBST(elfutils_LD_LIBRARY_PATH)
|
|
|
5cd83f |
AC_SUBST(libunwind_LD_LIBRARY_PATH)
|
|
|
5cd83f |
|
|
|
5cd83f |
AC_CONFIG_FILES([
|
|
|
5cd83f |
diff -u ltrace-0.7.91/ltrace.1 ltrace-0.7.91-pm/ltrace.1
|
|
|
5cd83f |
--- ltrace-0.7.91/ltrace.1 2015-01-09 00:38:17.975190764 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/ltrace.1 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -196,7 +196,8 @@
|
|
|
5cd83f |
correct execution of setuid and/or setgid binaries.
|
|
|
5cd83f |
.IP "\-w, --where \fInr"
|
|
|
5cd83f |
Show backtrace of \fInr\fR stack frames for each traced function. This
|
|
|
5cd83f |
-option enabled only if libunwind support was enabled at compile time.
|
|
|
5cd83f |
+option enabled only if elfutils or libunwind support was enabled at compile
|
|
|
5cd83f |
+time.
|
|
|
5cd83f |
.IP "\-x \fIfilter"
|
|
|
5cd83f |
A qualifying expression which modifies which symbol table entry points
|
|
|
5cd83f |
to trace. The format of the filter expression is described in the
|
|
|
5cd83f |
diff -u ltrace-0.7.91/Makefile.am ltrace-0.7.91-pm/Makefile.am
|
|
|
5cd83f |
--- ltrace-0.7.91/Makefile.am 2015-01-09 00:38:17.965190955 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/Makefile.am 2015-01-09 00:37:40.260910568 +0100
|
|
|
5cd83f |
@@ -40,6 +40,7 @@
|
|
|
5cd83f |
$(liberty_LIBS) \
|
|
|
5cd83f |
$(libsupcxx_LIBS) \
|
|
|
5cd83f |
$(libstdcxx_LIBS) \
|
|
|
5cd83f |
+ $(libdw_LIBS) \
|
|
|
5cd83f |
$(libunwind_LIBS) \
|
|
|
5cd83f |
sysdeps/libos.la
|
|
|
5cd83f |
|
|
|
5cd83f |
diff -u ltrace-0.7.91/options.c ltrace-0.7.91-pm/options.c
|
|
|
5cd83f |
--- ltrace-0.7.91/options.c 2015-01-09 00:38:17.974190783 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/options.c 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -107,9 +107,9 @@
|
|
|
5cd83f |
" -T show the time spent inside each call.\n"
|
|
|
5cd83f |
" -u USERNAME run command with the userid, groupid of username.\n"
|
|
|
5cd83f |
" -V, --version output version information and exit.\n"
|
|
|
5cd83f |
-#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
+#if defined(HAVE_UNWINDER)
|
|
|
5cd83f |
" -w, --where=NR print backtrace showing NR stack frames at most.\n"
|
|
|
5cd83f |
-#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
+#endif /* defined(HAVE_UNWINDER) */
|
|
|
5cd83f |
" -x FILTER modify which static functions to trace.\n"
|
|
|
5cd83f |
"\nReport bugs to ltrace-devel@lists.alioth.debian.org\n",
|
|
|
5cd83f |
progname);
|
|
|
5cd83f |
@@ -519,9 +519,9 @@
|
|
|
5cd83f |
progname = argv[0];
|
|
|
5cd83f |
options.output = stderr;
|
|
|
5cd83f |
options.no_signals = 0;
|
|
|
5cd83f |
-#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
+#if defined(HAVE_UNWINDER)
|
|
|
5cd83f |
options.bt_depth = -1;
|
|
|
5cd83f |
-#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
+#endif /* defined(HAVE_UNWINDER) */
|
|
|
5cd83f |
|
|
|
5cd83f |
guess_cols();
|
|
|
5cd83f |
|
|
|
5cd83f |
@@ -545,9 +545,9 @@
|
|
|
5cd83f |
{"output", 1, 0, 'o'},
|
|
|
5cd83f |
{"version", 0, 0, 'V'},
|
|
|
5cd83f |
{"no-signals", 0, 0, 'b'},
|
|
|
5cd83f |
-# if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
+# if defined(HAVE_UNWINDER)
|
|
|
5cd83f |
{"where", 1, 0, 'w'},
|
|
|
5cd83f |
-# endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
+# endif /* defined(HAVE_UNWINDER) */
|
|
|
5cd83f |
{0, 0, 0, 0}
|
|
|
5cd83f |
};
|
|
|
5cd83f |
#endif
|
|
|
5cd83f |
@@ -556,7 +556,7 @@
|
|
|
5cd83f |
#ifdef USE_DEMANGLE
|
|
|
5cd83f |
"C"
|
|
|
5cd83f |
#endif
|
|
|
5cd83f |
-#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
+#if defined(HAVE_UNWINDER)
|
|
|
5cd83f |
"w:"
|
|
|
5cd83f |
#endif
|
|
|
5cd83f |
"cfhiLrStTVba:A:D:e:F:l:n:o:p:s:u:x:X:";
|
|
|
5cd83f |
@@ -681,11 +681,11 @@
|
|
|
5cd83f |
"There is NO WARRANTY, to the extent permitted by law.\n");
|
|
|
5cd83f |
exit(0);
|
|
|
5cd83f |
break;
|
|
|
5cd83f |
-#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
+#if defined(HAVE_UNWINDER)
|
|
|
5cd83f |
case 'w':
|
|
|
5cd83f |
options.bt_depth = parse_int(optarg, 'w', 1, 0);
|
|
|
5cd83f |
break;
|
|
|
5cd83f |
-#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
+#endif /* defined(HAVE_UNWINDER) */
|
|
|
5cd83f |
|
|
|
5cd83f |
case 'x':
|
|
|
5cd83f |
parse_filter_chain(optarg, &options.static_filter);
|
|
|
5cd83f |
diff -u ltrace-0.7.91/options.h ltrace-0.7.91-pm/options.h
|
|
|
5cd83f |
--- ltrace-0.7.91/options.h 2015-01-09 00:38:17.966190936 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/options.h 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -44,9 +44,9 @@
|
|
|
5cd83f |
size_t strlen; /* default maximum # of bytes printed in strings */
|
|
|
5cd83f |
int follow; /* trace child processes */
|
|
|
5cd83f |
int no_signals; /* don't print signals */
|
|
|
5cd83f |
-#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
+#if defined(HAVE_UNWINDER)
|
|
|
5cd83f |
int bt_depth; /* how may levels of stack frames to show */
|
|
|
5cd83f |
-#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
+#endif /* defined(HAVE_UNWINDER) */
|
|
|
5cd83f |
struct filter *plt_filter;
|
|
|
5cd83f |
struct filter *static_filter;
|
|
|
5cd83f |
|
|
|
5cd83f |
diff -u ltrace-0.7.91/output.c ltrace-0.7.91-pm/output.c
|
|
|
5cd83f |
--- ltrace-0.7.91/output.c 2015-01-09 00:38:17.966190936 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/output.c 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -33,6 +33,7 @@
|
|
|
5cd83f |
#include <unistd.h>
|
|
|
5cd83f |
#include <errno.h>
|
|
|
5cd83f |
#include <assert.h>
|
|
|
5cd83f |
+#include <inttypes.h>
|
|
|
5cd83f |
|
|
|
5cd83f |
#include "output.h"
|
|
|
5cd83f |
#include "demangle.h"
|
|
|
5cd83f |
@@ -567,6 +568,73 @@
|
|
|
5cd83f |
stel->out.need_delim = need_delim;
|
|
|
5cd83f |
}
|
|
|
5cd83f |
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+/* Prints information about one frame of a thread. Called by
|
|
|
5cd83f |
+ dwfl_getthread_frames in output_right. Returns 1 when done (max
|
|
|
5cd83f |
+ number of frames reached). Returns -1 on error. Returns 0 on
|
|
|
5cd83f |
+ success (if there are more frames in the thread, call us again). */
|
|
|
5cd83f |
+static int
|
|
|
5cd83f |
+frame_callback (Dwfl_Frame *state, void *arg)
|
|
|
5cd83f |
+{
|
|
|
5cd83f |
+ Dwarf_Addr pc;
|
|
|
5cd83f |
+ bool isactivation;
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ int *frames = (int *) arg;
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ if (!dwfl_frame_pc(state, &pc, &isactivation))
|
|
|
5cd83f |
+ return -1;
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ if (!isactivation)
|
|
|
5cd83f |
+ pc--;
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ Dwfl *dwfl = dwfl_thread_dwfl(dwfl_frame_thread(state));
|
|
|
5cd83f |
+ Dwfl_Module *mod = dwfl_addrmodule(dwfl, pc);
|
|
|
5cd83f |
+ const char *modname = NULL;
|
|
|
5cd83f |
+ const char *symname = NULL;
|
|
|
5cd83f |
+ GElf_Off off = 0;
|
|
|
5cd83f |
+ if (mod != NULL) {
|
|
|
5cd83f |
+ GElf_Sym sym;
|
|
|
5cd83f |
+ modname = dwfl_module_info(mod, NULL, NULL, NULL, NULL,
|
|
|
5cd83f |
+ NULL, NULL, NULL);
|
|
|
5cd83f |
+ symname = dwfl_module_addrinfo(mod, pc, &off, &sym,
|
|
|
5cd83f |
+ NULL, NULL, NULL);
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ /* This mimics the output produced by libunwind below. */
|
|
|
5cd83f |
+ fprintf(options.output, " > %s(%s+0x%" PRIx64 ") [%" PRIx64 "]\n",
|
|
|
5cd83f |
+ modname, symname, off, pc);
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ /* See if we can extract the source line too and print it on
|
|
|
5cd83f |
+ the next line if we can find it. */
|
|
|
5cd83f |
+ if (mod != NULL) {
|
|
|
5cd83f |
+ Dwfl_Line *l = dwfl_module_getsrc(mod, pc);
|
|
|
5cd83f |
+ if (l != NULL) {
|
|
|
5cd83f |
+ int line, col;
|
|
|
5cd83f |
+ line = col = -1;
|
|
|
5cd83f |
+ const char *src = dwfl_lineinfo(l, NULL, &line, &col,
|
|
|
5cd83f |
+ NULL, NULL);
|
|
|
5cd83f |
+ if (src != NULL) {
|
|
|
5cd83f |
+ fprintf(options.output, "\t%s", src);
|
|
|
5cd83f |
+ if (line > 0) {
|
|
|
5cd83f |
+ fprintf(options.output, ":%d", line);
|
|
|
5cd83f |
+ if (col > 0)
|
|
|
5cd83f |
+ fprintf(options.output,
|
|
|
5cd83f |
+ ":%d", col);
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+ fprintf(options.output, "\n");
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ /* Max number of frames to print reached? */
|
|
|
5cd83f |
+ if ((*frames)-- == 0)
|
|
|
5cd83f |
+ return 1;
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ return 0;
|
|
|
5cd83f |
+}
|
|
|
5cd83f |
+#endif /* defined(HAVE_LIBDW) */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
void
|
|
|
5cd83f |
output_right(enum tof type, struct process *proc, struct library_symbol *libsym,
|
|
|
5cd83f |
struct timedelta *spent)
|
|
|
5cd83f |
@@ -694,6 +762,24 @@
|
|
|
5cd83f |
}
|
|
|
5cd83f |
#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+ if (options.bt_depth > 0 && proc->leader->dwfl != NULL) {
|
|
|
5cd83f |
+ int frames = options.bt_depth;
|
|
|
5cd83f |
+ if (dwfl_getthread_frames(proc->leader->dwfl, proc->pid,
|
|
|
5cd83f |
+ frame_callback, &frames) < 0) {
|
|
|
5cd83f |
+ // Only print an error if we couldn't show anything.
|
|
|
5cd83f |
+ // Otherwise just show there might be more...
|
|
|
5cd83f |
+ if (frames == options.bt_depth)
|
|
|
5cd83f |
+ fprintf(stderr,
|
|
|
5cd83f |
+ "dwfl_getthread_frames tid %d: %s\n",
|
|
|
5cd83f |
+ proc->pid, dwfl_errmsg(-1));
|
|
|
5cd83f |
+ else
|
|
|
5cd83f |
+ fprintf(options.output, " > [...]\n");
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+ fprintf(options.output, "\n");
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+#endif /* defined(HAVE_LIBDW) */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
current_proc = NULL;
|
|
|
5cd83f |
current_column = 0;
|
|
|
5cd83f |
}
|
|
|
5cd83f |
diff -u ltrace-0.7.91/proc.c ltrace-0.7.91-pm/proc.c
|
|
|
5cd83f |
--- ltrace-0.7.91/proc.c 2015-01-09 00:38:17.981190650 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/proc.c 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -111,6 +111,11 @@
|
|
|
5cd83f |
if (proc->unwind_as != NULL)
|
|
|
5cd83f |
unw_destroy_addr_space(proc->unwind_as);
|
|
|
5cd83f |
#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+ if (proc->dwfl != NULL)
|
|
|
5cd83f |
+ dwfl_end(proc->dwfl);
|
|
|
5cd83f |
+#endif /* defined(HAVE_LIBDW) */
|
|
|
5cd83f |
}
|
|
|
5cd83f |
|
|
|
5cd83f |
static int
|
|
|
5cd83f |
@@ -172,6 +177,10 @@
|
|
|
5cd83f |
}
|
|
|
5cd83f |
#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+ proc->dwfl = NULL; /* Initialize for leader only on first library. */
|
|
|
5cd83f |
+#endif /* defined(HAVE_LIBDW) */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
return 0;
|
|
|
5cd83f |
}
|
|
|
5cd83f |
|
|
|
5cd83f |
@@ -887,6 +896,59 @@
|
|
|
5cd83f |
debug(DEBUG_PROCESS, "added library %s@%p (%s) to %d",
|
|
|
5cd83f |
lib->soname, lib->base, lib->pathname, proc->pid);
|
|
|
5cd83f |
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+ if (options.bt_depth > 0) {
|
|
|
5cd83f |
+ /* Setup module tracking for libdwfl unwinding. */
|
|
|
5cd83f |
+ struct process *leader = proc->leader;
|
|
|
5cd83f |
+ Dwfl *dwfl = leader->dwfl;
|
|
|
5cd83f |
+ if (dwfl == NULL) {
|
|
|
5cd83f |
+ static const Dwfl_Callbacks proc_callbacks = {
|
|
|
5cd83f |
+ .find_elf = dwfl_linux_proc_find_elf,
|
|
|
5cd83f |
+ .find_debuginfo = dwfl_standard_find_debuginfo
|
|
|
5cd83f |
+ };
|
|
|
5cd83f |
+ dwfl = dwfl_begin(&proc_callbacks);
|
|
|
5cd83f |
+ if (dwfl == NULL)
|
|
|
5cd83f |
+ fprintf(stderr,
|
|
|
5cd83f |
+ "Couldn't initialize libdwfl unwinding "
|
|
|
5cd83f |
+ "for process %d: %s\n", leader->pid,
|
|
|
5cd83f |
+ dwfl_errmsg (-1));
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ if (dwfl != NULL) {
|
|
|
5cd83f |
+ dwfl_report_begin_add(dwfl);
|
|
|
5cd83f |
+ if (dwfl_report_elf(dwfl, lib->soname,
|
|
|
5cd83f |
+ lib->pathname, -1,
|
|
|
5cd83f |
+ (GElf_Addr) lib->base,
|
|
|
5cd83f |
+ false) == NULL)
|
|
|
5cd83f |
+ fprintf(stderr,
|
|
|
5cd83f |
+ "dwfl_report_elf %s@%p (%s) %d: %s\n",
|
|
|
5cd83f |
+ lib->soname, lib->base, lib->pathname,
|
|
|
5cd83f |
+ proc->pid, dwfl_errmsg (-1));
|
|
|
5cd83f |
+ dwfl_report_end(dwfl, NULL, NULL);
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+ if (leader->dwfl == NULL) {
|
|
|
5cd83f |
+ int r = dwfl_linux_proc_attach(dwfl,
|
|
|
5cd83f |
+ leader->pid,
|
|
|
5cd83f |
+ true);
|
|
|
5cd83f |
+ if (r == 0)
|
|
|
5cd83f |
+ leader->dwfl = dwfl;
|
|
|
5cd83f |
+ else {
|
|
|
5cd83f |
+ const char *msg;
|
|
|
5cd83f |
+ dwfl_end(dwfl);
|
|
|
5cd83f |
+ if (r < 0)
|
|
|
5cd83f |
+ msg = dwfl_errmsg(-1);
|
|
|
5cd83f |
+ else
|
|
|
5cd83f |
+ msg = strerror(r);
|
|
|
5cd83f |
+ fprintf(stderr, "Couldn't initialize "
|
|
|
5cd83f |
+ "libdwfl unwinding for "
|
|
|
5cd83f |
+ "process %d: %s\n",
|
|
|
5cd83f |
+ leader->pid, msg);
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+ }
|
|
|
5cd83f |
+#endif /* defined(HAVE_LIBDW) */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
/* Insert breakpoints for all active (non-latent) symbols. */
|
|
|
5cd83f |
struct library_symbol *libsym = NULL;
|
|
|
5cd83f |
while ((libsym = library_each_symbol(lib, libsym,
|
|
|
5cd83f |
diff -u ltrace-0.7.91/proc.c.orig ltrace-0.7.91-pm/proc.c.orig
|
|
|
5cd83f |
--- ltrace-0.7.91/proc.h 2015-01-09 00:38:17.966190936 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91-pm/proc.h 2015-01-09 00:37:40.261910548 +0100
|
|
|
5cd83f |
@@ -28,6 +28,10 @@
|
|
|
5cd83f |
#include <sys/time.h>
|
|
|
5cd83f |
#include <stdint.h>
|
|
|
5cd83f |
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+# include <elfutils/libdwfl.h>
|
|
|
5cd83f |
+#endif
|
|
|
5cd83f |
+
|
|
|
5cd83f |
#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
# include <libunwind.h>
|
|
|
5cd83f |
#endif /* defined(HAVE_LIBUNWIND) */
|
|
|
5cd83f |
@@ -113,6 +117,11 @@
|
|
|
5cd83f |
short e_machine;
|
|
|
5cd83f |
char e_class;
|
|
|
5cd83f |
|
|
|
5cd83f |
+#if defined(HAVE_LIBDW)
|
|
|
5cd83f |
+ /* Unwind info for leader, NULL for non-leader procs. */
|
|
|
5cd83f |
+ Dwfl *dwfl;
|
|
|
5cd83f |
+#endif /* defined(HAVE_LIBDW) */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
#if defined(HAVE_LIBUNWIND)
|
|
|
5cd83f |
/* libunwind address space */
|
|
|
5cd83f |
unw_addr_space_t unwind_as;
|
|
|
5cd83f |
diff -up ltrace-0.7.91/proc.c\~ ltrace-0.7.91/proc.c
|
|
|
5cd83f |
--- ltrace-0.7.91/proc.c~ 2015-01-09 01:55:38.289864078 +0100
|
|
|
5cd83f |
+++ ltrace-0.7.91/proc.c 2015-01-09 01:56:29.818881935 +0100
|
|
|
5cd83f |
@@ -918,7 +918,8 @@ proc_add_library(struct process *proc, s
|
|
|
5cd83f |
dwfl_report_begin_add(dwfl);
|
|
|
5cd83f |
if (dwfl_report_elf(dwfl, lib->soname,
|
|
|
5cd83f |
lib->pathname, -1,
|
|
|
5cd83f |
- (GElf_Addr) lib->base,
|
|
|
5cd83f |
+ /* XXX double cast */
|
|
|
5cd83f |
+ (GElf_Addr) (uintptr_t) lib->base,
|
|
|
5cd83f |
false) == NULL)
|
|
|
5cd83f |
fprintf(stderr,
|
|
|
5cd83f |
"dwfl_report_elf %s@%p (%s) %d: %s\n",
|
|
|
5cd83f |
diff -up a/configure b/configure
|
|
|
5cd83f |
--- a/configure 2018-04-06 19:48:06.543593689 -0400
|
|
|
5cd83f |
+++ b/configure 2018-04-06 19:47:52.039859482 -0400
|
|
|
5cd83f |
@@ -637,6 +637,7 @@ am__EXEEXT_TRUE
|
|
|
5cd83f |
LTLIBOBJS
|
|
|
5cd83f |
LIBOBJS
|
|
|
5cd83f |
libunwind_LD_LIBRARY_PATH
|
|
|
5cd83f |
+elfutils_LD_LIBRARY_PATH
|
|
|
5cd83f |
libelf_LD_LIBRARY_PATH
|
|
|
5cd83f |
AM_LDFLAGS
|
|
|
5cd83f |
AM_CFLAGS
|
|
|
5cd83f |
@@ -645,6 +646,7 @@ USE_VALGRIND_FALSE
|
|
|
5cd83f |
USE_VALGRIND_TRUE
|
|
|
5cd83f |
HAVE_VALGRIND
|
|
|
5cd83f |
libunwind_LIBS
|
|
|
5cd83f |
+libdw_LIBS
|
|
|
5cd83f |
libstdcxx_LIBS
|
|
|
5cd83f |
libsupcxx_LIBS
|
|
|
5cd83f |
liberty_LIBS
|
|
|
5cd83f |
@@ -780,6 +782,7 @@ enable_silent_rules
|
|
|
5cd83f |
enable_maintainer_mode
|
|
|
5cd83f |
enable_largefile
|
|
|
5cd83f |
with_libelf
|
|
|
5cd83f |
+with_elfutils
|
|
|
5cd83f |
with_libunwind
|
|
|
5cd83f |
enable_debug
|
|
|
5cd83f |
enable_werror
|
|
|
5cd83f |
@@ -1440,6 +1443,7 @@ Optional Packages:
|
|
|
5cd83f |
--with-sysroot=DIR Search for dependent libraries within DIR
|
|
|
5cd83f |
(or the compiler's sysroot if not specified).
|
|
|
5cd83f |
--with-libelf Prefix of libelf headers/library
|
|
|
5cd83f |
+ --with-elfutils Use elfutils libdwfl unwinding support
|
|
|
5cd83f |
--with-libunwind Use libunwind frame unwinding support
|
|
|
5cd83f |
|
|
|
5cd83f |
Some influential environment variables:
|
|
|
5cd83f |
@@ -12115,6 +12119,108 @@ fi
|
|
|
5cd83f |
|
|
|
5cd83f |
|
|
|
5cd83f |
|
|
|
5cd83f |
+# Check whether --with-elfutils was given.
|
|
|
5cd83f |
+if test "${with_elfutils+set}" = set; then :
|
|
|
5cd83f |
+ withval=$with_elfutils; case "${withval}" in
|
|
|
5cd83f |
+ (yes|no) enable_elfutils=$withval;;
|
|
|
5cd83f |
+ (*) enable_elfutils=yes
|
|
|
5cd83f |
+ AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
|
|
|
5cd83f |
+ AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
|
|
|
5cd83f |
+ elfutils_LD_LIBRARY_PATH="${withval}/lib:${withval}/lib/elfutils"
|
|
|
5cd83f |
+ ;;
|
|
|
5cd83f |
+esac
|
|
|
5cd83f |
+else
|
|
|
5cd83f |
+ enable_elfutils=maybe
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+saved_CPPFLAGS="${CPPFLAGS}"
|
|
|
5cd83f |
+CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
|
|
|
5cd83f |
+for ac_header in elfutils/libdwfl.h
|
|
|
5cd83f |
+do :
|
|
|
5cd83f |
+ ac_fn_c_check_header_mongrel "$LINENO" "elfutils/libdwfl.h" "ac_cv_header_elfutils_libdwfl_h" "$ac_includes_default"
|
|
|
5cd83f |
+if test "x$ac_cv_header_elfutils_libdwfl_h" = xyes; then :
|
|
|
5cd83f |
+ cat >>confdefs.h <<_ACEOF
|
|
|
5cd83f |
+#define HAVE_ELFUTILS_LIBDWFL_H 1
|
|
|
5cd83f |
+_ACEOF
|
|
|
5cd83f |
+ have_libdwfl_h=yes
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+done
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+CPPFLAGS="${saved_CPPFLAGS}"
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+saved_LDFLAGS="${LDFLAGS}"
|
|
|
5cd83f |
+LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
|
|
|
5cd83f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dwfl_getthread_frames in -ldw" >&5
|
|
|
5cd83f |
+$as_echo_n "checking for dwfl_getthread_frames in -ldw... " >&6; }
|
|
|
5cd83f |
+if ${ac_cv_lib_dw_dwfl_getthread_frames+:} false; then :
|
|
|
5cd83f |
+ $as_echo_n "(cached) " >&6
|
|
|
5cd83f |
+else
|
|
|
5cd83f |
+ ac_check_lib_save_LIBS=$LIBS
|
|
|
5cd83f |
+LIBS="-ldw $LIBS"
|
|
|
5cd83f |
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
5cd83f |
+/* end confdefs.h. */
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+/* Override any GCC internal prototype to avoid an error.
|
|
|
5cd83f |
+ Use char because int might match the return type of a GCC
|
|
|
5cd83f |
+ builtin and then its argument prototype would still apply. */
|
|
|
5cd83f |
+#ifdef __cplusplus
|
|
|
5cd83f |
+extern "C"
|
|
|
5cd83f |
+#endif
|
|
|
5cd83f |
+char dwfl_getthread_frames ();
|
|
|
5cd83f |
+int
|
|
|
5cd83f |
+main ()
|
|
|
5cd83f |
+{
|
|
|
5cd83f |
+return dwfl_getthread_frames ();
|
|
|
5cd83f |
+ ;
|
|
|
5cd83f |
+ return 0;
|
|
|
5cd83f |
+}
|
|
|
5cd83f |
+_ACEOF
|
|
|
5cd83f |
+if ac_fn_c_try_link "$LINENO"; then :
|
|
|
5cd83f |
+ ac_cv_lib_dw_dwfl_getthread_frames=yes
|
|
|
5cd83f |
+else
|
|
|
5cd83f |
+ ac_cv_lib_dw_dwfl_getthread_frames=no
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+rm -f core conftest.err conftest.$ac_objext \
|
|
|
5cd83f |
+ conftest$ac_exeext conftest.$ac_ext
|
|
|
5cd83f |
+LIBS=$ac_check_lib_save_LIBS
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dw_dwfl_getthread_frames" >&5
|
|
|
5cd83f |
+$as_echo "$ac_cv_lib_dw_dwfl_getthread_frames" >&6; }
|
|
|
5cd83f |
+if test "x$ac_cv_lib_dw_dwfl_getthread_frames" = xyes; then :
|
|
|
5cd83f |
+ have_libdw_dwfl_frames=yes
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+LDFLAGS="${saved_LDFLAGS}"
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use elfutils libdwfl unwinding support" >&5
|
|
|
5cd83f |
+$as_echo_n "checking whether to use elfutils libdwfl unwinding support... " >&6; }
|
|
|
5cd83f |
+case "${enable_elfutils}" in
|
|
|
5cd83f |
+(yes|maybe)
|
|
|
5cd83f |
+ if test x$have_libdwfl_h = xyes -a x$have_libdw_dwfl_frames = xyes; then
|
|
|
5cd83f |
+ enable_elfutils=yes
|
|
|
5cd83f |
+ elif test $enable_elfutils = maybe; then
|
|
|
5cd83f |
+ enable_elfutils=no
|
|
|
5cd83f |
+ else
|
|
|
5cd83f |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_elfutils" >&5
|
|
|
5cd83f |
+$as_echo "$enable_elfutils" >&6; }
|
|
|
5cd83f |
+ as_fn_error $? "Missing elfutils/libdwfl.h or dwfl_getthread_frames not in libdw.so" "$LINENO" 5
|
|
|
5cd83f |
+ fi
|
|
|
5cd83f |
+ ;;
|
|
|
5cd83f |
+(*) ;;
|
|
|
5cd83f |
+esac
|
|
|
5cd83f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_elfutils" >&5
|
|
|
5cd83f |
+$as_echo "$enable_elfutils" >&6; }
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+if test x"$enable_elfutils" = xyes; then
|
|
|
5cd83f |
+ libdw_LIBS=-ldw
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+$as_echo "#define HAVE_LIBDW 1" >>confdefs.h
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+
|
|
|
5cd83f |
# HAVE_LIBUNWIND
|
|
|
5cd83f |
|
|
|
5cd83f |
# Check whether --with-libunwind was given.
|
|
|
5cd83f |
@@ -12329,6 +12435,15 @@ $as_echo "#define HAVE_LIBUNWIND 1" >>co
|
|
|
5cd83f |
LDFLAGS="${saved_LDFLAGS}"
|
|
|
5cd83f |
fi
|
|
|
5cd83f |
|
|
|
5cd83f |
+if test x"$enable_elfutils" = xyes -a x"$enable_libunwind" = xyes; then
|
|
|
5cd83f |
+ as_fn_error $? "Cannot enable both --with-libunwind and --with-elfutils" "$LINENO" 5
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+if test x"$enable_elfutils" = xyes -o x"$enable_libunwind" = xyes; then
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+$as_echo "#define HAVE_UNWINDER 1" >>confdefs.h
|
|
|
5cd83f |
+
|
|
|
5cd83f |
+fi
|
|
|
5cd83f |
|
|
|
5cd83f |
saved_CPPFLAGS="${CPPFLAGS}"
|
|
|
5cd83f |
saved_LDFLAGS="${LDFLAGS}"
|
|
|
5cd83f |
diff a/config.h.in b/config.h.in
|
|
|
5cd83f |
--- a/config.h.in 2013-03-22 19:12:35.000000000 -0400
|
|
|
5cd83f |
+++ b/config.h.in 2018-04-06 21:49:42.000000000 -0400
|
|
|
5cd83f |
@@ -15,6 +15,9 @@
|
|
|
5cd83f |
/* Define to 1 if you have the <dlfcn.h> header file. */
|
|
|
5cd83f |
#undef HAVE_DLFCN_H
|
|
|
5cd83f |
|
|
|
5cd83f |
+/* Define to 1 if you have the <elfutils/libdwfl.h> header file. */
|
|
|
5cd83f |
+#undef HAVE_ELFUTILS_LIBDWFL_H
|
|
|
5cd83f |
+
|
|
|
5cd83f |
/* we have read mmap support */
|
|
|
5cd83f |
#undef HAVE_ELF_C_READ_MMAP
|
|
|
5cd83f |
|
|
|
5cd83f |
@@ -39,6 +42,9 @@
|
|
|
5cd83f |
/* Define to 1 if you have the <inttypes.h> header file. */
|
|
|
5cd83f |
#undef HAVE_INTTYPES_H
|
|
|
5cd83f |
|
|
|
5cd83f |
+/* we have elfutils libdw */
|
|
|
5cd83f |
+#undef HAVE_LIBDW
|
|
|
5cd83f |
+
|
|
|
5cd83f |
/* Define to 1 if you have the `elf' library (-lelf). */
|
|
|
5cd83f |
#undef HAVE_LIBELF
|
|
|
5cd83f |
|
|
|
5cd83f |
@@ -129,6 +135,9 @@
|
|
|
5cd83f |
/* Define to 1 if you have the <unistd.h> header file. */
|
|
|
5cd83f |
#undef HAVE_UNISTD_H
|
|
|
5cd83f |
|
|
|
5cd83f |
+/* we have an unwinder available */
|
|
|
5cd83f |
+#undef HAVE_UNWINDER
|
|
|
5cd83f |
+
|
|
|
5cd83f |
/* Define to 1 if you have the `vfork' function. */
|
|
|
5cd83f |
#undef HAVE_VFORK
|
|
|
5cd83f |
|
|
|
5cd83f |
@@ -175,6 +184,11 @@
|
|
|
5cd83f |
/* Version number of package */
|
|
|
5cd83f |
#undef VERSION
|
|
|
5cd83f |
|
|
|
5cd83f |
+/* Enable large inode numbers on Mac OS X 10.5. */
|
|
|
5cd83f |
+#ifndef _DARWIN_USE_64_BIT_INODE
|
|
|
5cd83f |
+# define _DARWIN_USE_64_BIT_INODE 1
|
|
|
5cd83f |
+#endif
|
|
|
5cd83f |
+
|
|
|
5cd83f |
/* Number of bits in a file offset, on hosts where this is settable. */
|
|
|
5cd83f |
#undef _FILE_OFFSET_BITS
|
|
|
5cd83f |
|
|
|
5cd83f |
diff a/Makefile.in b/Makefile.in
|
|
|
5cd83f |
--- a/Makefile.in 2013-11-04 20:22:47.000000000 -0500
|
|
|
5cd83f |
+++ b/Makefile.in 2018-04-06 23:29:16.919673155 -0400
|
|
|
5cd83f |
@@ -297,6 +297,7 @@ includedir = @includedir@
|
|
|
5cd83f |
infodir = @infodir@
|
|
|
5cd83f |
install_sh = @install_sh@
|
|
|
5cd83f |
libdir = @libdir@
|
|
|
5cd83f |
+libdw_LIBS = @libdw_LIBS@
|
|
|
5cd83f |
libelf_LD_LIBRARY_PATH = @libelf_LD_LIBRARY_PATH@
|
|
|
5cd83f |
liberty_LIBS = @liberty_LIBS@
|
|
|
5cd83f |
libexecdir = @libexecdir@
|
|
|
5cd83f |
@@ -342,6 +343,7 @@ libltrace_la_LIBADD = \
|
|
|
5cd83f |
$(liberty_LIBS) \
|
|
|
5cd83f |
$(libsupcxx_LIBS) \
|
|
|
5cd83f |
$(libstdcxx_LIBS) \
|
|
|
5cd83f |
+ $(libdw_LIBS) \
|
|
|
5cd83f |
$(libunwind_LIBS) \
|
|
|
5cd83f |
sysdeps/libos.la
|
|
|
5cd83f |
|