Debugging Tools for Windows |
User-mode and kernel-mode code use different routines to break into the debugger.
A break routine causes an exception to occur in the current process, so that the calling thread can signal the debugger associated with the calling process.
To break into a debugger from a user-mode program, use the DebugBreak routine.
For complete documentation of this routine, see the Platform SDK.
When a user-mode program calls DebugBreak, the following possible actions will occur:
When a kernel-mode program breaks into the debugger, the entire operating system freezes until the kernel debugger allows execution to resume. If no kernel debugger is present, this is treated as a bug check.
The DbgBreakPoint routine works in kernel-mode code, but is otherwise similar to the DebugBreak user-mode routine.
DbgBreakPointWithStatus also causes a break, but it additionally sends a 32-bit status code to the debugger.
KdBreakPoint and KdBreakPointWithStatus are identical to DbgBreakPoint and DbgBreakPointWithStatus, respectively, when compiled in the checked build environment. When compiled in the free build environment, they have no effect.
For complete documentation of these routines, as well as the build environment, see the Windows Driver Kit.
Two conditional break routines are available for kernel-mode code. These routines test a logical expression. If the expression is false, execution halts and the debugger becomes active.
The ASSERT macro causes the debugger to display the failed expression and its location in the program. The ASSERTMSG macro is similar, but allows an additional message to be sent to the debugger.
ASSERT and ASSERTMSG are only active when compiled in the checked build environment. When compiled in the free build environment, they have no effect.
For complete documentation of these routines, as well as the build environment, see the Windows Driver Kit.