Skip to content

Commit

Permalink
debug-trap: use int3 on x86 instead of int $03
Browse files Browse the repository at this point in the history
See Peter Cordes' comment on Stack Overflow:
https://stackoverflow.com/questions/173618/is-there-a-portable-equivalent-to-debugbreak-debugbreak/49079078#comment112451699_49079078

> For x86 (including x86-64) GAS syntax, it's better to write `int3` to
> make it explicit that you want the special case debug-break
> instruction, one byte `CC` not `CD 03`, for the rare cases where that
> matter (code size, and v8086 mode).
> (felixcloutier.com/x86/intn:into:int3:int1). With NASM they actually
> assemble differently, GAS optimizes both to int3.
  • Loading branch information
nemequ committed Aug 29, 2020
1 parent f596f8b commit ed26cfb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion debug-trap/debug-trap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# elif defined(__DMC__) && defined(_M_IX86)
static inline void psnip_trap(void) { __asm int 3h; }
# elif defined(__i386__) || defined(__x86_64__)
static inline void psnip_trap(void) { __asm__ __volatile__("int $03"); }
static inline void psnip_trap(void) { __asm__ __volatile__("int3"); }
# elif defined(__thumb__)
static inline void psnip_trap(void) { __asm__ __volatile__(".inst 0xde01"); }
# elif defined(__aarch64__)
Expand Down

0 comments on commit ed26cfb

Please sign in to comment.