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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 // Returns true if the check succeeded. | 454 // Returns true if the check succeeded. |
455 operator bool() const { return !message_; } | 455 operator bool() const { return !message_; } |
456 // Returns the message. | 456 // Returns the message. |
457 std::string* message() { return message_; } | 457 std::string* message() { return message_; } |
458 | 458 |
459 private: | 459 private: |
460 std::string* message_; | 460 std::string* message_; |
461 }; | 461 }; |
462 | 462 |
463 // Crashes in the fastest, simplest possible way with no attempt at logging. | 463 // Crashes in the fastest, simplest possible way with no attempt at logging. |
464 #if defined(COMPILER_GCC) || defined(__clang__) | 464 #if defined(COMPILER_GCC) || (defined(__clang__) && !defined(OS_WIN)) |
Nico
2017/02/10 22:45:30
the || __clang__ was here to use __builtin_trap on
scottmg
2017/02/11 05:58:30
Done.
| |
465 #define IMMEDIATE_CRASH() __builtin_trap() | 465 #define IMMEDIATE_CRASH() __builtin_trap() |
466 #elif defined(COMPILER_MSVC) || (defined(__clang__) && defined(OS_WIN)) | |
467 #define IMMEDIATE_CRASH() __debugbreak() | |
466 #else | 468 #else |
467 #define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0)) | 469 #error Port |
468 #endif | 470 #endif |
469 | 471 |
470 // CHECK dies with a fatal error if condition is not true. It is *not* | 472 // CHECK dies with a fatal error if condition is not true. It is *not* |
471 // controlled by NDEBUG, so the check will be executed regardless of | 473 // controlled by NDEBUG, so the check will be executed regardless of |
472 // compilation mode. | 474 // compilation mode. |
473 // | 475 // |
474 // We make sure CHECK et al. always evaluates their arguments, as | 476 // We make sure CHECK et al. always evaluates their arguments, as |
475 // doing CHECK(FunctionWithSideEffect()) is a common idiom. | 477 // doing CHECK(FunctionWithSideEffect()) is a common idiom. |
476 | 478 |
477 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) | 479 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 #elif NOTIMPLEMENTED_POLICY == 5 | 1073 #elif NOTIMPLEMENTED_POLICY == 5 |
1072 #define NOTIMPLEMENTED() do {\ | 1074 #define NOTIMPLEMENTED() do {\ |
1073 static bool logged_once = false;\ | 1075 static bool logged_once = false;\ |
1074 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 1076 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
1075 logged_once = true;\ | 1077 logged_once = true;\ |
1076 } while(0);\ | 1078 } while(0);\ |
1077 EAT_STREAM_PARAMETERS | 1079 EAT_STREAM_PARAMETERS |
1078 #endif | 1080 #endif |
1079 | 1081 |
1080 #endif // BASE_LOGGING_H_ | 1082 #endif // BASE_LOGGING_H_ |
OLD | NEW |