diff options
Diffstat (limited to 'deps/v8/src/base/logging.cc')
-rw-r--r-- | deps/v8/src/base/logging.cc | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/deps/v8/src/base/logging.cc b/deps/v8/src/base/logging.cc index ad5349ac7e..e58fdba09f 100644 --- a/deps/v8/src/base/logging.cc +++ b/deps/v8/src/base/logging.cc @@ -119,16 +119,50 @@ DEFINE_CHECK_OP_IMPL(GT) } // namespace base } // namespace v8 +namespace { + +// FailureMessage is a stack allocated object which has a special marker field +// at the start and at the end. This makes it possible to retrieve the embedded +// message from the stack. +// +class FailureMessage { + public: + explicit FailureMessage(const char* format, va_list arguments) { + memset(&message_, 0, arraysize(message_)); + v8::base::OS::VSNPrintF(&message_[0], arraysize(message_), format, + arguments); + } + + static const uintptr_t kStartMarker = 0xdecade10; + static const uintptr_t kEndMarker = 0xdecade11; + static const int kMessageBufferSize = 1024; + + uintptr_t start_marker_ = kStartMarker; + char message_[kMessageBufferSize]; + uintptr_t end_marker_ = kEndMarker; +}; + +} // namespace + void V8_Fatal(const char* file, int line, const char* format, ...) { + va_list arguments; + va_start(arguments, format); + // Format the error message into a stack object for later retrieveal by the + // crash processor. + FailureMessage message(format, arguments); + va_end(arguments); + fflush(stdout); fflush(stderr); v8::base::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); - va_list arguments; + + // Print the error message. va_start(arguments, format); v8::base::OS::VPrintError(format, arguments); va_end(arguments); - v8::base::OS::PrintError("\n#\n"); + // Print the message object's address to force stack allocation. + v8::base::OS::PrintError("\n#\n#\n#\n#FailureMessage Object: %p", &message); if (v8::base::g_print_stack_trace) v8::base::g_print_stack_trace(); |