30inline static void debug_break(
void)
40#define DEBUG_BREAK_USE_TRAP_INSTRUCTION 1
41#define DEBUG_BREAK_USE_BULTIN_TRAP 2
42#define DEBUG_BREAK_USE_SIGTRAP 3
44#if defined(__i386__) || defined(__x86_64__)
45#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
46__inline__
static void trap_instruction(
void)
48 __asm__
volatile(
"int $0x03");
50#elif defined(__thumb__)
51#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
53__attribute__((always_inline)) __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
84__attribute__((always_inline)) __inline__
static void trap_instruction(
void)
88 __asm__
volatile(
".inst 0xe7f001f0");
92#elif defined(__aarch64__) && defined(__APPLE__)
93#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
94#elif defined(__aarch64__)
95#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
96__attribute__((always_inline)) __inline__
static void trap_instruction(
void)
100 __asm__
volatile(
".inst 0xd4200000");
102#elif defined(__powerpc__)
104#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
105__attribute__((always_inline)) __inline__
static void trap_instruction(
void)
109 __asm__
volatile(
".4byte 0x7d821008");
118#elif defined(__riscv)
121#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
122__attribute__((always_inline)) __inline__
static void trap_instruction(
void)
126 __asm__
volatile(
".4byte 0x00100073");
129#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP
133#ifndef DEBUG_BREAK_IMPL
134#error "debugbreak.h is not supported on this target"
135#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION
136__attribute__((always_inline)) __inline__
static void debug_break(
void)
140#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
141__attribute__((always_inline)) __inline__
static void debug_break(
void)
143 __builtin_debugtrap();
145#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP
146__attribute__((always_inline)) __inline__
static void debug_break(
void)
150#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP
152__attribute__((always_inline)) __inline__
static void debug_break(
void)
157#error "invalid DEBUG_BREAK_IMPL value"