> Hello,
>
> I use the gfortran compiler and gdb for debugging. I want to check
> arrays in subroutins like in the following example:
>
> $ cat array.f90
> program Test
> Â call sub(5)
> contains
>
> subroutine sub(n)
> Â integer, intent(in) Â :: n
> Â integer, dimension(n) :: A
>  integer        :: i
>
> Â do i = 1, n
> Â Â A(i) = i
> Â end do
> Â print *, A
>
> end subroutine
> end program
>
> $ gfortran -v
> Target: i486-linux-gnu
> Configuration: ../src/configure -v --enable-languages=c,c+
> +,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-
> system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-
> threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2
> --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --
> enable-objc-gc --enable-mpfr --enable-targets=all --enable-
> checking=release --build=i486-linux-gnu --host=i486-linux-gnu --
> target=i486-linux-gnu
> Thread-model: posix
> gcc-Version
4.2.3 (Ubuntu
4.2.3-2ubuntu7)
> $ gdb -v
> GNU gdb 6.8-debian ...
> This GDB was configured as "i486-linux-gnu".
>
> $ gfortran -g array.f90
> $ gdb -q ./a.out
> (gdb) b array.f90:13
> Breakpoint 1 at 0x80487ac: file array.f90, line 13.
> (gdb) r
> Starting program: /home/beppo/a.out
>
> Breakpoint 1, sub (n=@0x8048980) at array.f90:13
> 13 Â Â Â Â print *, A
> Current language: Â auto; currently fortran
> (gdb) print A
> $1 = (PTR TO -> ( int4 (0:-1))) 0x8050398
> (gdb) print *A
> $2 = ()
>
> But, as you can see in the last line, gdb can not dereference the
> array pointer A. Perhaps it is a problem with the debug information of
> gfortran? Can anybody help me?
>
> Regards,
> Daniel.
The problem is at both ends: gfortran 4.2 doesn't output all debug
information, but even if it would, then gdb would not recognize it.
The generation of DWARF3 debugging information has improved a lot
especially for gfortran 4.4, but gdb does not yet support much of it.
There are some pending gdb patches for this (see the one currently
linked to from the gfortran wiki:
http://gcc.gnu.org/wiki/GFortranPatchTracker).
You would have to ask on the gdb mailing list what the status is of
these patches.
Hope this helps,
Gr.
Steven