File indexing completed on 2025-01-18 09:54:05
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_DEBUGGER_HPP_INCLUDED
0009 #define CATCH_DEBUGGER_HPP_INCLUDED
0010
0011 #include <catch2/internal/catch_platform.hpp>
0012
0013 namespace Catch {
0014 bool isDebuggerActive();
0015 }
0016
0017 #ifdef CATCH_PLATFORM_MAC
0018
0019 #if defined(__i386__) || defined(__x86_64__)
0020 #define CATCH_TRAP() __asm__("int $3\n" : : )
0021 #elif defined(__aarch64__)
0022 #define CATCH_TRAP() __asm__(".inst 0xd43e0000")
0023 #elif defined(__POWERPC__)
0024 #define CATCH_TRAP() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
0025 : : : "memory","r0","r3","r4" )
0026 #endif
0027
0028 #elif defined(CATCH_PLATFORM_IPHONE)
0029
0030
0031 #if defined(__i386__) || defined(__x86_64__)
0032 #define CATCH_TRAP() __asm__("int $3")
0033 #elif defined(__aarch64__)
0034 #define CATCH_TRAP() __asm__(".inst 0xd4200000")
0035 #elif defined(__arm__) && !defined(__thumb__)
0036 #define CATCH_TRAP() __asm__(".inst 0xe7f001f0")
0037 #elif defined(__arm__) && defined(__thumb__)
0038 #define CATCH_TRAP() __asm__(".inst 0xde01")
0039 #endif
0040
0041 #elif defined(CATCH_PLATFORM_LINUX)
0042
0043
0044
0045 #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
0046 #define CATCH_TRAP() asm volatile ("int $3")
0047 #else
0048 #include <signal.h>
0049
0050 #define CATCH_TRAP() raise(SIGTRAP)
0051 #endif
0052 #elif defined(_MSC_VER)
0053 #define CATCH_TRAP() __debugbreak()
0054 #elif defined(__MINGW32__)
0055 extern "C" __declspec(dllimport) void __stdcall DebugBreak();
0056 #define CATCH_TRAP() DebugBreak()
0057 #endif
0058
0059 #ifndef CATCH_BREAK_INTO_DEBUGGER
0060 #ifdef CATCH_TRAP
0061 #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }()
0062 #else
0063 #define CATCH_BREAK_INTO_DEBUGGER() []{}()
0064 #endif
0065 #endif
0066
0067 #endif