Chromium Code Reviews| Index: base/logging.h |
| diff --git a/base/logging.h b/base/logging.h |
| index 07674698e0220dbd7d2ab1662556e2853adc275d..fe015b58bf796cb1863cff7389024a70c964bdf0 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,19 @@ 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. |
| +// 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) |
| #define DCHECK(condition) \ |
| LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ |
| @@ -680,10 +702,22 @@ 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. |
| +// 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. |
| + |
| +#define DCHECK_OP(name, op, val1, val2) \ |
| + DCHECK((val1) op (val2)) |
|
ncarter (slow)
2016/04/14 18:41:34
This looks correct.
Wez
2016/04/14 19:54:39
Unfortunately, though, there is an operator<<(ostr
|
| + |
| +#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, ...) |