summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-08-18 00:39:49 +0200
committerLuca Barbieri <[email protected]>2010-08-20 18:18:28 +0200
commitb3e57fc8685af44dcf35a7f429b7410e63a9a571 (patch)
treed36931f6db4abb69e363598adabe4711a910dd11 /src/gallium/auxiliary
parent64c4f9c56645768aa3cc4a9a60b266a20acca0c2 (diff)
u_debug_symbol: add support for getting symbol names from glibc
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_debug_symbol.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c
index 7147bbc32b8..ebea517f90e 100644
--- a/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -143,6 +143,23 @@ debug_symbol_name_imagehlp(const void *addr, char* buf, unsigned size)
}
#endif
+#ifdef __GLIBC__
+#include <execinfo.h>
+
+/* This can only provide dynamic symbols, or binary offsets into a file.
+ *
+ * To fix this, post-process the output with tools/addr2line.sh
+ */
+static INLINE void
+debug_symbol_name_glibc(const void *addr, char* buf, unsigned size)
+{
+ char** syms = backtrace_symbols((void**)&addr, 1);
+ strncpy(buf, syms[0], size);
+ buf[size - 1] = 0;
+ free(syms);
+}
+#endif
+
void
debug_symbol_name(const void *addr, char* buf, unsigned size)
{
@@ -152,6 +169,12 @@ debug_symbol_name(const void *addr, char* buf, unsigned size)
return;
#endif
+#ifdef __GLIBC__
+ debug_symbol_name_glibc(addr, buf, size);
+ if(buf[0])
+ return;
+#endif
+
util_snprintf(buf, size, "%p", addr);
buf[size - 1] = 0;
}