5.3 Entering 80386 Debugger

To enter 80386 Debugger at any time interrupts are not disabled, press the CTRL+C key combination on the debugging terminal. A nonmaskable interrupt (NMI) can be used to enter the debugger even when interrupts are disabled.

An int 3 instruction or a call to the Windows DebugBreak function passes control to the 80386 Debugger.

When a Windows application running in standard or 386 enhanced mode attempts to read or write memory with a bad selector, beyond a selector limit, or with a selector set to 0, a general protection (GP) fault occurs.

In such cases, Windows displays a dialog box notifying the user of a problem. When 80386 Debugger is loaded, the dialog box has a Cancel button. If the user chooses the Cancel button, Windows passes control to the debugger at the instruction that caused the fault with a display of the following form:

GENERAL PROTECTION VIOLATION
AX=00000000 BX=00002136 CX=06040079 DX=00001EF5 SI=000000C3 DI=00002283
IP=00000028 SP=80012126 BP=0000212C CR2=80501FFC CR3=0293 IOPL=0 F=-- --
CS=0915 SS=091D DS=091D ES=0000 FS=0000 GS=0000 -- NV UP EI PLZR NA PE NC
00AD:00000FA0  MOV BX, WORD PTR ES:[BX]
ES:65DF=INV:0003#

For more information about commands shown in the remaining examples in this section, see Section 5.4.2, “Command Parameters,” and Section 5.6, “Reference of 80386 Debugger Commands.”

You can determine the cause of the GP fault by looking at the value and the limit of the selector. To dump the local descriptor table (LDT) entry, you can use a command of the following form:

dl selector

The ability to continue execution depends on the cause of the fault. If the fault was caused by reading or writing beyond the selector limit, it may be possible to skip the instruction by incrementing the IP register.

To determine how many bytes the instruction contains, you may need to display the actual code bytes when disassembling the instruction. To do this, use the following commands:

y codebytes
r

If the fault is caused by a critical logic error, such as trying to use a selector for a temporary variable, there probably is no way to continue execution of the application. You may need to restart the computer.