| Index: src/base/logging.cc
|
| diff --git a/src/base/logging.cc b/src/base/logging.cc
|
| index 25d77bb1ec1dc9b9e9e84e3ac2460eb689ac088f..7fe72315b129b109683f729e90c571017702be02 100644
|
| --- a/src/base/logging.cc
|
| +++ b/src/base/logging.cc
|
| @@ -18,6 +18,7 @@
|
|
|
| namespace v8 {
|
| namespace base {
|
| +namespace logging {
|
|
|
| // Explicit instantiations for commonly used comparisons.
|
| #define DEFINE_MAKE_CHECK_OP_STRING(type) \
|
| @@ -35,11 +36,11 @@ DEFINE_MAKE_CHECK_OP_STRING(void const*)
|
|
|
|
|
| // Explicit instantiations for floating point checks.
|
| -#define DEFINE_CHECK_OP_IMPL(NAME) \
|
| - template std::string* Check##NAME##Impl<float, float>( \
|
| - float const& lhs, float const& rhs, char const* msg); \
|
| - template std::string* Check##NAME##Impl<double, double>( \
|
| - double const& lhs, double const& rhs, char const* msg);
|
| +#define DEFINE_CHECK_OP_IMPL(NAME) \
|
| + template std::string* Check##NAME##Impl<float, float>( \
|
| + float const& lhs, float const& rhs, char const* result); \
|
| + template std::string* Check##NAME##Impl<double, double>( \
|
| + double const& lhs, double const& rhs, char const* result);
|
| DEFINE_CHECK_OP_IMPL(EQ)
|
| DEFINE_CHECK_OP_IMPL(NE)
|
| DEFINE_CHECK_OP_IMPL(LE)
|
| @@ -49,7 +50,37 @@ DEFINE_CHECK_OP_IMPL(GT)
|
| #undef DEFINE_CHECK_OP_IMPL
|
|
|
|
|
| +LogMessage::LogMessage(char const* file, int line, LogSeverity severity)
|
| + : file_(file), line_(line), severity_(severity) {}
|
| +
|
| +
|
| +LogMessage::LogMessage(char const* file, int line, std::string* result)
|
| + : file_(file), line_(line), severity_(LOG_FATAL) {
|
| + stream() << "Check failed: " << *result;
|
| + delete result;
|
| +}
|
| +
|
| +
|
| +LogMessage::LogMessage(char const* file, int line, LogSeverity severity,
|
| + std::string* result)
|
| + : file_(file), line_(line), severity_(severity) {
|
| + stream() << "Check failed: " << *result;
|
| + delete result;
|
| +}
|
| +
|
| +
|
| +LogMessage::~LogMessage() {
|
| + if (severity_ == LOG_FATAL) {
|
| + V8_Fatal(file_, line_, "%s", stream_.str().c_str());
|
| + }
|
| + OS::Print("%s\n", stream_.str().c_str());
|
| +}
|
| +
|
| +
|
| +namespace {
|
| +
|
| // Attempts to dump a backtrace (if supported).
|
| +// TODO(bmeurer): Inline this thing into the caller!
|
| void DumpBacktrace() {
|
| #if V8_LIBC_GLIBC || V8_OS_BSD
|
| void* trace[100];
|
| @@ -99,6 +130,9 @@ void DumpBacktrace() {
|
| #endif // V8_LIBC_GLIBC || V8_OS_BSD
|
| }
|
|
|
| +} // namespace
|
| +
|
| +} // namespace logging
|
| } // namespace base
|
| } // namespace v8
|
|
|
| @@ -114,7 +148,7 @@ extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
|
| v8::base::OS::VPrintError(format, arguments);
|
| va_end(arguments);
|
| v8::base::OS::PrintError("\n#\n");
|
| - v8::base::DumpBacktrace();
|
| + v8::base::logging::DumpBacktrace();
|
| fflush(stderr);
|
| v8::base::OS::Abort();
|
| }
|
|
|