diff options
author | Abseil Team <absl-team@google.com> | 2022-10-06 18:21:49 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-06 18:22:36 (GMT) |
commit | 67e264834a45c3d543aa2fa11bcc41c4ba90316b (patch) | |
tree | 75d188241e2b5ff758f9eb1f23d1b7aa8712fe36 /googletest | |
parent | 08935483cb22749b3c3774e9bcd5ef35b5a1a7b7 (diff) | |
download | googletest-67e264834a45c3d543aa2fa11bcc41c4ba90316b.zip googletest-67e264834a45c3d543aa2fa11bcc41c4ba90316b.tar.gz googletest-67e264834a45c3d543aa2fa11bcc41c4ba90316b.tar.bz2 |
[fuchsia] Use __builtin_trap to trigger gunit_break_on_failure on non-x86 arch
In developing tests for the fuchsia debugger, it was found that in addition to catching gtest failures (which are implemented as software breakpoints) we also see PageFault exceptions, caused by this nullptr dereference.
PiperOrigin-RevId: 479365782
Change-Id: I84d805d94c2e46b6f3c982ca1ae49c6ac3ed3430
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/src/gtest.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 43e8723..638d53b 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -143,6 +143,14 @@ #include "absl/strings/str_replace.h" #endif // GTEST_HAS_ABSL +// Checks builtin compiler feature |x| while avoiding an extra layer of #ifdefs +// at the callsite. +#if defined(__has_builtin) +#define GTEST_HAS_BUILTIN(x) __has_builtin(x) +#else +#define GTEST_HAS_BUILTIN(x) 0 +#endif // defined(__has_builtin) + namespace testing { using internal::CountIf; @@ -5331,6 +5339,10 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, (defined(__x86_64__) || defined(__i386__))) // with clang/gcc we can achieve the same effect on x86 by invoking int3 asm("int3"); +#elif GTEST_HAS_BUILTIN(__builtin_trap) + __builtin_trap(); +#elif defined(SIGTRAP) + raise(SIGTRAP); #else // Dereference nullptr through a volatile pointer to prevent the compiler // from removing. We use this rather than abort() or __builtin_trap() for |