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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 std::string* message() { return message_; } | 493 std::string* message() { return message_; } |
| 494 | 494 |
| 495 private: | 495 private: |
| 496 std::string* message_; | 496 std::string* message_; |
| 497 }; | 497 }; |
| 498 | 498 |
| 499 // Crashes in the fastest, simplest possible way with no attempt at logging. | 499 // Crashes in the fastest, simplest possible way with no attempt at logging. |
| 500 #if defined(COMPILER_GCC) | 500 #if defined(COMPILER_GCC) |
| 501 #define IMMEDIATE_CRASH() __builtin_trap() | 501 #define IMMEDIATE_CRASH() __builtin_trap() |
| 502 #elif defined(COMPILER_MSVC) | 502 #elif defined(COMPILER_MSVC) |
| 503 | |
| 504 // Clang is cleverer about coalescing int3s, so we need to add a unique-ish | |
| 505 // instruction following the __debugbreak() to have it emit distinct locations | |
| 506 // for CHECKs rather than collapsing them all together. It would be nice to use | |
| 507 // a short intrinsic to do this (and perhaps have only one implementation for | |
| 508 // both clang and MSVC), however clang-cl currently does not support intrinsics | |
| 509 // here. Adding the nullptr store to the MSVC path adds unnecessary bloat. | |
| 510 // TODO(scottmg): Reinvestigate a short sequence that will work on both | |
| 511 // compilers once clang supports more intrinsics. See https://crbug.com/693713. | |
| 512 #if defined(__clang__) | |
| 513 #define IMMEDIATE_CRASH() \ | |
| 514 (__debugbreak(), \ | |
| 515 (void)(*reinterpret_cast<volatile unsigned char*>(0) = __COUNTER__)) | |
|
Primiano Tucci (use gerrit)
2017/02/21 11:02:07
I arrived late on this. I had the same exact prob
| |
| 516 #else | |
| 503 #define IMMEDIATE_CRASH() __debugbreak() | 517 #define IMMEDIATE_CRASH() __debugbreak() |
| 518 #endif // __clang__ | |
| 519 | |
| 504 #else | 520 #else |
| 505 #error Port | 521 #error Port |
| 506 #endif | 522 #endif |
| 507 | 523 |
| 508 // CHECK dies with a fatal error if condition is not true. It is *not* | 524 // CHECK dies with a fatal error if condition is not true. It is *not* |
| 509 // controlled by NDEBUG, so the check will be executed regardless of | 525 // controlled by NDEBUG, so the check will be executed regardless of |
| 510 // compilation mode. | 526 // compilation mode. |
| 511 // | 527 // |
| 512 // We make sure CHECK et al. always evaluates their arguments, as | 528 // We make sure CHECK et al. always evaluates their arguments, as |
| 513 // doing CHECK(FunctionWithSideEffect()) is a common idiom. | 529 // doing CHECK(FunctionWithSideEffect()) is a common idiom. |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1057 #elif NOTIMPLEMENTED_POLICY == 5 | 1073 #elif NOTIMPLEMENTED_POLICY == 5 |
| 1058 #define NOTIMPLEMENTED() do {\ | 1074 #define NOTIMPLEMENTED() do {\ |
| 1059 static bool logged_once = false;\ | 1075 static bool logged_once = false;\ |
| 1060 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 1076 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 1061 logged_once = true;\ | 1077 logged_once = true;\ |
| 1062 } while(0);\ | 1078 } while(0);\ |
| 1063 EAT_STREAM_PARAMETERS | 1079 EAT_STREAM_PARAMETERS |
| 1064 #endif | 1080 #endif |
| 1065 | 1081 |
| 1066 #endif // BASE_LOGGING_H_ | 1082 #endif // BASE_LOGGING_H_ |
| OLD | NEW |