| 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__ |
| 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 |
| 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. |
| 459 #define CHECK(condition) \ | 465 #define CHECK(condition) \ |
| 460 !(condition) ? ::base::debug::BreakDebugger() : EAT_STREAM_PARAMETERS | 466 !(condition) ? LOGGING_CRASH() : EAT_STREAM_PARAMETERS |
| 461 | 467 |
| 462 #define PCHECK(condition) CHECK(condition) | 468 #define PCHECK(condition) CHECK(condition) |
| 463 | 469 |
| 464 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) | 470 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) |
| 465 | 471 |
| 466 #else // !(OFFICIAL_BUILD && NDEBUG) | 472 #else // !(OFFICIAL_BUILD && NDEBUG) |
| 467 | 473 |
| 468 #if defined(_PREFAST_) && defined(OS_WIN) | 474 #if defined(_PREFAST_) && defined(OS_WIN) |
| 469 // Use __analysis_assume to tell the VC++ static analysis engine that | 475 // Use __analysis_assume to tell the VC++ static analysis engine that |
| 470 // assert conditions are true, to suppress warnings. The LAZY_STREAM | 476 // 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 | 979 #elif NOTIMPLEMENTED_POLICY == 5 |
| 974 #define NOTIMPLEMENTED() do {\ | 980 #define NOTIMPLEMENTED() do {\ |
| 975 static bool logged_once = false;\ | 981 static bool logged_once = false;\ |
| 976 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 982 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 977 logged_once = true;\ | 983 logged_once = true;\ |
| 978 } while(0);\ | 984 } while(0);\ |
| 979 EAT_STREAM_PARAMETERS | 985 EAT_STREAM_PARAMETERS |
| 980 #endif | 986 #endif |
| 981 | 987 |
| 982 #endif // BASE_LOGGING_H_ | 988 #endif // BASE_LOGGING_H_ |
| OLD | NEW |