Problems with gdb and FORTRAN programs

Mumit Khan khan@xraylith.wisc.EDU
Mon May 31 21:10:00 GMT 1999

"Richard Stanton" <stanton@Haas.Berkeley.EDU> writes:
> I'm writing/debugging some FORTRAN code using egcs 1.1.2 and gdb 4.17.1.
> There seem to be some problems viewing variables with gdb in fortran mode.
> For example,
> Breakpoint 1, getdat_ (data=0xf0be20, m=0x30720d0, n=0x30720d4) at
> snpdata.f:40
> (gdb) print n
> $2 = (PTR TO -> ( integer )) 0x30720d4
> (gdb) set lang c
> Warning: the current language does not match this frame.
> (gdb) print n[0]
> $3 = 491
> (gdb) set lang fortran
> (gdb) print n(1)
> Program received signal SIGSEGV, Segmentation fault.
> 0x30720d9 in ?? ()
> The program being debugged stopped while in a function called from GDB.
> When the function (at 0x30720d4) is done executing, GDB will silently
> stop (instead of continuing to evaluate the expression containing
> the function call).
> (gdb)
> How can I view the contents of the variable n in fortran mode?

This is certainly a bug, and I have no clue as to how to attack this
problem. There are two separate problems when debugging g77 code:

  - gdb still doesn't grok fortran mode well. It likes Sun's f77 if
    I remember correctly (or did many years ago when I had to debug
    my old code).

  - g77 doesn't write out debug info in very usable form.

Your particular problem however has an easy, albeit non-fortran'y,
  (gdb) print *n

That should work, at least in theory. btw, gdb-4.18 does not solve this
problem, and this problem is not unique to Cygwin port by any means.

We just have to wait until this bug hits one of those rare folks who know 
more about g77's debug info output and gdb's handling of it. Anybody know
how to bribe Craig Burley or Toon Moene?


Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list