Reviewers: Sven Panne,
Description:
Use libdl to get symbols for backtraces
With this patch, it'll look like this:
$ out/x64.optdebug/d8 --expose-trigger-failure test/mjsunit/mjsunit.js
test/mjsunit/verify-assert-false.js
==== C stack trace ===============================
1: V8_Fatal
2: v8::internal::FunctionCallbackArguments::Call(void
(*)(v8::FunctionCallbackInfo<v8::Value> const&))
3: 0x727ced
4: 0x72b6ba
5: 0x188c7f607f9b
BUG=none
[email protected]
LOG=y
Please review this at https://codereview.chromium.org/1018313003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+13, -15 lines):
M BUILD.gn
M src/base/logging.cc
M tools/gyp/v8.gyp
Index: BUILD.gn
diff --git a/BUILD.gn b/BUILD.gn
index
e141f48a82bfab73faf2f9cbd860d7a52e6ee9a9..1ded5f7915b9fa81f11052c5b44126e9d93df4fe
100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1392,7 +1392,7 @@ source_set("v8_libbase") {
if (is_linux) {
sources += [ "src/base/platform/platform-linux.cc" ]
- libs = [ "rt" ]
+ libs = [ "dl", "rt" ]
} else if (is_android) {
defines += [ "CAN_USE_VFP_INSTRUCTIONS" ]
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;
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index
a6ee03a5565367e7b516ba700dcabb9724def8bd..1c8fd635a54f50ffd6e999519abc24d4a9ca7ea3
100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -1370,6 +1370,7 @@
['nacl_target_arch=="none"', {
'link_settings': {
'libraries': [
+ '-ldl',
'-lrt'
],
},
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.