hi,
I am trying to add some support for the floating point unit to winedbg. I have one question to the experts. The debugger code gets/sets the CPU registers through a {G|S}etThreadContext() from the server, adding the flag CONTEXT_FLOATING_POINT should make sure to include the FP registers. This doesn't work because the server code clears the CONTEXT_FLOATING_POINT flag at some point (see attached patch). My patch is simply preventing this, but it may well be that the FP registers should be available at this point.
So is this the correct fix?
Rein.
Rein Klazes wrote:
hi,
I am trying to add some support for the floating point unit to winedbg. I have one question to the experts. The debugger code gets/sets the CPU registers through a {G|S}etThreadContext() from the server, adding the flag CONTEXT_FLOATING_POINT should make sure to include the FP registers. This doesn't work because the server code clears the CONTEXT_FLOATING_POINT flag at some point (see attached patch). My patch is simply preventing this, but it may well be that the FP registers should be available at this point.
So is this the correct fix?
this won't work in all cases: when (g|s)etting the registers for a thread, two cases exist: 1/ either the thread is currently caught in an exception 2/ or the thread is not
the get/set is done, in case 1/, but just copying the CONTEXT that the exception handler sent to the server in case 2, we use the existing unix API (ptrace or equivalent) to get the CONTEXT
what's not working with your patch is that in the case 1/ only a partial context is copied and it doesn't contain the floating point regs
and most of the operations in the debugger (when displaying the context of thread) are of type 1/, not 2/
one of the fix would be to store the FPU registers for each exception, but that may be time consuming (and restoring as well) (see dlls/ntdll/signal_i386.c) note than on i386, the floating regs in exception are only present for floating point ops
A+
On Mon, 03 Feb 2003 21:45:29 +0100, you wrote:
Rein Klazes wrote:
hi,
I am trying to add some support for the floating point unit to winedbg. I have one question to the experts. The debugger code gets/sets the CPU registers through a {G|S}etThreadContext() from the server, adding the flag CONTEXT_FLOATING_POINT should make sure to include the FP registers. This doesn't work because the server code clears the CONTEXT_FLOATING_POINT flag at some point (see attached patch). My patch is simply preventing this, but it may well be that the FP registers should be available at this point.
So is this the correct fix?
this won't work in all cases: when (g|s)etting the registers for a thread, two cases exist: 1/ either the thread is currently caught in an exception 2/ or the thread is not
the get/set is done, in case 1/, but just copying the CONTEXT that the exception handler sent to the server in case 2, we use the existing unix API (ptrace or equivalent) to get the CONTEXT
Aha, and trying to do this ptrace call in case 1 (like in my patch) does not return the correct CONTEXT?
what's not working with your patch is that in the case 1/ only a partial context is copied and it doesn't contain the floating point regs
and most of the operations in the debugger (when displaying the context of thread) are of type 1/, not 2/
one of the fix would be to store the FPU registers for each exception, but that may be time consuming (and restoring as well) (see dlls/ntdll/signal_i386.c)
OK, I will have a look there.
note than on i386, the floating regs in exception are only present for floating point ops
I hope that doesn't prevent me form single stepping through FP code, while displaying some of the registers.
Thanks for the explanation!
Rein.
Aha, and trying to do this ptrace call in case 1 (like in my patch) does not return the correct CONTEXT?
it will: 1/ return the context (register part) from the exception 2/ recopy the current thread context which means that it will correct only if the thread hasn't used FPU operations between the exception and sending the exception to the server
anyway, what I don't like in you patch is that well get FPU status not linked to the exact exception point
apparently, the REGISTER kludge is needed because Dr (aka REGISTER) have to be read by ptrace in all cases (exception or not), which is not the case for the FPU registers
A+