Interrupt 3-breakpoint exception (#bp) – Intel IA-32 User Manual

Page 206

Advertising
background image

5-30 Vol. 3A

INTERRUPT AND EXCEPTION HANDLING

Interrupt 3—Breakpoint Exception (#BP)

Exception Class

Trap.

Description

Indicates that a breakpoint instruction (INT 3) was executed, causing a breakpoint trap to be
generated. Typically, a debugger sets a breakpoint by replacing the first opcode byte of an
instruction with the opcode for the INT 3 instruction. (The INT 3 instruction is one byte long,
which makes it easy to replace an opcode in a code segment in RAM with the breakpoint
opcode.) The operating system or a debugging tool can use a data segment mapped to the same
physical address space as the code segment to place an INT 3 instruction in places where it is
desired to call the debugger.

With the P6 family, Pentium, Intel486, and Intel386 processors, it is more convenient to set
breakpoints with the debug registers. (See Section 18.3.2, “Breakpoint Exception (#BP)—Inter-
rupt Vector 3,” for information about the breakpoint exception.) If more breakpoints are needed
beyond what the debug registers allow, the INT 3 instruction can be used.

The breakpoint (#BP) exception can also be generated by executing the INT n instruction with
an operand of 3. The action of this instruction (INT 3) is slightly different than that of the INT 3
instruction (see “INTn/INTO/INT3—Call to Interrupt Procedure” in Chapter 3, “Instruction Set
Reference, A-M,” in the IA-32 Intel® Architecture Software Developer’s Manual, Volume 2A).

Exception Error Code

None.

Saved Instruction Pointer

Saved contents of CS and EIP registers point to the instruction following the INT 3 instruction.

Program State Change

Even though the EIP points to the instruction following the breakpoint instruction, the state of
the program is essentially unchanged because the INT 3 instruction does not affect any register
or memory locations. The debugger can thus resume the suspended program by replacing the
INT 3 instruction that caused the breakpoint with the original opcode and decrementing the
saved contents of the EIP register. Upon returning from the debugger, program execution
resumes with the replaced instruction.

Advertising