Use __builtin_debugtrap or SIGTRAP instead of __builtin_trap for --gtest_break_on_failure

This commit is contained in:
sameersharmadev 2025-07-10 10:03:33 +05:30
parent 3983f67e32
commit 50ea853604

View File

@ -5477,10 +5477,13 @@ 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 defined(__clang__) && __has_builtin(__builtin_debugtrap)
__builtin_debugtrap();
#elif defined(__GNUC__)
raise(SIGTRAP);
#elif GTEST_HAS_BUILTIN(__builtin_trap)
__builtin_trap();
#elif defined(SIGTRAP)
raise(SIGTRAP);
__builtin_trap();
#else
// Dereference nullptr through a volatile pointer to prevent the compiler
// from removing. We use this rather than abort() or __builtin_trap() for