Index: base/logging.cc |
diff --git a/base/logging.cc b/base/logging.cc |
index cea6edae4a37cef2519ff32045c46c0a3c73e4d0..1af2dc0561093992838e6c38e4d31afb89109cb5 100644 |
--- a/base/logging.cc |
+++ b/base/logging.cc |
@@ -57,6 +57,7 @@ typedef pthread_mutex_t* MutexHandle; |
#include "base/command_line.h" |
#include "base/debug/alias.h" |
#include "base/debug/debugger.h" |
+#include "base/debug/dump_without_crashing.h" |
#include "base/debug/stack_trace.h" |
#include "base/posix/eintr_wrapper.h" |
#include "base/strings/string_piece.h" |
@@ -123,6 +124,7 @@ bool show_error_dialogs = false; |
// An assert handler override specified by the client to be called instead of |
// the debug message dialog and process termination. |
LogAssertHandlerFunction log_assert_handler = nullptr; |
+ |
// A log message handler that gets notified of every log message we process. |
LogMessageHandlerFunction log_message_handler = nullptr; |
@@ -726,7 +728,7 @@ LogMessage::~LogMessage() { |
} |
} |
- if (severity_ == LOG_FATAL) { |
+ if (severity_ == LOG_FATAL || severity_ == LOG_DUMP) { |
// Write the log message to the global activity tracker, if running. |
base::debug::GlobalActivityTracker* tracker = |
base::debug::GlobalActivityTracker::Get(); |
@@ -739,7 +741,21 @@ LogMessage::~LogMessage() { |
str_newline.copy(str_stack, arraysize(str_stack)); |
base::debug::Alias(str_stack); |
- if (log_assert_handler) { |
+ if (severity_ == LOG_DUMP) { |
Wez
2016/12/19 23:57:46
Q: Is it more or less readable to have LOG_DUMP im
|
+ // To ensure we don't risk spamming Crash with dump-on-DCHECK reports we |
+ // log |
+ // only the first[*] DCHECK to fail once DumpWithoutCrashing() is working. |
+ // [*] This is racey, but in the pathological case still only results in |
+ // one |
+ // dump per-racing-thread, rather than our aim of one per-process. |
Wez
2016/12/19 23:57:46
Note to self: Fix comment line-wrap.
|
+ static bool dump_on_dcheck = true; |
+ if (dump_on_dcheck) |
+ dump_on_dcheck = !base::debug::DumpWithoutCrashing(); |
+ return; |
+ } |
+ |
+ |
+ else if (log_assert_handler) { |
// Make a copy of the string for the handler out of paranoia. |
log_assert_handler(std::string(stream_.str())); |
} else { |