Blob Blame Raw
From edf055d2733a0e012dfd97daf1906c407c47ff88 Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Thu, 23 Jul 2009 14:43:30 -0400
Subject: [PATCH] dix: Print load map on backtrace

---
 os/backtrace.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/os/backtrace.c b/os/backtrace.c
index 3cfae3e..af67301 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -30,18 +30,34 @@
 
 #ifdef HAVE_BACKTRACE
 #include <execinfo.h>
+#include <dlfcn.h>
+#include <link.h>
 
 void xorg_backtrace(void)
 {
     void *array[32]; /* deeper nesting than this means something's wrong */
     int size, i;
     char **strings;
+    struct link_map *lm;
+    void *self;
+
     ErrorF("\nBacktrace:\n");
     size = backtrace(array, 32);
     strings = backtrace_symbols(array, size);
     for (i = 0; i < size; i++)
         ErrorF("%d: %s\n", i, strings[i]);
     free(strings);
+
+    self = dlopen(NULL, RTLD_LAZY);
+    dlinfo(self, RTLD_DI_LINKMAP, &lm);
+
+    ErrorF("\nLink map:\n");
+    while (lm) {
+        if (lm->l_addr)
+            ErrorF("%p: %s\n", (void *)lm->l_addr,
+                   lm->l_name[0] ? lm->l_name : "(vdso)");
+        lm = lm->l_next;
+    }
 }
 
 #else /* not glibc or glibc < 2.1 */
-- 
1.6.3.3