3#ifndef TETL_CONFIG_DEBUG_TRAP_HPP
4#define TETL_CONFIG_DEBUG_TRAP_HPP
9#if !defined(TETL_NDEBUG) && defined(NDEBUG) && !defined(TETL_DEBUG)
16 #define TETL_DEBUG_TRAP __debugbreak
19 #define TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION 1
20 #define TETL_DEBUG_TRAP_IMPL_BULTIN_TRAP 2
21 #define TETL_DEBUG_TRAP_IMPL_BULTIN_DEBUGTRAP 3
22 #define TETL_DEBUG_TRAP_IMPL_SIGTRAP 4
24 #if defined(__i386__) || defined(__x86_64__)
25 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
27inline auto trap_inst() ->
void { __asm__
volatile(
"int $0x03"); }
28 #elif defined(__thumb__)
29 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
31inline auto trap_inst() ->
void { __asm__
volatile(
".inst 0xde01"); }
32 #elif defined(__arm__) && !defined(__thumb__)
33 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
35inline auto trap_inst() ->
void { __asm__
volatile(
".inst 0xe7f001f0"); }
36 #elif defined(__aarch64__) && defined(__APPLE__)
37 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_BULTIN_DEBUGTRAP
38 #elif defined(__aarch64__)
39 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
41inline auto trap_inst() ->
void { __asm__
volatile(
".inst 0xd4200000"); }
42 #elif defined(__powerpc__)
43 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
45inline auto trap_inst() ->
void { __asm__
volatile(
".4byte 0x7d821008"); }
46 #elif defined(__riscv)
47 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
49inline auto trap_inst() ->
void { __asm__
volatile(
".4byte 0x00100073"); }
50 #elif defined(__AVR__)
51 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
54 #elif defined(__STDC_HOSTED__)
55 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_SIGTRAP
58 #define TETL_DEBUG_TRAP_IMPL TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
63 #if !defined(TETL_DEBUG_TRAP_IMPL)
65 #elif TETL_DEBUG_TRAP_IMPL == TETL_DEBUG_TRAP_IMPL_TRAP_INSTRUCTION
67 #elif TETL_DEBUG_TRAP_IMPL == TETL_DEBUG_TRAP_IMPL_BULTIN_DEBUGTRAP
69 #elif TETL_DEBUG_TRAP_IMPL == TETL_DEBUG_TRAP_IMPL_BULTIN_TRAP
71 #elif TETL_DEBUG_TRAP_IMPL == TETL_DEBUG_TRAP_IMPL_SIGTRAP
76 #error "invalid TETL_DEBUG_TRAP_IMPL value"
auto trap_inst() -> void
Definition debug_trap.hpp:60
auto TETL_DEBUG_TRAP() -> void
Definition debug_trap.hpp:66