Today a colleague came by to ask about how to get “int 3” functionality on the 64bit platforms. What is “int 3”? It’s the assembly instruction that is used to create a breakpoint. At least that’s the instruction for the x86 processor, and as you can imagine it is very platform specific.
On the 64bit platforms there is no inline assembly, so there goes your “__asm int 3”. What to do now? Well there’s a lesser known construct which is actually much better to use in that it works across all platforms (x64, Itanium, and x86), which is __debugbreak(). This is a Visual C++ compiler intrinsic (defined in Visual C++ 2005 under vc\include\intrin.h, with tons of other cool intrinsics) that will effectively act “int 3” across all platforms.
DebugBreak, the Win32 function call is still around, but in general using __debugbreak() is my preference, if for no other reason than it’s not a function call (it’s a compiler intrinsic), and you don’t need debug symbols to get a readable call stack.
If you’re writing C++ you probably don’t want to write non-portable assembly, and this is just one less place where you would have to.