Commit 49c14f63 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

Replace DumpBacktrace with Chromium's StackTrace implementation.

Adds support for dumping the stack on Windows. Also enables in-process
stack dumping in d8 to dump the stack on exceptions and signals.

This CL changes the format of stack dumps from:
 1: V8_Fatal
 2: 0x1ac6ba5
 3: v8::internal::interpreter::BytecodeGenerator::Visit(v8::internal::AstNode*)
 4: v8::internal::interpreter::BytecodeGenerator::VisitForAccumulatorValue(v8::internal::Expression*)
 ...

To:
  ./out/x64.debug/d8(v8::base::debug::StackTrace::StackTrace()+0x1e) [0x1c6ee5e]
  ./out/x64.debug/d8() [0x1c6ede5]
  /lib/x86_64-linux-gnu/libpthread.so.0(+0x10330) [0x7fa01193e330]
  ./out/x64.debug/d8(v8::base::OS::Abort()+0x12) [0x1c6cea2]
  ./out/x64.debug/d8() [0x1c67538]
  ./out/x64.debug/d8() [0x1ac80b5]
  ./out/x64.debug/d8(v8::internal::interpreter::BytecodeGenerator
::Visit(v8::internal::AstNode*)+0x3cb) [0x1ac323b]
  ./out/x64.debug/d8(v8::internal::interpreter::BytecodeGenerator
::VisitForAccumulatorValue(v8::internal::Expression*)+0x40) [0x1ac2570]

