www.delorie.com/gnu/docs/gcc/gcc_9.html   search  
 
Buy the book!


Using the GNU Compiler Collection (GCC)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6 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.

See section `Options for Debugging Your Program or GCC' in Using the GNU Compiler Collection (GCC), for more information on debugging options.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)