multidimensional arrays compiled by gfortran are not passed as such to gdb
jiho
jo.irisson@gmail.com
Thu Aug 9 18:17:00 GMT 2007
Hello everyone,
With the help of the guys on the #gdb irc channel we found what is
apparently a bug in gfortran: multidimensional arrays are not
recognized as such after compilation. Therefore, in gdb, they are
only viewed as uni-dimensional arrays and debugging becomes very
difficult.
Let's see the minimal example:
foo.f:
program foo
real a(1,2)
a(1,1)=3.
a(1,2)=4.
write(*,*) a(1,1)
end
Now with gfortran:
$ gfortran --version
GNU Fortran (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
[...]
$ gfortran -g foo.f
$ gdb a.out
GNU gdb 6.6
[...]
(gdb) b foo.f:7
Breakpoint 1 at 0x400747: file foo.f, line 7.
(gdb) r
Breakpoint 1, MAIN__ () at foo.f:7
(gdb) p a
$1 = (3, 4)
(gdb) p a(1,2)
Wrong number of subscripts
(gdb) ptype a
type = real*4 (0:1)
and
$ readelf -wi a.out
[...]
<2><9d>: Abbrev Number: 3 (DW_TAG_variable)
DW_AT_name : a
DW_AT_decl_file : 1
DW_AT_decl_line : 3
DW_AT_type : <bb>
DW_AT_location : 2 byte block: 91 60 (DW_OP_fbreg: -32)
[...]
While with g77 (or intel fortran for that mater):
$ g77 --version
GNU Fortran (GCC) 3.4.6 20060404 (Red Hat 3.4.6-4)
[...]
$ g77 -g foo.f
$ gdb a.out
GNU gdb 6.6
[...]
(gdb) b foo.f:7
Breakpoint 1 at 0x400890: file foo.f, line 7.
(gdb) r
Breakpoint 1, MAIN__ () at foo.f:7
(gdb) p a
$1 = (( 3) ( 4) )
(gdb) p a(1,2)
$2 = 4
(gdb) ptype a
type = real*4 (1,2)
and
$ readelf -wi a.out
[...]
<2><9c>: Abbrev Number: 3 (DW_TAG_variable)
DW_AT_name : a
DW_AT_decl_file : 1
DW_AT_decl_line : 3
DW_AT_type : <da>
DW_AT_location : 2 byte block: 91 60 (DW_OP_fbreg: -32)
[...]
Is this helpful? Does someone see what the problem can be? Should I
report a bug properly, via bugzilla?
Cheers,
JiHO
---
http://jo.irisson.free.fr/
More information about the Fortran
mailing list