Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // TODO(akalin): This would be more valuable if there were some way to | 456 #if defined(COMPILER_GCC) || __clang__ |
|
danakj
2016/05/16 23:43:11
Can you leave a comment saying this is explicitly
| |
| 457 // remove BreakDebugger() from the backtrace, perhaps by turning it | 457 #define LOGGING_CRASH() __builtin_trap() |
| 458 // into a macro (like __debugbreak() on Windows). | 458 #else |
| 459 #define LOGGING_CRASH() ((void)(*(volatile char*)0 = 0)) | |
| 460 #endif | |
| 461 | |
| 459 #define CHECK(condition) \ | 462 #define CHECK(condition) \ |
| 460 !(condition) ? ::base::debug::BreakDebugger() : EAT_STREAM_PARAMETERS | 463 !(condition) ? LOGGING_CRASH() : EAT_STREAM_PARAMETERS |
| 461 | 464 |
| 462 #define PCHECK(condition) CHECK(condition) | 465 #define PCHECK(condition) CHECK(condition) |
| 463 | 466 |
| 464 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) | 467 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) |
| 465 | 468 |
| 466 #else // !(OFFICIAL_BUILD && NDEBUG) | 469 #else // !(OFFICIAL_BUILD && NDEBUG) |
| 467 | 470 |
| 468 #if defined(_PREFAST_) && defined(OS_WIN) | 471 #if defined(_PREFAST_) && defined(OS_WIN) |
| 469 // Use __analysis_assume to tell the VC++ static analysis engine that | 472 // Use __analysis_assume to tell the VC++ static analysis engine that |
| 470 // assert conditions are true, to suppress warnings. The LAZY_STREAM | 473 // assert conditions are true, to suppress warnings. The LAZY_STREAM |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 #elif NOTIMPLEMENTED_POLICY == 5 | 976 #elif NOTIMPLEMENTED_POLICY == 5 |
| 974 #define NOTIMPLEMENTED() do {\ | 977 #define NOTIMPLEMENTED() do {\ |
| 975 static bool logged_once = false;\ | 978 static bool logged_once = false;\ |
| 976 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 979 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 977 logged_once = true;\ | 980 logged_once = true;\ |
| 978 } while(0);\ | 981 } while(0);\ |
| 979 EAT_STREAM_PARAMETERS | 982 EAT_STREAM_PARAMETERS |
| 980 #endif | 983 #endif |
| 981 | 984 |
| 982 #endif // BASE_LOGGING_H_ | 985 #endif // BASE_LOGGING_H_ |
| OLD | NEW |