Commit 36e58db6 authored by ofrobots's avatar ofrobots Committed by Commit bot

Fix backtrace for solaris and musl C based linux environments as well

R=rmcilroy@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2333023002
Cr-Commit-Position: refs/heads/master@{#39392}
parent c8e93b06
......@@ -25,7 +25,11 @@
#include <string>
#include <vector>
#if V8_LIBC_GLIBC || V8_OS_BSD || V8_LIBC_UCLIBC
#if V8_LIBC_GLIBC || V8_LIBC_BSD || V8_LIBC_UCLIBC || V8_OS_SOLARIS
#define HAVE_EXECINFO_H 1
#endif
#if HAVE_EXECINFO_H
#include <cxxabi.h>
#include <execinfo.h>
#endif
......@@ -77,7 +81,7 @@ void DemangleSymbols(std::string* text) {
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
#if V8_LIBC_GLIBC || V8_OS_BSD || V8_LIBC_UCLIBC
#if HAVE_EXECINFO_H
std::string::size_type search_from = 0;
while (search_from < text->size()) {
......@@ -114,7 +118,7 @@ void DemangleSymbols(std::string* text) {
}
}
#endif // V8_LIBC_GLIBC || V8_OS_BSD || V8_LIBC_UCLIBC
#endif // HAVE_EXECINFO_H
}
class BacktraceOutputHandler {
......@@ -135,7 +139,7 @@ void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
handler->HandleOutput(buf);
}
#if !V8_OS_AIX
#if HAVE_EXECINFO_H
void ProcessBacktrace(void* const* trace, size_t size,
BacktraceOutputHandler* handler) {
// NOTE: This code MUST be async-signal safe (it's used by in-process
......@@ -172,7 +176,7 @@ void ProcessBacktrace(void* const* trace, size_t size,
}
}
}
#endif // !V8_OS_AIX
#endif // HAVE_EXECINFO_H
void PrintToStderr(const char* output) {
// NOTE: This code MUST be async-signal safe (it's used by in-process
......@@ -361,7 +365,7 @@ StackTrace::StackTrace() {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
#if !V8_OS_AIX
#if HAVE_EXECINFO_H
// Though the backtrace API man page does not list any possible negative
// return values, we take no chance.
count_ = static_cast<size_t>(backtrace(trace_, arraysize(trace_)));
......@@ -374,18 +378,18 @@ void StackTrace::Print() const {
// NOTE: This code MUST be async-signal safe (it's used by in-process
// stack dumping signal handler). NO malloc or stdio is allowed here.
#if !V8_OS_AIX
#if HAVE_EXECINFO_H
PrintBacktraceOutputHandler handler;
ProcessBacktrace(trace_, count_, &handler);
#endif
}
#if !V8_OS_AIX
void StackTrace::OutputToStream(std::ostream* os) const {
#if HAVE_EXECINFO_H
StreamBacktraceOutputHandler handler(os);
ProcessBacktrace(trace_, count_, &handler);
}
#endif
}
namespace internal {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment