Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Locating Exceptions

A program can throw an exception for many possible reasons. One approach to locating the problem is to find the line number in the source program where the exception occurred, and then examine that location.

Compiling with -ftrap=common forces trapping on all common exceptions.

To find where an exception occurred:

demo% cat wh.f
                 call joe(r, s)
                 print *, r/s
                 end
                 subroutine joe(r,s)
                 r = 12.
                 s = 0.
                 return
                 end
demo% f95 -g -o wh -ftrap=common wh.f
demo% dbx wh
Reading symbolic information for wh
(dbx) catch FPE
(dbx) run
Running: wh
(process id 17970)
signal FPE (floating point divide by zero) in MAIN at line 2 in file “wh.f”
   2                     print *, r/s
(dbx)