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

Unified Diff: base/logging.h

Issue 1814423002: Patch to try dump-on-DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable Blink ASSERT in dump-without-DCHECK builds Created 4 years, 9 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
Index: base/logging.h
diff --git a/base/logging.h b/base/logging.h
index 07674698e0220dbd7d2ab1662556e2853adc275d..84d6cc338100ca987037c7e92d62ee48542dfe88 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -637,11 +637,17 @@ enum { DEBUG_MODE = ENABLE_DLOG };
#if DCHECK_IS_ON()
+// If DCHECK is configured to dump-without-crashing then omit these, so that
+// anything using them directly will break the build. See crbug.com/596231.
+#if !defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+
#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;
+#endif // !defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+
#else // DCHECK_IS_ON()
// These are just dummy values.
@@ -660,6 +666,10 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
#if defined(_PREFAST_) && defined(OS_WIN)
// See comments on the previous use of __analysis_assume.
+#if defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+#error "Only one of _PREFAST_ and DCHECK_IS_DUMP_WITHOUT_CRASH may be set"
+#endif // defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+
#define DCHECK(condition) \
__analysis_assume(!!(condition)), \
LAZY_STREAM(LOG_STREAM(DCHECK), false) \
@@ -670,7 +680,20 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
<< "Check failed: " #condition ". "
-#else // _PREFAST_
+#elif DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+// DCHECK is configured to dump-without-crashing, rather than logging.
+// See crbug.com/596231.
+
+BASE_EXPORT void DCheckDumpWithoutCrashing();
+
+#define DCHECK(condition) \
+ (condition) ? (void)0 : logging::DCheckDumpWithoutCrashing(), \
+ EAT_STREAM_PARAMETERS
+
+// Since we're uploading a crash dump, not logging, DPCHECK behaves identically.
+#define DPCHECK(condition) DCHECK(condition)
+
+#else // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
#define DCHECK(condition) \
LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
@@ -680,10 +703,21 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
<< "Check failed: " #condition ". "
-#endif // _PREFAST_
+#endif // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
+
+#if DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+// DCHECK is configured to dump-without-crashing, rather than logging.
+// See crbug.com/596231.
+
+// Use logging::Check*Impl() to ensure that operator<<()s don't go unused.
+#define DCHECK_OP(name, op, val1, val2) \
+ DCHECK(logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2))
+
+#else // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
+
// The 'switch' is used to prevent the 'else' from being ambiguous when the
// macro is used in an 'if' clause such as:
// if (a == 1)
@@ -699,6 +733,8 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \
true_if_passed.message()).stream()
+#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, ...)

Powered by Google App Engine
This is Rietveld 408576698