Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Unified Diff: base/logging.h

Issue 2288473002: Implement Dump-on-DCHECK (via a new LogSeverity). (Closed)
Patch Set: Pull the Official Windows build default in, and rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/allocator/partition_allocator/partition_alloc.h ('k') | base/logging.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.h
diff --git a/base/logging.h b/base/logging.h
index 5174e6d375540cd0f0bf355034c17812a66bf37b..7cc4ebb386619953dde5448e6e829e80817ca7a7 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -297,10 +297,13 @@ const LogSeverity LOG_INFO = 0;
const LogSeverity LOG_WARNING = 1;
const LogSeverity LOG_ERROR = 2;
const LogSeverity LOG_FATAL = 3;
-const LogSeverity LOG_NUM_SEVERITIES = 4;
+const LogSeverity LOG_DUMP = 4;
+const LogSeverity LOG_NUM_SEVERITIES = 5;
// LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode
-#ifdef NDEBUG
+#if defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+const LogSeverity LOG_DFATAL = LOG_DUMP;
+#elif NDEBUG
const LogSeverity LOG_DFATAL = LOG_ERROR;
#else
const LogSeverity LOG_DFATAL = LOG_FATAL;
@@ -694,9 +697,9 @@ enum { DEBUG_MODE = DCHECK_IS_ON() };
#if DCHECK_IS_ON()
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
- COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__)
-#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
-const LogSeverity LOG_DCHECK = LOG_FATAL;
+ COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ##__VA_ARGS__)
+#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_DFATAL
+const LogSeverity LOG_DCHECK = LOG_DFATAL;
#else // DCHECK_IS_ON()
@@ -750,7 +753,20 @@ inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
DCHECK_IS_ON() ? (logging::AnalyzerNoReturn() || !(condition)) : false) \
<< "Check failed: " #condition ". "
-#else
+#elif DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+// DCHECK is configured to dump-without-crashing, rather than logging.
+// Since we only intend to enable this in official builds, we follow the
+// example of CHECK_OP etc in official builds, and strip out logging.
+// See crbug.com/596231.
+
+BASE_EXPORT void DCheckDumpWithoutCrashing();
+
+#define DCHECK(condition) \
+ !(condition) ? ::logging::DCheckDumpWithoutCrashing() : EAT_STREAM_PARAMETERS
+
+#define DPCHECK(condition) DCHECK(condition)
+
+#else // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
#if DCHECK_IS_ON()
@@ -768,7 +784,7 @@ inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
#endif // DCHECK_IS_ON()
-#endif
+#endif // _PREFAST_
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
@@ -808,6 +824,8 @@ inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
#endif // DCHECK_IS_ON()
+#endif // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+
// Equality/Inequality checks - compare two values, and log a
// LOG_DCHECK message including the two values when the result is not
// as expected. The values must have operator<<(ostream, ...)
« no previous file with comments | « base/allocator/partition_allocator/partition_alloc.h ('k') | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698