08ecc6
From edf055d2733a0e012dfd97daf1906c407c47ff88 Mon Sep 17 00:00:00 2001
08ecc6
From: Adam Jackson <ajax@redhat.com>
08ecc6
Date: Thu, 23 Jul 2009 14:43:30 -0400
08ecc6
Subject: [PATCH] dix: Print load map on backtrace
08ecc6
08ecc6
---
08ecc6
 os/backtrace.c |   16 ++++++++++++++++
08ecc6
 1 files changed, 16 insertions(+), 0 deletions(-)
08ecc6
08ecc6
diff --git a/os/backtrace.c b/os/backtrace.c
08ecc6
index 3cfae3e..af67301 100644
08ecc6
--- a/os/backtrace.c
08ecc6
+++ b/os/backtrace.c
08ecc6
@@ -30,18 +30,34 @@
08ecc6
 
08ecc6
 #ifdef HAVE_BACKTRACE
08ecc6
 #include <execinfo.h>
08ecc6
+#include <dlfcn.h>
08ecc6
+#include <link.h>
08ecc6
 
08ecc6
 void xorg_backtrace(void)
08ecc6
 {
08ecc6
     void *array[32]; /* deeper nesting than this means something's wrong */
08ecc6
     int size, i;
08ecc6
     char **strings;
08ecc6
+    struct link_map *lm;
08ecc6
+    void *self;
08ecc6
+
08ecc6
     ErrorF("\nBacktrace:\n");
08ecc6
     size = backtrace(array, 32);
08ecc6
     strings = backtrace_symbols(array, size);
08ecc6
     for (i = 0; i < size; i++)
08ecc6
         ErrorF("%d: %s\n", i, strings[i]);
08ecc6
     free(strings);
08ecc6
+
08ecc6
+    self = dlopen(NULL, RTLD_LAZY);
08ecc6
+    dlinfo(self, RTLD_DI_LINKMAP, &lm);
08ecc6
+
08ecc6
+    ErrorF("\nLink map:\n");
08ecc6
+    while (lm) {
08ecc6
+        if (lm->l_addr)
08ecc6
+            ErrorF("%p: %s\n", (void *)lm->l_addr,
08ecc6
+                   lm->l_name[0] ? lm->l_name : "(vdso)");
08ecc6
+        lm = lm->l_next;
08ecc6
+    }
08ecc6
 }
08ecc6
 
08ecc6
 #else /* not glibc or glibc < 2.1 */
08ecc6
-- 
08ecc6
1.6.3.3
08ecc6