Breaking into the Debugger

To execute debugging commands, you need to break into the debugger and have it display its command prompt. You can automatically break into the debugger as Windows starts by specifying /B option on the WDEB386 command line or in a y command with the DebugCmd setting in the SYSTEM.INI file. The debugger stops execution just after loading VxDs and just prior to initialization. Breaking in at Windows start time is useful if you want to setup breakpoints or use the ".VMM S" command to turn on verbose device tracing (which displays the name of each VxD before it is called, and OK when the VxD returns)

To break into the debugger at any time interrupts are not disabled, press the CTRL+C key combination on the debugging terminal. Alternately, press the CTRL+ALT+SYSRQ key combination on the computer running the debugger. This stops execution at the next convenient location in ring 0 or ring 3 code.

To break into the debugger when interrupts are disabled, you use hardware to generate a nonmaskable interrupt (NMI). This usually means having an external "STOP" button connected to a debugging card installed in computer running the debugger. Some machines may have the capability of connecting a front panel button to the NMI line on the machine bus. In any case, using NMI has the advantage of being able to break into a machine that has hung with interrupts disabled. (You can disable the breaking on nonmaskable interrupts by using the v2 command.)

You can have your application, DLL, or VxD break into the debugger by adding an int 1 or int 3 instruction or a call to the DebugBreak function to your code. The int 1 instruction produces an "Unexpected trace interrupt" message and stops on the instruction after the int 1. This message does not indicate an error condition and can be ignored. An int 3 will break directly on the int instruction and not produce the message. The int 3 is used in system components to stop execution on an error.

Once an int instruction is hit, you can remove it by using the z (Zap) command. This command replaces the int instruction with a nop instruction. For programmers developing virtual device drivers (VxDs), the Debug_Out macro is available to send an ASCII string to the debug terminal and execute an int 1, which will break to the debugger.

Once you have broken into the debugger, you can set additional breakpoints by using the bp or br command. For example, the following command sets a breakpoint at beginning of the function _MyEntryPoint:

bp _MyEntryPoint
 

The system also breaks into the debugger if an application or DLL causes a general protection fault (GPF) by attempting to read or write memory with a bad selector, beyond a selector limit, or with a selector set to 0. The debugger receives control immediately if it traps interrupt vector 0Dh (the default setting). If you disable this trap (by using the vs command), Windows first displays a dialog box notifying the user of a problem. The user can click the Debug button to pass control to the debugger at the instruction that caused the fault.