31 #define debug_break __debugbreak
39 #define DEBUG_BREAK_USE_TRAP_INSTRUCTION 1
40 #define DEBUG_BREAK_USE_BULTIN_TRAP 2
41 #define DEBUG_BREAK_USE_SIGTRAP 3
43 #if defined(__i386__) || defined(__x86_64__)
44 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
45 __inline__
static void trap_instruction(
void)
47 __asm__
volatile(
"int $0x03");
49 #elif defined(__thumb__)
50 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
53 __inline__
static void trap_instruction(
void)
59 __asm__
volatile(
".inst 0xde01");
62 __asm__
volatile(
".inst.w 0xf7f0a000");
82 #elif defined(__arm__) && !defined(__thumb__)
83 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
85 __inline__
static void trap_instruction(
void)
89 __asm__
volatile(
".inst 0xe7f001f0");
93 #elif defined(__aarch64__) && defined(__APPLE__)
94 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
95 #elif defined(__aarch64__)
96 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
98 __inline__
static void trap_instruction(
void)
102 __asm__
volatile(
".inst 0xd4200000");
104 #elif defined(__powerpc__)
106 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
108 __inline__
static void trap_instruction(
void)
112 __asm__
volatile(
".4byte 0x7d821008");
121 #elif defined(__riscv)
124 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
126 __inline__
static void trap_instruction(
void)
130 __asm__
volatile(
".4byte 0x00100073");
133 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP
137 #ifndef DEBUG_BREAK_IMPL
138 #error "debugbreak.h is not supported on this target"
139 #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION
141 __inline__
static void debug_break(
void)
145 #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
147 __inline__
static void debug_break(
void)
149 __builtin_debugtrap();
151 #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP
153 __inline__
static void debug_break(
void)
157 #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP
160 __inline__
static void debug_break(
void)
165 #error "invalid DEBUG_BREAK_IMPL value"
__attribute__((always_inline)) __inline__ static void debug_break(void)