summaryrefslogtreecommitdiffstats
path: root/base/logging.h
diff options
context:
space:
mode:
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-10 18:23:38 +0000
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-10 18:23:38 +0000
commit1a150551a669a94dbdc316b452721b721354bedc (patch)
treeafe18b1e11656f71d8cb09f19c88ae5a88773dab /base/logging.h
parent9d4a5601ae06d88f19522e0aca4f08f2f0c946c3 (diff)
downloadchromium_src-1a150551a669a94dbdc316b452721b721354bedc.zip
chromium_src-1a150551a669a94dbdc316b452721b721354bedc.tar.gz
chromium_src-1a150551a669a94dbdc316b452721b721354bedc.tar.bz2
Let DCHECK in non-official-release build be opt-in with dcheck_always_on=1 only
- Remove DCHECK in non-official-release build by default - Gyp variable dcheck_always_on=1 (existing) forces to enable DCHECK in release build - Remove flag --enable-dcheck Other effects/notes: - Now allow "buildtype=Official dcheck_always_on=1" (which will enable DCHECK in official build) combination. - Gyp variable logging_like_official_build no longer has an effect - Leave DCHECK_IS_ON() unchanged. May deal with it in a later change if needed. This won't affect bots which use dcheck_always_on=1. BUG=350462 TEST=LoggingTest.Dcheck R=thakis@chromium.org TBR=darin,sehr (command line changes in components/nacl and mojo) Review URL: https://codereview.chromium.org/189603007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255987 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.h')
-rw-r--r--base/logging.h76
1 files changed, 8 insertions, 68 deletions
diff --git a/base/logging.h b/base/logging.h
index 2c538d2..b1f1ebd1 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -181,11 +181,6 @@ enum LogLockingState { LOCK_LOG_FILE, DONT_LOCK_LOG_FILE };
// Defaults to APPEND_TO_OLD_LOG_FILE.
enum OldFileDeletionState { DELETE_OLD_LOG_FILE, APPEND_TO_OLD_LOG_FILE };
-enum DcheckState {
- DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS,
- ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS
-};
-
struct BASE_EXPORT LoggingSettings {
// The defaults values are:
//
@@ -193,7 +188,6 @@ struct BASE_EXPORT LoggingSettings {
// log_file: NULL
// lock_log: LOCK_LOG_FILE
// delete_old: APPEND_TO_OLD_LOG_FILE
- // dcheck_state: DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS
LoggingSettings();
LoggingDestination logging_dest;
@@ -203,8 +197,6 @@ struct BASE_EXPORT LoggingSettings {
const PathChar* log_file;
LogLockingState lock_log;
OldFileDeletionState delete_old;
-
- DcheckState dcheck_state;
};
// Define different names for the BaseInitLoggingImpl() function depending on
@@ -465,20 +457,6 @@ const LogSeverity LOG_0 = LOG_ERROR;
#define PLOG_IF(severity, condition) \
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
-#if !defined(NDEBUG)
-// Debug builds always include DCHECK and DLOG.
-#undef LOGGING_IS_OFFICIAL_BUILD
-#define LOGGING_IS_OFFICIAL_BUILD 0
-#elif defined(OFFICIAL_BUILD)
-// Official release builds always disable and remove DCHECK and DLOG.
-#undef LOGGING_IS_OFFICIAL_BUILD
-#define LOGGING_IS_OFFICIAL_BUILD 1
-#elif !defined(LOGGING_IS_OFFICIAL_BUILD)
-// Unless otherwise specified, unofficial release builds include
-// DCHECK and DLOG.
-#define LOGGING_IS_OFFICIAL_BUILD 0
-#endif
-
// The actual stream used isn't important.
#define EAT_STREAM_PARAMETERS \
true ? (void) 0 : ::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
@@ -490,10 +468,10 @@ const LogSeverity LOG_0 = LOG_ERROR;
// We make sure CHECK et al. always evaluates their arguments, as
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
-#if LOGGING_IS_OFFICIAL_BUILD
+#if defined(OFFICIAL_BUILD) && defined(NDEBUG)
// Make all CHECK functions discard their log strings to reduce code
-// bloat for official builds.
+// bloat for official release builds.
// TODO(akalin): This would be more valuable if there were some way to
// remove BreakDebugger() from the backtrace, perhaps by turning it
@@ -590,21 +568,15 @@ DEFINE_CHECK_OP_IMPL(GT, > )
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
-#if LOGGING_IS_OFFICIAL_BUILD
-// In order to have optimized code for official builds, remove DLOGs and
-// DCHECKs.
-#define ENABLE_DLOG 0
-#define ENABLE_DCHECK 0
-
-#elif defined(NDEBUG)
-// Otherwise, if we're a release build, remove DLOGs but not DCHECKs
-// (since those can still be turned on via a command-line flag).
+#if defined(NDEBUG)
#define ENABLE_DLOG 0
-#define ENABLE_DCHECK 1
-
#else
-// Otherwise, we're a debug build so enable DLOGs and DCHECKs.
#define ENABLE_DLOG 1
+#endif
+
+#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
+#define ENABLE_DCHECK 0
+#else
#define ENABLE_DCHECK 1
#endif
@@ -672,44 +644,12 @@ enum { DEBUG_MODE = ENABLE_DLOG };
#if ENABLE_DCHECK
-#if defined(NDEBUG)
-
-BASE_EXPORT extern DcheckState g_dcheck_state;
-BASE_EXPORT void set_dcheck_state(DcheckState state);
-
-#if defined(DCHECK_ALWAYS_ON)
-
-#define DCHECK_IS_ON() true
-#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;
-
-#else
-
-#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
- COMPACT_GOOGLE_LOG_EX_ERROR_REPORT(ClassName , ##__VA_ARGS__)
-#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_ERROR_REPORT
-const LogSeverity LOG_DCHECK = LOG_ERROR_REPORT;
-
-#define DCHECK_IS_ON() \
- UNLIKELY(::logging::g_dcheck_state == \
- ::logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS) && \
- LOG_IS_ON(DCHECK)
-
-#endif // defined(DCHECK_ALWAYS_ON)
-
-#else // defined(NDEBUG)
-
-// On a regular debug build, we want to have DCHECKs enabled.
#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;
#define DCHECK_IS_ON() true
-#endif // defined(NDEBUG)
-
#else // ENABLE_DCHECK
// These are just dummy values since DCHECK_IS_ON() is always false in