Page 1 of 1
Handling debug exception
Posted: Tue Jan 26, 2021 8:14 am
by Robert
Hi!
How could I handle Exc1 (fired when EIP equals to DRn and debug feature is enabled in DR7)?
I mean the cs:eip in the stack is the one pointed by DRn. So if I'd like to continue the execution, I should disable DRn. But I don't want to. Any ideas?
Thanks,
Re: Handling debug exception
Posted: Tue Jan 26, 2021 8:57 am
by quirck
Take a look at this flag in EFLAGS.
RF Resume (bit 16) — Controls the processor’s response to instruction-breakpoint conditions. When set, this flag temporarily disables debug exceptions (#DB) from being generated for instruction breakpoints (although other exception conditions can cause an exception to be generated). When clear, instruction breakpoints will generate debug exceptions.
The primary function of the RF flag is to allow the restarting of an instruction following a debug exception that was caused by an instruction breakpoint condition. Here, debug software must set this flag in the EFLAGS image on the stack just prior to returning to the interrupted program with IRETD (to prevent the instruction breakpoint from causing another debug exception). The processor then automatically clears this flag after the instruction returned to has been successfully executed, enabling instruction breakpoint faults again.
See also: Section 17.3.1.1, “Instruction-Breakpoint Exception Condition.”
Re: Handling debug exception
Posted: Wed Jan 27, 2021 9:19 am
by Robert
quirck wrote:Take a look at this flag in EFLAGS.
RF Resume (bit 16) — Controls the ...
See also: Section 17.3.1.1
A couple of ywars ago I've read about this, but totally forgot it. Thanks for the answer, it was a huge help.