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

Side by Side Diff: base/logging.h

Issue 2676483002: Make CHECK int 3 on Windows, rather than crash (Closed)
Patch Set: . Created 3 years, 10 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 | base/logging_unittest.cc » ('j') | base/logging_unittest.cc » ('J')
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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
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))
465 #define IMMEDIATE_CRASH() __builtin_trap() 465 #define IMMEDIATE_CRASH() __builtin_trap()
466 #else 466 #elif defined(COMPILER_MSVC) || (defined(__clang__) && defined(OS_WIN))
467 #define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0)) 467 #define IMMEDIATE_CRASH() __debugbreak()
Will Harris 2017/02/02 03:12:03 might be nice to have an #else and an #error here
Primiano Tucci (use gerrit) 2017/02/03 03:15:05 not an owner, but +1 to the #error pointing to crb
scottmg 2017/02/06 19:50:47 That's why I left the deref null in the #else bloc
468 #endif 468 #endif
469 469
470 // CHECK dies with a fatal error if condition is not true. It is *not* 470 // 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 471 // controlled by NDEBUG, so the check will be executed regardless of
472 // compilation mode. 472 // compilation mode.
473 // 473 //
474 // We make sure CHECK et al. always evaluates their arguments, as 474 // We make sure CHECK et al. always evaluates their arguments, as
475 // doing CHECK(FunctionWithSideEffect()) is a common idiom. 475 // doing CHECK(FunctionWithSideEffect()) is a common idiom.
476 476
477 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) 477 #if defined(OFFICIAL_BUILD) && defined(NDEBUG)
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 #elif NOTIMPLEMENTED_POLICY == 5 1071 #elif NOTIMPLEMENTED_POLICY == 5
1072 #define NOTIMPLEMENTED() do {\ 1072 #define NOTIMPLEMENTED() do {\
1073 static bool logged_once = false;\ 1073 static bool logged_once = false;\
1074 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1074 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1075 logged_once = true;\ 1075 logged_once = true;\
1076 } while(0);\ 1076 } while(0);\
1077 EAT_STREAM_PARAMETERS 1077 EAT_STREAM_PARAMETERS
1078 #endif 1078 #endif
1079 1079
1080 #endif // BASE_LOGGING_H_ 1080 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | base/logging_unittest.cc » ('j') | base/logging_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698