If you want to see where your code causes ieee floating point errors (I
have only tested this ON THE SUN, Hp and aix should work in the same way
see the man page...) u can use the following. The method I'll demo is
done in fortran but will work with c/c++ just as well. If you will
remember ieee's default floating point model has all the exception flags
turned off. It is up the application to enable the exceptions they want
to be told about.
Finding errors...
The procedure is simple. It consists of a setup call to a special os
supplied error handler and your handler code.
For example to instrument recsis you would:
1. add a call in recsis.F - the main program
...lots of code deleted...
c
c_end_var
c
c executable code for routine RECSIS:
c----6----------------------------------------------------------------72
c
james = ieee_handler ("set", "all", common_handler)
if (james .ne.0) print *, "fortran is cool!"
call recsis_main
c
STOP
end
Notice the variable james... and the call to ieee_handler above!
a man on ieee_handler yields:
it takes 3 parameters:, the command (in this case set), the ieee flags
you are interested in (in this case all) and the routine to call where
the os detects a floating point exception.
2. link your handler code into the system...
here is my common_handler ...
integer function common_handler(signal, sip, uap)
integer sig
structure /fault/
integer address
end structure
structure /siginfo/
integer si_signo
integer si_code
integer si_errno
record /fault/ fault
end structure
record /siginfo/ sip
write (*,10) sip.si_code, sip.fault.address
10 format("ieee exception ", i4, " occured at address ", z8)
return
With this I can see at what instruction a problem occured and from there
I can use a debugger (stopi at 0x1xxxxx) to see what line of code (if
you have debug symbols in that piece of code).
3. run the code in the debugger...
for example here is some recsis output...
RESLUN I: Reserving logical unit number: 24 for routine RENNNN
REOPEN I: File: /apps/clas/u1/clsrc/recsis/runtime/recseq.ini opened
successfully
RESLUN I: Freeing unit: 24 reserved by RENNNN closed by RENNNN
RS>USER_TCL_INI: This is a DUMMY routine, this message written once
ieee exception 6 occured at address EF5A8564
ieee exception 6 occured at address EF5A8564
ieee exception 6 occured at address EF5A8564
EC1_TCL_INII: EC1_INIT_TCL initialization
ieee exception 6 occured at address 1826CC
ieee exception 6 occured at address 1825CC
ieee exception 6 occured at address 18260C
TRKTCL_INITI: DC TCL variables are initialized.
20
HSTTCL_INITI: Operating system determined to be: SunOS
HSTTCL_INITI: PAW shared memory enable with global section:HB44
HSTTCL_INITI: HISTOGRAM FILE NAME =re4644.rzn
ieee exception 6 occured at address 268460
HBOOK_INIT I: initializing shared memory =HB44
ieee exception 6 occured at address 268460
open: Permission denied
GLOBAL MEMORY ERROR = -13
HBOOK_INIT I: Opening histogram file name =re4644.rzn
RETCL_INIT I: Welcome to RECSIS 2.0!
now if you ask the debuger real nice...
(debugger) stopi at 0x1826cc
(3) stopi at &trktcl_init+0x1a2c
(debugger)
or
(debugger) stopi at 0x268460
(4) stopi at &atanf+0x2b0
(debugger)
notice what it will tell you.
Granted this is a real shot gun approach infact you may want to not use
all flags at once.
I hope this helps somebody...