I have three machine, two run Linux and one run OS X Yosemite with different version of gfortran
and gdb
. gdb
on my old box work well with allocated arrays, however, newer version of gdb
(after 7.2) and gfortran
(after 4.7) do not seem to be able to examine the allocatable variables.
My question is: is this an expected behavior or is there a patch to keep gfortran
, gdb
work like the older version?
This is a small version of code I tested:
integer :: x(2,3)
integer, allocatable :: y(:,:)
allocate(y(2,3))
x = reshape([1,2,3,4,5,6], [2,3], order=[2,1])
y = reshape([1,2,3,4,5,6], [2,3], order=[2,1])
print *, 'x', transpose(x)
print *, 'y', transpose(y)
end
And results from three machine
It works well on 4.7 on Fedora 17 (no longer maintained)
[qlle@(none) ~]$ gdb --version | head -n1
GNU gdb (GDB) Fedora (7.4.50.20120120-54.fc17)
[qlle@(none) ~]$ gfortran --version | head -n1
GNU Fortran (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)
(gdb) i lo
x = (( 1, 4) ( 2, 5) ( 3, 6) )
y = (( 1, 4) ( 2, 5) ( 3, 6) )
(gdb) p y(:,2)
$1 = (2, 5)
(gdb) p y(2,:)
$2 = (4, 5, 6)
(gdb) show language
The current source language is "auto; currently fortran".
However, with latest version through homebrew
on Mac machine, I got incomplete type
instead.
~/Downloads❯ gdb --version | head -n 1
GNU gdb (GDB) 7.8.1
~/Downloads❯ gfortran --version | head -n1
GNU Fortran (Homebrew gcc 4.9.2_1) 4.9.2
~/Downloads❯ gdb a.out
...
(gdb) break 9
Breakpoint 1 at 0x100000b41: file alloc.f90, line 9.
run
...
(gdb) info locals
x = (( 1, 4) ( 2, 5) ( 3, 6) )
y = <incomplete type>
And even worse, on other Linux box with 4.8 (Ubuntu 14.04), it seems to point to incorrect section (stack instead of heap):
link@hyrule:~$ gdb --version | head -n1
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
link@hyrule:~$ gfortran --version | head -n1
GNU Fortran (Ubuntu 4.8.2-19ubuntu1) 4.8.2
(gdb) i lo
x = (( 1, 4) ( 2, 5) ( 3, 6) )
y = (( 0) )
(gdb) p &y
$1 = (PTR TO -> ( integer(kind=4) (*,*))) 0x7fffffffe4f0
(gdb) p &x
$2 = (PTR TO -> ( integer(kind=4) (2,3))) 0x7fffffffe540
(gdb) p *((integer *) y)@6
$6 = (1, 4, 2, 5, 3, 6)