Index: src/base/logging.cc |
diff --git a/src/base/logging.cc b/src/base/logging.cc |
index 25d77bb1ec1dc9b9e9e84e3ac2460eb689ac088f..a2688c9c9aefb1f566f048e79c7f6ec4c0f9db16 100644 |
--- a/src/base/logging.cc |
+++ b/src/base/logging.cc |
@@ -5,10 +5,11 @@ |
#include "src/base/logging.h" |
#if V8_LIBC_GLIBC || V8_OS_BSD |
-# include <cxxabi.h> |
-# include <execinfo.h> |
+#include <cxxabi.h> |
+#include <dlfcn.h> |
+#include <execinfo.h> |
#elif V8_OS_QNX |
-# include <backtrace.h> |
+#include <backtrace.h> |
#endif // V8_LIBC_GLIBC || V8_OS_BSD |
#include <cstdio> |
@@ -54,28 +55,24 @@ void DumpBacktrace() { |
#if V8_LIBC_GLIBC || V8_OS_BSD |
void* trace[100]; |
int size = backtrace(trace, arraysize(trace)); |
- char** symbols = backtrace_symbols(trace, size); |
OS::PrintError("\n==== C stack trace ===============================\n\n"); |
if (size == 0) { |
OS::PrintError("(empty)\n"); |
- } else if (symbols == NULL) { |
- OS::PrintError("(no symbols)\n"); |
} else { |
for (int i = 1; i < size; ++i) { |
OS::PrintError("%2d: ", i); |
- char mangled[201]; |
- if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT |
- int status; |
- size_t length; |
- char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); |
- OS::PrintError("%s\n", demangled != NULL ? demangled : mangled); |
+ Dl_info info; |
+ char* demangled = NULL; |
+ if (!dladdr(trace[i], &info) || !info.dli_sname) { |
+ OS::PrintError("%p\n", trace[i]); |
+ } else if ((demangled = abi::__cxa_demangle(info.dli_sname, 0, 0, 0))) { |
+ OS::PrintError("%s\n", demangled); |
free(demangled); |
} else { |
- OS::PrintError("??\n"); |
+ OS::PrintError("%s\n", info.dli_sname); |
} |
} |
} |
- free(symbols); |
#elif V8_OS_QNX |
char out[1024]; |
bt_accessor_t acc; |