| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 typedef HANDLE FileHandle; | 10 typedef HANDLE FileHandle; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 std::string* result) | 538 std::string* result) |
| 539 : severity_(severity), file_(file), line_(line) { | 539 : severity_(severity), file_(file), line_(line) { |
| 540 Init(file, line); | 540 Init(file, line); |
| 541 stream_ << "Check failed: " << *result; | 541 stream_ << "Check failed: " << *result; |
| 542 delete result; | 542 delete result; |
| 543 } | 543 } |
| 544 | 544 |
| 545 LogMessage::~LogMessage() { | 545 LogMessage::~LogMessage() { |
| 546 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) && \ | 546 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) && \ |
| 547 !defined(FNL_MUSL) | 547 !defined(FNL_MUSL) |
| 548 if (severity_ == LOG_FATAL) { | 548 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { |
| 549 // Include a stack trace on a fatal. | 549 // Include a stack trace on a fatal, unless a debugger is attached. |
| 550 base::debug::StackTrace trace; | 550 base::debug::StackTrace trace; |
| 551 stream_ << std::endl; // Newline to separate from log message. | 551 stream_ << std::endl; // Newline to separate from log message. |
| 552 trace.OutputToStream(&stream_); | 552 trace.OutputToStream(&stream_); |
| 553 } | 553 } |
| 554 #endif | 554 #endif |
| 555 stream_ << std::endl; | 555 stream_ << std::endl; |
| 556 std::string str_newline(stream_.str()); | 556 std::string str_newline(stream_.str()); |
| 557 | 557 |
| 558 // Give any log message handler first dibs on the message. | 558 // Give any log message handler first dibs on the message. |
| 559 if (log_message_handler && | 559 if (log_message_handler && |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 if (log_assert_handler) { | 633 if (log_assert_handler) { |
| 634 // Make a copy of the string for the handler out of paranoia. | 634 // Make a copy of the string for the handler out of paranoia. |
| 635 log_assert_handler(std::string(stream_.str())); | 635 log_assert_handler(std::string(stream_.str())); |
| 636 } else { | 636 } else { |
| 637 // Don't use the string with the newline, get a fresh version to send to | 637 // Don't use the string with the newline, get a fresh version to send to |
| 638 // the debug message process. We also don't display assertions to the | 638 // the debug message process. We also don't display assertions to the |
| 639 // user in release mode. The enduser can't do anything with this | 639 // user in release mode. The enduser can't do anything with this |
| 640 // information, and displaying message boxes when the application is | 640 // information, and displaying message boxes when the application is |
| 641 // hosed can cause additional problems. | 641 // hosed can cause additional problems. |
| 642 #ifndef NDEBUG | 642 #ifndef NDEBUG |
| 643 DisplayDebugMessageInDialog(stream_.str()); | 643 if (!base::debug::BeingDebugged()) { |
| 644 // Displaying a dialog is unnecessary when debugging and can complicate |
| 645 // debugging. |
| 646 DisplayDebugMessageInDialog(stream_.str()); |
| 647 } |
| 644 #endif | 648 #endif |
| 645 // Crash the process to generate a dump. | 649 // Crash the process to generate a dump. |
| 646 base::debug::BreakDebugger(); | 650 base::debug::BreakDebugger(); |
| 647 } | 651 } |
| 648 } | 652 } |
| 649 } | 653 } |
| 650 | 654 |
| 651 // writes the common header info to the stream | 655 // writes the common header info to the stream |
| 652 void LogMessage::Init(const char* file, int line) { | 656 void LogMessage::Init(const char* file, int line) { |
| 653 base::StringPiece filename(file); | 657 base::StringPiece filename(file); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 817 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 814 LogMessage(file, line, LOG_ERROR).stream() | 818 LogMessage(file, line, LOG_ERROR).stream() |
| 815 << "NOTREACHED() hit."; | 819 << "NOTREACHED() hit."; |
| 816 } | 820 } |
| 817 | 821 |
| 818 } // namespace logging | 822 } // namespace logging |
| 819 | 823 |
| 820 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 824 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 821 return out << base::WideToUTF8(wstr); | 825 return out << base::WideToUTF8(wstr); |
| 822 } | 826 } |
| OLD | NEW |