g77.info: Debugging Options

Go forward to Optimize Options
Go backward to Warning Options
Go up to Invoking G77
Go to the top op g77

Options for Debugging Your Program or GNU Fortran

   GNU Fortran has various special options that are used for debugging
either your program or `g77'
`-g'
     Produce debugging information in the operating system's native
     format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
     debugging information.
     A sample debugging session looks like this (note the use of the
     breakpoint):
          $ cat gdb.f
                PROGRAM PROG
                DIMENSION A(10)
                DATA A /1.,2.,3.,4.,5.,6.,7.,8.,9.,10./
                A(5) = 4.
                PRINT*,A
                END
          $ g77 -g -O gdb.f
          $ gdb a.out
          ...
          (gdb) break MAIN__
          Breakpoint 1 at 0x8048e96: file gdb.f, line 4.
          (gdb) run
          Starting program: /home/toon/g77-bugs/./a.out
          Breakpoint 1, MAIN__ () at gdb.f:4
          4             A(5) = 4.
          Current language:  auto; currently fortran
          (gdb) print a(5)
          $1 = 5
          (gdb) step
          5             PRINT*,A
          (gdb) print a(5)
          $2 = 4
          ...
     One could also add the setting of the breakpoint and the first run
     command to the file `.gdbinit' in the current directory, to
     simplify the debugging session.
   *Note Options for Debugging Your Program or GCC: (gcc)Debugging
Options, for more information on debugging options.