On the x86 architecture, a debug register is a register used by a processor for program debugging. There are six debug registers, named DR0...DR7, with DR4 and DR5 as obsolete synonyms for DR6 and DR7. The debug registers allow programmers to selectively enable various debug conditions associated with a set of four debug addresses. Two of these registers are used to control debug features. These registers are accessed by variants of the MOV instruction. A debug register may be either the source operand or destination operand. The debug registers are privileged resources; the MOV instructions that access them can only be executed at privilege level zero. An attempt to read or write the debug registers when executing at any other privilege level causes a general protection fault.

DR0 to DR3

Each of these registers contains the linear address associated with one of four breakpoint conditions. Each breakpoint condition is further defined by bits in DR7.

The debug address registers are effective whether or not paging is enabled. The addresses in these registers are linear addresses. If paging is enabled, the linear addresses are translated into physical addresses by the processor's paging mechanism. If paging is not enabled, these linear addresses are the same as physical addresses.

Note that when paging is enabled, different tasks may have different linear-to-physical address mappings. When this is the case, an address in a debug address register may be relevant to one task but not to another. For this reason the x86 has both global and local enable bits in DR7. These bits indicate whether a given debug address has a global (all tasks) or local (current task only) relevance.

DR6 - Debug status

The debug status register permits the debugger to determine which debug conditions have occurred. When the processor detects an enabled debug exception, it will set the corresponding bits of this register before entering the debug exception handler.

BitsAbbreviationDescription
0B0Breakpoint #0 Condition Detected
1B1Breakpoint #1 Condition Detected
2B2Breakpoint #2 Condition Detected
3B3Breakpoint #3 Condition Detected
10:4—N/aReserved. Read as all-0s on 386/486 processors, all-1s on later processors.
11BLDCleared to 0 by the processor for Bus Lock Trap exceptions.On processors that don't support Bus Lock Trap exceptions, bit 11 of DR6 is a read-only bit, acting in the same way as bits 10:4.
12BK, SMMS(386/486 only) SMM or ICE mode entered (see also DR7, bit 12). Reserved and read as 0 on all later processors.
13BDDebug Register Access Detected (see also DR7, bit 13).
14BSSingle-Step execution (enabled by EFLAGS.TF)
15BTTask Switch breakpoint. Occurs when a task switch is done with a TSS that has the T (debug trap flag) bit set.
16RTM(Processors with Intel TSX only) Cleared to 0 by the processor for debug exceptions inside RTM transactions, set to 1 for all debug exceptions outside transactions. On processors without TSX, bit 16 of DR6 is a read-only bit, acting in the same way as bits 31:17.
31:17—N/aReserved. Read as all-0s on 386/486/6x86 processors, all-1s on later processors.
63:32—N/a(x86-64 only) Reserved. Read as all-0s. Must be written as all-0s.

DR7 - Debug control

The debug control register is used to selectively enable the four address breakpoint conditions, and to specify the type and size of each of the four breakpoints. There are two levels of enabling: the local (0,2,4,6) and global (1,3,5,7) levels. The local enable bits are automatically reset by the processor at every task switch to avoid unwanted breakpoint conditions in the new task. The global enable bits are not reset by a task switch; therefore, they can be used for conditions that are global to all tasks.

BitsAbbreviationDescription
0L0Local enable for breakpoint #0.
1G0Global enable for breakpoint #0.
2L1Local enable for breakpoint #1.
3G1Global enable for breakpoint #1.
4L2Local enable for breakpoint #2.
5G2Global enable for breakpoint #2.
6L3Local enable for breakpoint #3.
7G3Global enable for breakpoint #3.
8LE(386 only) Local Exact Breakpoint Enable.
9GE(386 only) Global Exact Breakpoint Enable.
10—N/aReserved, read-only, read as 1 and should be written as 1.
11RTM(Processors with Intel TSX only) Enable advanced debugging of RTM transactions (only if DEBUGCTL bit 15 is also set) On other processors: reserved, read-only, read as 0 and should be written as 0.
12IR, SMIE(386/486 processors only) Action on breakpoint match: 0 = INT 1 (#DB exception, default) 1 = Break to ICE/SMM On other processors: Reserved, read-only, read as 0 and should be written as 0.
13GDGeneral Detect Enable. If set, will cause a debug exception on any attempt at accessing the DR0-DR7 registers.
15:14—N/aReserved, should be written as all-0s.
17:16R/W0Breakpoint condition for breakpoint #0.
19:18LEN0Breakpoint length for breakpoint #0.
21:20R/W1Breakpoint condition for breakpoint #1.
23:22LEN1Breakpoint length for breakpoint #1.
25:24R/W2Breakpoint condition for breakpoint #2.
27:26LEN2Breakpoint length for breakpoint #2.
29:28R/W3Breakpoint condition for breakpoint #3.
31:30LEN3Breakpoint length for breakpoint #3.
32DR0_PT_LOGEnable DR0/1/2/3 breakpoint match as a trigger input for PTTT (Processor Trace Trigger Tracing).Read as 0 and must be written as all-0s on processors that don't support PTTT.
33DR1_PT_LOG
34DR2_PT_LOG
35DR3_PT_LOG
63:36—N/a(x86-64 only) Reserved. Read as all-0s. Must be written as all-0s.

DR4 and DR5

Not real registers. On processors that support the CR4.DE bit (Intel Pentium and later), their behaviour is controlled by CR4.DE:

  • CR4.DE=0 : DR4 and DR5 alias to DR6 and DR7, respectively.
  • CR4.DE=1 : accessing DR4/5 results in #UD (invalid opcode) exception.

On processors without CR4.DE, the behaviour is officially undefined - usually, DR4/5 are aliased to DR6/7, but exceptions exist and have been used for CPU detection.

See also

  • Intel 80386 Programmer's Reference

External links