[PATCH 3/5] Revert "os: use libunwind to generate backtraces"

Peter Hutterer peter.hutterer at who-t.net
Wed Oct 30 00:25:10 CET 2013


our backtraces are local only, so libunwind is not needed. We can use elfutils
for that instead.

This reverts commit e21e183059df5975e7086850d1931edb2c1bbd06.
---
 configure.ac            |  9 +-----
 include/dix-config.h.in |  3 --
 os/Makefile.am          |  5 ----
 os/backtrace.c          | 75 -------------------------------------------------
 4 files changed, 1 insertion(+), 91 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5cd8b25..d36aefc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,13 +308,6 @@ AC_CHECK_HEADER([execinfo.h],[
     ])]
 )
 
-PKG_CHECK_MODULES(LIBUNWIND, libunwind, [HAVE_LIBUNWIND=yes], [HAVE_LIBUNWIND=no])
-if test "x$HAVE_LIBUNWIND" = xyes; then
-	AC_DEFINE(HAVE_LIBUNWIND, 1, [Have libunwind support])
-fi
-AM_CONDITIONAL(HAVE_LIBUNWIND, [test "x$HAVE_LIBUNWIND" = xyes])
-
-
 dnl ---------------------------------------------------------------------------
 dnl Bus options and CPU capabilities.  Replaces logic in
 dnl hw/xfree86/os-support/bus/Makefile.am, among others.
@@ -1346,7 +1339,7 @@ AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
 
 if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
   DIX_LIB='$(top_builddir)/dix/dix.O'
-  OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS) $(LIBUNWIND_LIBS)'
+  OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS)'
 else
   DIX_LIB='$(top_builddir)/dix/libdix.la'
   OS_LIB='$(top_builddir)/os/libos.la'
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index a643dfc..e1cb9eb 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -60,9 +60,6 @@
 /* Has backtrace support */
 #undef HAVE_BACKTRACE
 
-/* Has libunwind support */
-#undef HAVE_LIBUNWIND
-
 /* Define to 1 if you have the <byteswap.h> header file. */
 #undef HAVE_BYTESWAP_H
 
diff --git a/os/Makefile.am b/os/Makefile.am
index 364b6da..8891485 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -34,11 +34,6 @@ if XDMCP
 libos_la_SOURCES += $(XDMCP_SRCS)
 endif
 
-if HAVE_LIBUNWIND
-AM_CFLAGS += $(LIBUNWIND_CFLAGS)
-libos_la_LIBADD += $(LIBUNWIND_LIBS)
-endif
-
 EXTRA_DIST = $(SECURERPC_SRCS) $(XDMCP_SRCS)
 
 if SPECIAL_DTRACE_OBJECTS
diff --git a/os/backtrace.c b/os/backtrace.c
index 3d1195b..c807bd2 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -30,80 +30,6 @@
 #include <errno.h>
 #include <string.h>
 
-#ifdef HAVE_LIBUNWIND
-
-#define UNW_LOCAL_ONLY
-#include <libunwind.h>
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-#include <dlfcn.h>
-
-void
-xorg_backtrace(void)
-{
-    unw_cursor_t cursor;
-    unw_context_t context;
-    unw_word_t off;
-    unw_proc_info_t pip;
-    int ret, i = 0;
-    char procname[256];
-    const char *filename;
-    Dl_info dlinfo;
-
-    pip.unwind_info = NULL;
-    ret = unw_getcontext(&context);
-    if (ret) {
-        ErrorFSigSafe("unw_getcontext failed: %s [%d]\n", unw_strerror(ret),
-                ret);
-        return;
-    }
-
-    ret = unw_init_local(&cursor, &context);
-    if (ret) {
-        ErrorFSigSafe("unw_init_local failed: %s [%d]\n", unw_strerror(ret),
-                ret);
-        return;
-    }
-
-    ErrorFSigSafe("\n");
-    ErrorFSigSafe("Backtrace:\n");
-    ret = unw_step(&cursor);
-    while (ret > 0) {
-        ret = unw_get_proc_info(&cursor, &pip);
-        if (ret) {
-            ErrorFSigSafe("unw_get_proc_info failed: %s [%d]\n",
-                    unw_strerror(ret), ret);
-            break;
-        }
-
-        ret = unw_get_proc_name(&cursor, procname, 256, &off);
-        if (ret && ret != -UNW_ENOMEM) {
-            if (ret != -UNW_EUNSPEC)
-                ErrorFSigSafe("unw_get_proc_name failed: %s [%d]\n",
-                        unw_strerror(ret), ret);
-            procname[0] = '?';
-            procname[1] = 0;
-        }
-
-        if (dladdr((void *)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname &&
-                *dlinfo.dli_fname)
-            filename = dlinfo.dli_fname;
-        else
-            filename = "?";
-
-        ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname,
-            ret == -UNW_ENOMEM ? "..." : "", (int)off,
-            (void *)(pip.start_ip + off));
-
-        ret = unw_step(&cursor);
-        if (ret < 0)
-            ErrorFSigSafe("unw_step failed: %s [%d]\n", unw_strerror(ret), ret);
-    }
-    ErrorFSigSafe("\n");
-}
-#else /* HAVE_LIBUNWIND */
 #ifdef HAVE_BACKTRACE
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
@@ -321,4 +247,3 @@ xorg_backtrace(void)
 
 #endif
 #endif
-#endif
-- 
1.8.3.1



More information about the xorg-devel mailing list