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

Side by Side Diff: base/logging.h

Issue 2046593002: Revert of In official builds, let CHECK(false) crash instead of calling BreakDebugger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // compilation mode. 446 // compilation mode.
447 // 447 //
448 // We make sure CHECK et al. always evaluates their arguments, as 448 // We make sure CHECK et al. always evaluates their arguments, as
449 // doing CHECK(FunctionWithSideEffect()) is a common idiom. 449 // doing CHECK(FunctionWithSideEffect()) is a common idiom.
450 450
451 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) 451 #if defined(OFFICIAL_BUILD) && defined(NDEBUG)
452 452
453 // Make all CHECK functions discard their log strings to reduce code 453 // Make all CHECK functions discard their log strings to reduce code
454 // bloat, and improve performance, for official release builds. 454 // bloat, and improve performance, for official release builds.
455 455
456 #if defined(COMPILER_GCC) || __clang__ 456 // TODO(akalin): This would be more valuable if there were some way to
457 #define LOGGING_CRASH() __builtin_trap() 457 // remove BreakDebugger() from the backtrace, perhaps by turning it
458 #else 458 // into a macro (like __debugbreak() on Windows).
459 #define LOGGING_CRASH() ((void)(*(volatile char*)0 = 0))
460 #endif
461
462 // This is not calling BreakDebugger since this is called frequently, and
463 // calling an out-of-line function instead of a noreturn inline macro prevents
464 // compiler optimizations.
465 #define CHECK(condition) \ 459 #define CHECK(condition) \
466 !(condition) ? LOGGING_CRASH() : EAT_STREAM_PARAMETERS 460 !(condition) ? ::base::debug::BreakDebugger() : EAT_STREAM_PARAMETERS
467 461
468 #define PCHECK(condition) CHECK(condition) 462 #define PCHECK(condition) CHECK(condition)
469 463
470 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) 464 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2))
471 465
472 #else // !(OFFICIAL_BUILD && NDEBUG) 466 #else // !(OFFICIAL_BUILD && NDEBUG)
473 467
474 #if defined(_PREFAST_) && defined(OS_WIN) 468 #if defined(_PREFAST_) && defined(OS_WIN)
475 // Use __analysis_assume to tell the VC++ static analysis engine that 469 // Use __analysis_assume to tell the VC++ static analysis engine that
476 // assert conditions are true, to suppress warnings. The LAZY_STREAM 470 // assert conditions are true, to suppress warnings. The LAZY_STREAM
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 #elif NOTIMPLEMENTED_POLICY == 5 973 #elif NOTIMPLEMENTED_POLICY == 5
980 #define NOTIMPLEMENTED() do {\ 974 #define NOTIMPLEMENTED() do {\
981 static bool logged_once = false;\ 975 static bool logged_once = false;\
982 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 976 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
983 logged_once = true;\ 977 logged_once = true;\
984 } while(0);\ 978 } while(0);\
985 EAT_STREAM_PARAMETERS 979 EAT_STREAM_PARAMETERS
986 #endif 980 #endif
987 981
988 #endif // BASE_LOGGING_H_ 982 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698