2

Having an issue with using GDB to print the values of two dimensional arrays in fortran code.

(gdb) print var(1,2)
no such vector element

After an extensive search I have found many posts dated ~2007 - 2010 about the problem. Most end with someone suggesting a patch. Has this issue ever been resolved in the current release (I'm using 7.4-2012.04)? There are no current posts on the subject, has it been fixed or a suitable work-around available?

one suggestion is to switch to c

(gdb) set language c
(gdb) print neighbours
$47 = 0xbfaeae44
(gdb) print *neighbours
$48 = 0xbfaeae44
(gdb) print 0xbfaeae44
$49 = 3215896132

How can I print the value pointed to and do pointer arithmetic with this?

Thanks

davepc
  • 320
  • 2
  • 10
  • GDB fortran support is a joke. – EMiller Oct 03 '12 at 17:44
  • 1
    Hi, I ran into some similar problems and wrote about it here: http://numericalnoob.blogspot.be/2012/08/fortran-allocatable-arrays-and-pointers.html (also read the comment on it). – steabert Oct 29 '12 at 13:25

2 Answers2

1

one possible solution is to use a gdb obtained from Archer (git) http://sourceware.org/gdb/wiki/ArcherBranchManagement, branch archer-jankratochvil-vla. I have downloaded with EGit(Eclipse), and I have compiled it and installed (./configure, make, sudo make install) in Mandriva 2010/2011 and Ubuntu Precise Pengolin. In order to do that, you must have some packages installed, it depends on yours distro. You have some messages in case of errors that help you to find the missing package. In Ubuntu the new gdb is launched by default, on command line. I have used the obtained gdb in Eclipse (Photran) and NetBeans, it work nice, almost like the commercial IDE from Windows, in the GUI environment.

Wilduck
  • 13,822
  • 10
  • 58
  • 90
Silviu
  • 11
  • 1
1

Yes there have been problems with this in the past. Not sure if this is true in the latest gdb.

Alternatively, you can use dbx (from Solaris Studio) that is freely available and has a nicer GUI. Btw Solaris Studio includes a debugger, analyzer, C/C++/Fortran compilers, Sunperf lib and the whole install is less than a gig.

I always use GNU compilers but Solaris Studio comes handy while working with Fortran programs specially while debugging/tracking bugs/warnings, conformance to standard etc. It is usually better to check your code with multiple compilers anyway. Analyzer is specially helpful when using OpenMP (for detecting races).

stali
  • 321
  • 2
  • 9