Index: base/logging_unittest.cc |
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc |
index f41cce2f43b390fa9603a14f3f689fe87d0dcb33..9fe718c8799a4e74f170091ca148033373c79161 100644 |
--- a/base/logging_unittest.cc |
+++ b/base/logging_unittest.cc |
@@ -9,6 +9,11 @@ |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#if defined(OS_WIN) |
+#include <excpt.h> |
+#include <windows.h> |
+#endif // OS_WIN |
+ |
namespace logging { |
namespace { |
@@ -190,6 +195,59 @@ TEST_F(LoggingTest, CheckStreamsAreLazy) { |
#endif |
+#if defined(OFFICIAL_BUILD) && defined(OS_WIN) |
+NOINLINE void CheckContainingFunc(int death_location) { |
+ CHECK(death_location != 1); |
+ CHECK(death_location != 2); |
+ CHECK(death_location != 3); |
+} |
+ |
+int GetCheckExceptionData(EXCEPTION_POINTERS* p, DWORD* code, void** addr) { |
+ *code = p->ExceptionRecord->ExceptionCode; |
+ *addr = p->ExceptionRecord->ExceptionAddress; |
+ return EXCEPTION_EXECUTE_HANDLER; |
+} |
+ |
+TEST_F(LoggingTest, CheckCausesDistinctBreakpoints) { |
+ DWORD code1 = 0; |
+ DWORD code2 = 0; |
+ DWORD code3 = 0; |
+ void* addr1 = nullptr; |
+ void* addr2 = nullptr; |
+ void* addr3 = nullptr; |
+ |
+ // Record the exception code and addresses. |
+ __try { |
+ CheckContainingFunc(1); |
+ } __except ( |
+ GetCheckExceptionData(GetExceptionInformation(), &code1, &addr1)) { |
+ } |
+ |
+ __try { |
+ CheckContainingFunc(2); |
+ } __except ( |
+ GetCheckExceptionData(GetExceptionInformation(), &code2, &addr2)) { |
+ } |
+ |
+ __try { |
+ CheckContainingFunc(3); |
+ } __except ( |
+ GetCheckExceptionData(GetExceptionInformation(), &code3, &addr3)) { |
+ } |
+ |
+ // Ensure that the exception codes are correct (in particular, breakpoints, |
+ // not access violations). |
+ EXPECT_EQ(STATUS_BREAKPOINT, code1); |
+ EXPECT_EQ(STATUS_BREAKPOINT, code2); |
+ EXPECT_EQ(STATUS_BREAKPOINT, code3); |
+ |
+ // Ensure that none of the CHECKs are colocated. |
+ EXPECT_NE(addr1, addr2); |
+ EXPECT_NE(addr1, addr3); |
+ EXPECT_NE(addr2, addr3); |
+} |
+#endif // OFFICIAL_BUILD && OS_WIN |
+ |
TEST_F(LoggingTest, DebugLoggingReleaseBehavior) { |
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
int debug_only_variable = 1; |