Debugging a Program With dbx

Using dbx to Locate Floating-Point Exceptions

You need to do two things. First, to stop the process whenever an FP exception occurs, type:


(dbx) catch FPE

Next, add the following to your Fortran application:


integer ieeer, ieee_handler, myhandler
ieeer = ieee_handler('set', 'all', myhandler)
...
        
integer function myhandler(sig, code, context)
integer sig, code(5)
call abort()
end

This is necessary because the ieee software typically sets all errors to be silent (not raising signals). This causes all ieee exceptions to generate a SIGFPE as appropriate, which is probably too much.

You can further tailor which exceptions you see by adjusting the parameters of ieee_handler() or by using an alternative to the dbx catch command:


stop sig FPE

which acts just like catch FPE, or


stop sig FPE subcode

For finer control, subcode can be one of the following:

FPE_INTDIV 

 1 integer divide by zero

FPE_INTOVF 

integer overflow 

FPE_FLTDIV 

floating point divide by zero 

FPE_FLTOVF 

floating point overflow 

FPE_FLTUND 

floating point underflow 

FPE_FLTRES 

floating point inexact result 

FPE_FLTINV 

invalid floating point operation 

FPE_FLTSUB 

subscript out of range 

Note that stop and catch are independent and that if you use stop FPE you should also ignore FPE.