Review-Url: https://codereview.chromium.org/2248393002
Cr-Commit-Position: refs/heads/master@{#38717}
parent 1c2c2f43
...@@ -2036,12 +2036,15 @@ v8_source_set("v8_libbase") { ...@@ -2036,12 +2036,15 @@ v8_source_set("v8_libbase") {
"src/base/build_config.h", "src/base/build_config.h",
"src/base/cpu.cc", "src/base/cpu.cc",
"src/base/cpu.h", "src/base/cpu.h",
"src/base/debug/stack_trace.cc",
"src/base/debug/stack_trace.h",
"src/base/division-by-constant.cc", "src/base/division-by-constant.cc",
"src/base/division-by-constant.h", "src/base/division-by-constant.h",
"src/base/file-utils.cc", "src/base/file-utils.cc",
"src/base/file-utils.h", "src/base/file-utils.h",
"src/base/flags.h", "src/base/flags.h",
"src/base/format-macros.h", "src/base/format-macros.h",
"src/base/free_deleter.h",
"src/base/functional.cc", "src/base/functional.cc",
"src/base/functional.h", "src/base/functional.h",
"src/base/hashmap.h", "src/base/hashmap.h",
...@@ -2079,11 +2082,16 @@ v8_source_set("v8_libbase") { ...@@ -2079,11 +2082,16 @@ v8_source_set("v8_libbase") {
defines = [] defines = []
if (is_posix) { if (is_posix) {
sources += [ "src/base/platform/platform-posix.cc" ] sources += [
"src/base/platform/platform-posix.cc",
]
} }
if (is_linux) { if (is_linux) {
sources += [ "src/base/platform/platform-linux.cc" ] sources += [
"src/base/debug/stack_trace_posix.cc",
"src/base/platform/platform-linux.cc",
]
libs = [ libs = [
"dl", "dl",
...@@ -2096,18 +2104,31 @@ v8_source_set("v8_libbase") { ...@@ -2096,18 +2104,31 @@ v8_source_set("v8_libbase") {
"rt", "rt",
] ]
if (host_os == "mac") { if (host_os == "mac") {
sources += [ "src/base/platform/platform-macos.cc" ] sources += [
"src/base/debug/stack_trace_posix.cc",
"src/base/platform/platform-macos.cc",
]
} else { } else {
sources += [ "src/base/platform/platform-linux.cc" ] sources += [
"src/base/debug/stack_trace_posix.cc",
"src/base/platform/platform-linux.cc",
]
} }
} else { } else {
sources += [ "src/base/platform/platform-linux.cc" ] sources += [
"src/base/debug/stack_trace_android.cc",
"src/base/platform/platform-linux.cc",
]
} }
} else if (is_mac) { } else if (is_mac) {
sources += [ "src/base/platform/platform-macos.cc" ] sources += [
"src/base/debug/stack_trace_posix.cc",
"src/base/platform/platform-macos.cc",
]
} else if (is_win) { } else if (is_win) {
# TODO(jochen): Add support for cygwin. # TODO(jochen): Add support for cygwin.
sources += [ sources += [
"src/base/debug/stack_trace_win.cc",
"src/base/platform/platform-win32.cc", "src/base/platform/platform-win32.cc",
"src/base/win32-headers.h", "src/base/win32-headers.h",
] ]
...@@ -2115,6 +2136,8 @@ v8_source_set("v8_libbase") { ...@@ -2115,6 +2136,8 @@ v8_source_set("v8_libbase") {
defines += [ "_CRT_RAND_S" ] # for rand_s() defines += [ "_CRT_RAND_S" ] # for rand_s()
libs = [ libs = [
"dbghelp.lib",
"shlwapi.lib",
"winmm.lib", "winmm.lib",
"ws2_32.lib", "ws2_32.lib",
] ]
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/base/debug/stack_trace.h"
#include <string.h>
#include <algorithm>
#include <sstream>
#include "src/base/macros.h"
namespace v8 {
namespace base {
namespace debug {
StackTrace::StackTrace(const void* const* trace, size_t count) {
count = std::min(count, arraysize(trace_));
if (count) memcpy(trace_, trace, count * sizeof(trace_[0]));
count_ = count;
}
StackTrace::~StackTrace() {}
const void* const* StackTrace::Addresses(size_t* count) const {
*count = count_;
if (count_) return trace_;
return NULL;
}
std::string StackTrace::ToString() const {
std::stringstream stream;
OutputToStream(&stream);
return stream.str();
}
} // namespace debug
} // namespace base
} // namespace v8
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Slightly adapted for inclusion in V8.
// Copyright 2016 the V8 project authors. All rights reserved.
#ifndef V8_BASE_DEBUG_STACK_TRACE_H_
#define V8_BASE_DEBUG_STACK_TRACE_H_
#include <stddef.h>
#include <iosfwd>
#include <string>
#include "src/base/build_config.h"
#if V8_OS_POSIX
#include <unistd.h>
#endif
#if V8_OS_WIN
struct _EXCEPTION_POINTERS;
struct _CONTEXT;
#endif
namespace v8 {
namespace base {
namespace debug {
// Enables stack dump to console output on exception and signals.
// When enabled, the process will quit immediately. This is meant to be used in
// tests only!
bool EnableInProcessStackDumping();
void DisableSignalStackDump();
// A stacktrace can be helpful in debugging. For example, you can include a
// stacktrace member in a object (probably around #ifndef NDEBUG) so that you
// can later see where the given object was created from.
class StackTrace {
public:
// Creates a stacktrace from the current location.
StackTrace();
// Creates a stacktrace from an existing array of instruction
// pointers (such as returned by Addresses()). |count| will be
// trimmed to |kMaxTraces|.
StackTrace(const void* const* trace, size_t count);
#if V8_OS_WIN
// Creates a stacktrace for an exception.
// Note: this function will throw an import not found (StackWalk64) exception
// on system without dbghelp 5.1.
explicit StackTrace(_EXCEPTION_POINTERS* exception_pointers);
explicit StackTrace(const _CONTEXT* context);
#endif
// Copying and assignment are allowed with the default functions.
~StackTrace();
// Gets an array of instruction pointer values. |*count| will be set to the
// number of elements in the returned array.
const void* const* Addresses(size_t* count) const;
// Prints the stack trace to stderr.
void Print() const;
// Resolves backtrace to symbols and write to stream.
void OutputToStream(std::ostream* os) const;
// Resolves backtrace to symbols and returns as string.
std::string ToString() const;
private:
#if V8_OS_WIN
void InitTrace(const _CONTEXT* context_record);
#endif
// From http://msdn.microsoft.com/en-us/library/bb204633.aspx,
// the sum of FramesToSkip and FramesToCapture must be less than 63,
// so set it to 62. Even if on POSIX it could be a larger value, it usually
// doesn't give much more information.
static const int kMaxTraces = 62;
void* trace_[kMaxTraces];
// The number of valid frames in |trace_|.
size_t count_;
};
} // namespace debug
} // namespace base
} // namespace v8
#endif // V8_BASE_DEBUG_STACK_TRACE_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Slightly adapted for inclusion in V8.
// Copyright 2016 the V8 project authors. All rights reserved.
#include "src/base/debug/stack_trace.h"
#include <signal.h>
#include <stddef.h>
#include <string.h>
#include <unwind.h>
#include <src/base/platform/platform.h>
#include <iomanip>
#include <ostream>
namespace {
struct StackCrawlState {
StackCrawlState(uintptr_t* frames, size_t max_depth)
: frames(frames),
frame_count(0),
max_depth(max_depth),
have_skipped_self(false) {}
uintptr_t* frames;
size_t frame_count;
size_t max_depth;
bool have_skipped_self;
};
_Unwind_Reason_Code TraceStackFrame(_Unwind_Context* context, void* arg) {
StackCrawlState* state = static_cast<StackCrawlState*>(arg);
uintptr_t ip = _Unwind_GetIP(context);
// The first stack frame is this function itself. Skip it.
if (ip != 0 && !state->have_skipped_self) {
state->have_skipped_self = true;
return _URC_NO_REASON;
}
state->frames[state->frame_count++] = ip;
if (state->frame_count >= state->max_depth)
return _URC_END_OF_STACK;
return _URC_NO_REASON;
}
} // namespace
namespace v8 {
namespace base {
namespace debug {
bool EnableInProcessStackDumping() {
// When running in an application, our code typically expects SIGPIPE
// to be ignored. Therefore, when testing that same code, it should run
// with SIGPIPE ignored as well.
// TODO(phajdan.jr): De-duplicate this SIGPIPE code.
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_IGN;
sigemptyset(&action.sa_mask);
return (sigaction(SIGPIPE, &action, NULL) == 0);
}
void DisableSignalStackDump() {
}
StackTrace::StackTrace() {
StackCrawlState state(reinterpret_cast<uintptr_t*>(trace_), kMaxTraces);
_Unwind_Backtrace(&TraceStackFrame, &state);
count_ = state.frame_count;
}
void StackTrace::Print() const {
std::string backtrace = ToString();
OS::Print("%s\n", backtrace.c_str());
}
void StackTrace::OutputToStream(std::ostream* os) const {
for (size_t i = 0; i < count_; ++i) {
*os << "#" << std::setw(2) << i << trace_[i] << "\n";
}
}
} // namespace debug
} // namespace base
} // namespace v8
This diff is collapsed.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Slightly adapted for inclusion in V8.
// Copyright 2016 the V8 project authors. All rights reserved.
#include "src/base/debug/stack_trace.h"
#include <windows.h>
#include <dbghelp.h>
#include <Shlwapi.h>
#include <stddef.h>
#include <iostream>
#include <memory>
#include "src/base/logging.h"
#include "src/base/macros.h"
namespace v8 {
namespace base {
namespace debug {
namespace {
// Previous unhandled filter. Will be called if not NULL when we intercept an
// exception. Only used in unit tests.
LPTOP_LEVEL_EXCEPTION_FILTER g_previous_filter = NULL;
bool g_dump_stack_in_signal_handler = true;
bool g_initialized_symbols = false;
DWORD g_init_error = ERROR_SUCCESS;
// Prints the exception call stack.
// This is the unit tests exception filter.
long WINAPI StackDumpExceptionFilter(EXCEPTION_POINTERS* info) { // NOLINT
if (g_dump_stack_in_signal_handler) {
debug::StackTrace(info).Print();
}
if (g_previous_filter) return g_previous_filter(info);
return EXCEPTION_CONTINUE_SEARCH;
}
void GetExePath(wchar_t* path_out) {
GetModuleFileName(NULL, path_out, MAX_PATH);
path_out[MAX_PATH - 1] = L'\0';
PathRemoveFileSpec(path_out);
}
bool InitializeSymbols() {
if (g_initialized_symbols) return g_init_error == ERROR_SUCCESS;
g_initialized_symbols = true;
// Defer symbol load until they're needed, use undecorated names, and get line
// numbers.
SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES);
if (!SymInitialize(GetCurrentProcess(), NULL, TRUE)) {
g_init_error = GetLastError();
// TODO(awong): Handle error: SymInitialize can fail with
// ERROR_INVALID_PARAMETER.
// When it fails, we should not call debugbreak since it kills the current
// process (prevents future tests from running or kills the browser
// process).
return false;
}
// When transferring the binaries e.g. between bots, path put
// into the executable will get off. To still retrieve symbols correctly,
// add the directory of the executable to symbol search path.
// All following errors are non-fatal.
const size_t kSymbolsArraySize = 1024;
std::unique_ptr<wchar_t[]> symbols_path(new wchar_t[kSymbolsArraySize]);
// Note: The below function takes buffer size as number of characters,
// not number of bytes!
if (!SymGetSearchPathW(GetCurrentProcess(), symbols_path.get(),
kSymbolsArraySize)) {
g_init_error = GetLastError();
return false;
}
wchar_t exe_path[MAX_PATH];
GetExePath(exe_path);
std::wstring new_path(std::wstring(symbols_path.get()) + L";" +
std::wstring(exe_path));
if (!SymSetSearchPathW(GetCurrentProcess(), new_path.c_str())) {
g_init_error = GetLastError();
return false;
}
g_init_error = ERROR_SUCCESS;
return true;
}
// For the given trace, attempts to resolve the symbols, and output a trace
// to the ostream os. The format for each line of the backtrace is:
//
// <tab>SymbolName[0xAddress+Offset] (FileName:LineNo)
//
// This function should only be called if Init() has been called. We do not
// LOG(FATAL) here because this code is called might be triggered by a
// LOG(FATAL) itself. Also, it should not be calling complex code that is
// extensible like PathService since that can in turn fire CHECKs.
void OutputTraceToStream(const void* const* trace, size_t count,
std::ostream* os) {
for (size_t i = 0; (i < count) && os->good(); ++i) {
const int kMaxNameLength = 256;
DWORD_PTR frame = reinterpret_cast<DWORD_PTR>(trace[i]);
// Code adapted from MSDN example:
// http://msdn.microsoft.com/en-us/library/ms680578(VS.85).aspx
ULONG64 buffer[(sizeof(SYMBOL_INFO) + kMaxNameLength * sizeof(wchar_t) +
sizeof(ULONG64) - 1) /
sizeof(ULONG64)];
memset(buffer, 0, sizeof(buffer));
// Initialize symbol information retrieval structures.
DWORD64 sym_displacement = 0;
PSYMBOL_INFO symbol = reinterpret_cast<PSYMBOL_INFO>(&buffer[0]);
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
symbol->MaxNameLen = kMaxNameLength - 1;
BOOL has_symbol =
SymFromAddr(GetCurrentProcess(), frame, &sym_displacement, symbol);
// Attempt to retrieve line number information.
DWORD line_displacement = 0;
IMAGEHLP_LINE64 line = {};
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
BOOL has_line = SymGetLineFromAddr64(GetCurrentProcess(), frame,
&line_displacement, &line);
// Output the backtrace line.
(*os) << "\t";
if (has_symbol) {
(*os) << symbol->Name << " [0x" << trace[i] << "+" << sym_displacement
<< "]";
} else {
// If there is no symbol information, add a spacer.
(*os) << "(No symbol) [0x" << trace[i] << "]";
}
if (has_line) {
(*os) << " (" << line.FileName << ":" << line.LineNumber << ")";
}
(*os) << "\n";
}
}
} // namespace
bool EnableInProcessStackDumping() {
// Add stack dumping support on exception on windows. Similar to OS_POSIX
// signal() handling in process_util_posix.cc.
g_previous_filter = SetUnhandledExceptionFilter(&StackDumpExceptionFilter);
g_dump_stack_in_signal_handler = true;
// Need to initialize symbols early in the process or else this fails on
// swarming (since symbols are in different directory than in the exes) and
// also release x64.
return InitializeSymbols();
}
void DisableSignalStackDump() {
g_dump_stack_in_signal_handler = false;
}
// Disable optimizations for the StackTrace::StackTrace function. It is
// important to disable at least frame pointer optimization ("y"), since
// that breaks CaptureStackBackTrace() and prevents StackTrace from working
// in Release builds (it may still be janky if other frames are using FPO,
// but at least it will make it further).
#if defined(COMPILER_MSVC)
#pragma optimize("", off)
#endif
StackTrace::StackTrace() {
// When walking our own stack, use CaptureStackBackTrace().
count_ = CaptureStackBackTrace(0, arraysize(trace_), trace_, NULL);
}
#if defined(COMPILER_MSVC)
#pragma optimize("", on)
#endif
StackTrace::StackTrace(EXCEPTION_POINTERS* exception_pointers) {
InitTrace(exception_pointers->ContextRecord);
}
StackTrace::StackTrace(const CONTEXT* context) { InitTrace(context); }
void StackTrace::InitTrace(const CONTEXT* context_record) {
// StackWalk64 modifies the register context in place, so we have to copy it
// so that downstream exception handlers get the right context. The incoming
// context may have had more register state (YMM, etc) than we need to unwind
// the stack. Typically StackWalk64 only needs integer and control registers.
CONTEXT context_copy;
memcpy(&context_copy, context_record, sizeof(context_copy));
context_copy.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL;
// When walking an exception stack, we need to use StackWalk64().
count_ = 0;
// Initialize stack walking.
STACKFRAME64 stack_frame;
memset(&stack_frame, 0, sizeof(stack_frame));
#if defined(_WIN64)
int machine_type = IMAGE_FILE_MACHINE_AMD64;
stack_frame.AddrPC.Offset = context_record->Rip;
stack_frame.AddrFrame.Offset = context_record->Rbp;
stack_frame.AddrStack.Offset = context_record->Rsp;
#else
int machine_type = IMAGE_FILE_MACHINE_I386;
stack_frame.AddrPC.Offset = context_record->Eip;
stack_frame.AddrFrame.Offset = context_record->Ebp;
stack_frame.AddrStack.Offset = context_record->Esp;
#endif
stack_frame.AddrPC.Mode = AddrModeFlat;
stack_frame.AddrFrame.Mode = AddrModeFlat;
stack_frame.AddrStack.Mode = AddrModeFlat;
while (StackWalk64(machine_type, GetCurrentProcess(), GetCurrentThread(),
&stack_frame, &context_copy, NULL,
&SymFunctionTableAccess64, &SymGetModuleBase64, NULL) &&
count_ < arraysize(trace_)) {
trace_[count_++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset);
}
for (size_t i = count_; i < arraysize(trace_); ++i) trace_[i] = NULL;
}
void StackTrace::Print() const { OutputToStream(&std::cerr); }
void StackTrace::OutputToStream(std::ostream* os) const {
InitializeSymbols();
if (g_init_error != ERROR_SUCCESS) {
(*os) << "Error initializing symbols (" << g_init_error
<< "). Dumping unresolved backtrace:\n";
for (size_t i = 0; (i < count_) && os->good(); ++i) {
(*os) << "\t" << trace_[i] << "\n";
}
} else {
(*os) << "\n";
(*os) << "==== C stack trace ===============================\n";
(*os) << "\n";
OutputTraceToStream(trace_, count_, os);
}
}
} // namespace debug
} // namespace base
} // namespace v8
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Slightly adapted for inclusion in V8.
// Copyright 2016 the V8 project authors. All rights reserved.
#ifndef V8_BASE_FREE_DELETER_H_
#define V8_BASE_FREE_DELETER_H_
#include <stdlib.h>
namespace v8 {
namespace base {
// Function object which invokes 'free' on its parameter, which must be
// a pointer. Can be used to store malloc-allocated pointers in std::unique_ptr:
//
// std::unique_ptr<int, base::FreeDeleter> foo_ptr(
// static_cast<int*>(malloc(sizeof(int))));
struct FreeDeleter {
inline void operator()(void* ptr) const { free(ptr); }
};
} // namespace base
} // namespace v8
#endif // V8_BASE_FREE_DELETER_H_
...@@ -4,17 +4,10 @@ ...@@ -4,17 +4,10 @@
#include "src/base/logging.h" #include "src/base/logging.h"
#if V8_LIBC_GLIBC || V8_OS_BSD
#include <cxxabi.h>
#include <dlfcn.h>
#include <execinfo.h>
#elif V8_OS_QNX
#include <backtrace.h>
#endif // V8_LIBC_GLIBC || V8_OS_BSD
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include "src/base/debug/stack_trace.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
namespace v8 { namespace v8 {
...@@ -49,53 +42,6 @@ DEFINE_CHECK_OP_IMPL(GE) ...@@ -49,53 +42,6 @@ DEFINE_CHECK_OP_IMPL(GE)
DEFINE_CHECK_OP_IMPL(GT) DEFINE_CHECK_OP_IMPL(GT)
#undef DEFINE_CHECK_OP_IMPL #undef DEFINE_CHECK_OP_IMPL
// Attempts to dump a backtrace (if supported).
void DumpBacktrace() {
#if V8_LIBC_GLIBC || V8_OS_BSD
void* trace[100];
int size = backtrace(trace, arraysize(trace));
OS::PrintError("\n==== C stack trace ===============================\n\n");
if (size == 0) {
OS::PrintError("(empty)\n");
} else {
for (int i = 1; i < size; ++i) {
OS::PrintError("%2d: ", i);
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("%s\n", info.dli_sname);
}
}
}
#elif V8_OS_QNX
char out[1024];
bt_accessor_t acc;
bt_memmap_t memmap;
bt_init_accessor(&acc, BT_SELF);
bt_load_memmap(&acc, &memmap);
bt_sprn_memmap(&memmap, out, sizeof(out));
OS::PrintError(out);
bt_addr_t trace[100];
int size = bt_get_backtrace(&acc, trace, arraysize(trace));
OS::PrintError("\n==== C stack trace ===============================\n\n");
if (size == 0) {
OS::PrintError("(empty)\n");
} else {
bt_sprnf_addrs(&memmap, trace, size, const_cast<char*>("%a\n"),
out, sizeof(out), NULL);
OS::PrintError(out);
}
bt_unload_memmap(&memmap);
bt_release_accessor(&acc);
#endif // V8_LIBC_GLIBC || V8_OS_BSD
}
} // namespace base } // namespace base
} // namespace v8 } // namespace v8
...@@ -111,7 +57,12 @@ extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { ...@@ -111,7 +57,12 @@ extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
v8::base::OS::VPrintError(format, arguments); v8::base::OS::VPrintError(format, arguments);
va_end(arguments); va_end(arguments);
v8::base::OS::PrintError("\n#\n"); v8::base::OS::PrintError("\n#\n");
v8::base::DumpBacktrace();
v8::base::debug::StackTrace trace;
trace.Print();
fflush(stderr); fflush(stderr);
// Avoid dumping stack trace on abort signal.
v8::base::debug::DisableSignalStackDump();
v8::base::OS::Abort(); v8::base::OS::Abort();
} }
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#ifndef V8_SHARED #ifndef V8_SHARED
#include "src/api.h" #include "src/api.h"
#include "src/base/cpu.h" #include "src/base/cpu.h"
#include "src/base/debug/stack_trace.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/base/sys-info.h" #include "src/base/sys-info.h"
...@@ -2538,6 +2539,9 @@ static void DumpHeapConstants(i::Isolate* isolate) { ...@@ -2538,6 +2539,9 @@ static void DumpHeapConstants(i::Isolate* isolate) {
int Shell::Main(int argc, char* argv[]) { int Shell::Main(int argc, char* argv[]) {
std::ofstream trace_file; std::ofstream trace_file;
#ifndef V8_SHARED
v8::base::debug::EnableInProcessStackDumping();
#endif
#if (defined(_WIN32) || defined(_WIN64)) #if (defined(_WIN32) || defined(_WIN64))
UINT new_flags = UINT new_flags =
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
......
...@@ -1767,10 +1767,13 @@ ...@@ -1767,10 +1767,13 @@
'base/cpu.h', 'base/cpu.h',
'base/division-by-constant.cc', 'base/division-by-constant.cc',
'base/division-by-constant.h', 'base/division-by-constant.h',
'base/debug/stack_trace.cc',
'base/debug/stack_trace.h',
'base/file-utils.cc', 'base/file-utils.cc',
'base/file-utils.h', 'base/file-utils.h',
'base/flags.h', 'base/flags.h',
'base/format-macros.h', 'base/format-macros.h',
'base/free_deleter.h',
'base/functional.cc', 'base/functional.cc',
'base/functional.h', 'base/functional.h',
'base/hashmap.h', 'base/hashmap.h',
...@@ -1817,14 +1820,16 @@ ...@@ -1817,14 +1820,16 @@
], ],
}, },
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-linux.cc', 'base/platform/platform-linux.cc',
'base/platform/platform-posix.cc' 'base/platform/platform-posix.cc',
], ],
} }
], ],
['OS=="android"', { ['OS=="android"', {
'sources': [ 'sources': [
'base/platform/platform-posix.cc' 'base/debug/stack_trace_android.cc',
'base/platform/platform-posix.cc',
], ],
'link_settings': { 'link_settings': {
'target_conditions': [ 'target_conditions': [
...@@ -1878,8 +1883,9 @@ ...@@ -1878,8 +1883,9 @@
], ],
}, },
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-posix.cc', 'base/platform/platform-posix.cc',
'base/qnx-math.h', 'base/qnx-math.h'
], ],
'target_conditions': [ 'target_conditions': [
['_toolset=="host" and host_os=="linux"', { ['_toolset=="host" and host_os=="linux"', {
...@@ -1906,8 +1912,9 @@ ...@@ -1906,8 +1912,9 @@
'-L/usr/local/lib -lexecinfo', '-L/usr/local/lib -lexecinfo',
]}, ]},
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-freebsd.cc', 'base/platform/platform-freebsd.cc',
'base/platform/platform-posix.cc' 'base/platform/platform-posix.cc',
], ],
} }
], ],
...@@ -1928,8 +1935,9 @@ ...@@ -1928,8 +1935,9 @@
'-L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lexecinfo', '-L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lexecinfo',
]}, ]},
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-openbsd.cc', 'base/platform/platform-openbsd.cc',
'base/platform/platform-posix.cc' 'base/platform/platform-posix.cc',
], ],
} }
], ],
...@@ -1945,15 +1953,17 @@ ...@@ -1945,15 +1953,17 @@
'-lnsl -lrt', '-lnsl -lrt',
]}, ]},
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-solaris.cc', 'base/platform/platform-solaris.cc',
'base/platform/platform-posix.cc' 'base/platform/platform-posix.cc',
], ],
} }
], ],
['OS=="mac"', { ['OS=="mac"', {
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-macos.cc', 'base/platform/platform-macos.cc',
'base/platform/platform-posix.cc' 'base/platform/platform-posix.cc',
]}, ]},
], ],
['OS=="win"', { ['OS=="win"', {
...@@ -1971,11 +1981,13 @@ ...@@ -1971,11 +1981,13 @@
'conditions': [ 'conditions': [
['build_env=="Cygwin"', { ['build_env=="Cygwin"', {
'sources': [ 'sources': [
'base/debug/stack_trace_posix.cc',
'base/platform/platform-cygwin.cc', 'base/platform/platform-cygwin.cc',
'base/platform/platform-posix.cc' 'base/platform/platform-posix.cc',
], ],
}, { }, {
'sources': [ 'sources': [
'base/debug/stack_trace_win.cc',
'base/platform/platform-win32.cc', 'base/platform/platform-win32.cc',
'base/win32-headers.h', 'base/win32-headers.h',
], ],
...@@ -1986,12 +1998,18 @@ ...@@ -1986,12 +1998,18 @@
}, },
}, { }, {
'sources': [ 'sources': [
'base/debug/stack_trace_win.cc',
'base/platform/platform-win32.cc', 'base/platform/platform-win32.cc',
'base/win32-headers.h', 'base/win32-headers.h',
], ],
'msvs_disabled_warnings': [4351, 4355, 4800], 'msvs_disabled_warnings': [4351, 4355, 4800],
'link_settings': { 'link_settings': {
'libraries': [ '-lwinmm.lib', '-lws2_32.lib' ], 'libraries': [
'-ldbghelp.lib',
'-lshlwapi.lib',
'-lwinmm.lib',
'-lws2_32.lib'
],
}, },
}], }],
], ],
......
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