In MSVC, DebugBreak() or __debugbreak cause a debugger to break. On x86 it is equivalent to writing \"_asm int 3\", on x64 it is something different. When compiling with gcc
This seems to be a very good, portable solution to this question: https://github.com/scottt/debugbreak
The header provided in the repository cited (debugbreak.h) encapsulates MSVC's
__debugbreak,
and
__asm__ volatile("int $0x03");
on i386 and x86_64, and on ARM it implements
__asm__ volatile(".inst 0xe7f001f0");
as well as documenting some workarounds for problems noted in the header for single-stepping past the breakpoint in GDB plus a Python script for extending GDB on those platforms where stepi or cont get stuck. The script adds debugbreak-step and debugbreak-continue to GDB.