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

Unified Diff: base/logging.h

Issue 2525723004: Move IMMEDIATE_CRASH and OOM_CRASH from wtf to base. (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/Assertions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.h
diff --git a/base/logging.h b/base/logging.h
index 714545c02bb06ac7f1b31e8a007b671e6dc11d6d..411fc4fb187563fae98e61e37014b05be667efbb 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -445,6 +445,29 @@ class CheckOpResult {
std::string* message_;
};
+// Crashes in the fastest, simplest possible way with no attempt at logging.
+#ifndef IMMEDIATE_CRASH
+#if defined(COMPILER_GCC) || defined(__clang__)
+#define IMMEDIATE_CRASH() __builtin_trap()
+#else
+#define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
+#endif
+#endif
+
+// Specialization of IMMEDIATE_CRASH which will raise a custom exception on
+// Windows to signal this is OOM and not a normal assert.
+#ifndef OOM_CRASH
+#if defined(OS_WIN)
+#define OOM_CRASH() \
+ do { \
+ ::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \
+ IMMEDIATE_CRASH(); \
+ } while (0)
+#else
+#define OOM_CRASH() IMMEDIATE_CRASH()
+#endif
+#endif
+
// CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by NDEBUG, so the check will be executed regardless of
// compilation mode.
@@ -456,12 +479,7 @@ class CheckOpResult {
// Make all CHECK functions discard their log strings to reduce code
// bloat, and improve performance, for official release builds.
-
-#if defined(COMPILER_GCC) || __clang__
-#define LOGGING_CRASH() __builtin_trap()
-#else
-#define LOGGING_CRASH() ((void)(*(volatile char*)0 = 0))
-#endif
+#define LOGGING_CRASH() IMMEDIATE_CRASH()
danakj 2016/11/28 20:55:06 Just remove this and use IMMEDIATE_CRASH below?
palmer 2016/11/28 22:21:33 Done.
// This is not calling BreakDebugger since this is called frequently, and
// calling an out-of-line function instead of a noreturn inline macro prevents
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/Assertions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698