Why do Intel's processors provide four debug registers rather than only one?



Why do Intel's processors provide four debug registers rather than only
one?

As we know, there are four debug registers (DR0 through DR3) inside
every Intel's processor except for the very early ones. What makes me
confused is as follows:

To my thinking, one debug regiter is enough to set a breakpoint for a
runnning program. If we need to set more breakpoints for this program,
we can do this job in the service routine of the debug interrupt. For
example, assuming we want to set two breakpoints at address 5 and 7. To
this end, we can first set DR0 to addess 5, when the program attempts
to executes the instruction at address 5, a debug interrupt will be
triggered and the ISR we provided in advance will be called. In the
ISR, we can set D0 to address 7 and return. Thus, the program will be
interrupted again when it attempts to execute the instruction at
address 7.

Following the steps I describe above seems a good solution to debugging
all kinds of programs. Why does the processor provide four ones? I
cannot think out how much we can benefit from providing more than one
debug register.

Any explanation will be appreciated. Thanks in advance.

.



Relevant Pages