Next: GCC warning options for numerical programs, Previous: Examining floating point registers, Up: Debugging Numerical Programs [Index]
It is possible to stop the program whenever a SIGFPE
floating
point exception occurs. This can be useful for finding the cause of an
unexpected infinity or NaN
. The current handler settings can be
shown with the command info signal SIGFPE
.
(gdb) info signal SIGFPE Signal Stop Print Pass to program Description SIGFPE Yes Yes Yes Arithmetic exception
Unless the program uses a signal handler the default setting should be
changed so that SIGFPE is not passed to the program, as this would cause
it to exit. The command handle SIGFPE stop nopass
prevents this.
(gdb) handle SIGFPE stop nopass Signal Stop Print Pass to program Description SIGFPE Yes Yes No Arithmetic exception
Depending on the platform it may be necessary to instruct the kernel to
generate signals for floating point exceptions. For programs using GSL
this can be achieved using the GSL_IEEE_MODE
environment variable
in conjunction with the function gsl_ieee_env_setup
as described
in see IEEE floating-point arithmetic.
(gdb) set env GSL_IEEE_MODE=double-precision