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

Unified Diff: base/logging.h

Issue 2701253005: Make LoggingTest.CheckCausesDistinctBreakpoints work on clang win (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | 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 6f30bcbe4f736f989bad178ac3d96ed70bf08943..13661a764436c132813c0dc46032714804d5262b 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -500,7 +500,23 @@ class CheckOpResult {
#if defined(COMPILER_GCC)
#define IMMEDIATE_CRASH() __builtin_trap()
#elif defined(COMPILER_MSVC)
+
+// Clang is cleverer about coalescing int3s, so we need to add a unique-ish
+// instruction following the __debugbreak() to have it emit distinct locations
+// for CHECKs rather than collapsing them all together. It would be nice to use
+// a short intrinsic to do this (and perhaps have only one implementation for
+// both clang and MSVC), however clang-cl currently does not support intrinsics
+// here. Adding the nullptr store to the MSVC path adds unnecessary bloat.
+// TODO(scottmg): Reinvestigate a short sequence that will work on both
+// compilers once clang supports more intrinsics. See https://crbug.com/693713.
+#if defined(__clang__)
+#define IMMEDIATE_CRASH() \
+ (__debugbreak(), \
+ (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
+#else
#define IMMEDIATE_CRASH() __debugbreak()
+#endif // __clang__
+
#else
#error Port
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698