Go to main content
Oracle® Developer Studio 12.5: Debugging a Program with dbx

Exit Print View

Updated: June 2016

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
                 subroutine joe(r,s)
                 r = 12.
                 s = 0.
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