This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Is it possible to preserve flags for fetestexcept() inside signal handler
- From: Jed Brown <jed at 59A2 dot org>
- To: libc-help at sourceware dot org
- Date: Thu, 31 May 2012 18:28:56 -0500
- Subject: Is it possible to preserve flags for fetestexcept() inside signal handler
As a debugging aid, I use feenableexcept() and set a signal handler
that provides a trace. Unfortunately, calling fetestexcept() inside
the signal handler shows all flags unset so there is no way for the
user to know what kind of floating point exception occurred. The best
I've managed is to give the user directions for running the program in
gdb, how to call fetestexcept() themselves once the error has trapped,
and how to interpret the results [1].
Is this the best I can do or is there some way to make fetestexcept()
return the correct flags when called from the signal handler? Does the
kernel reset them unconditionally?
[1] This especially sucks because the numeric codes are a lot to
remember and the macros aren't visible to GDB; I should write a
utility function to be called from the debugger.