http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61014
Bug ID: 61014
Summary: [4.6/4.7/4.8/4.9 Regression] gdb can't find symbol of
derived data type array in nested subroutine
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: sven.buijssen at math dot uni-dortmund.de
(I am not exactly sure whether gfortran or gdb are to blame for this issue, but
I tend towards the former.)
The following causes gdb 7.4 to report missing symbols in current context when
compiled with recent gfortran versions:
$ cat <<EOF > debug.f90
program debug
use module
implicit none
type(myint), dimension(1) :: bar
call foo(bar)
end program debug
EOF
$ cat <<EOF > module.f90
module module
implicit none
type myint
integer :: i = -1
end type myint
contains
subroutine foo(bar)
type(myint), dimension(:) :: bar
call subfoo()
contains
subroutine subfoo()
bar(1)%i = 1
print *, bar(1)%i
end subroutine subfoo
end subroutine foo
end module module
EOF
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gcc/4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.9.0/configure --prefix=/usr/local/gcc/4.9.0
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.9.0 (GCC)
$ gfortran -O0 -g -fno-inline -Wall -Wextra -c module.f90
$ gfortran -O0 -g -fno-inline -Wall -Wextra -fno-lto debug.f90 module.o
$ gdb --version
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>.
$ gdb a.out
(gdb) break module.f90:10
Breakpoint 1 at 0x4007a0: file module.f90, line 10.
(gdb) break module.f90:14
Breakpoint 2 at 0x400703: file module.f90, line 14.
(gdb) run
Starting program: /tmp/a.out
Breakpoint 1, 0x00000000004007a0 in __module_MOD_foo ()
(gdb) print bar(1)%i
No symbol "bar" in current context.
(gdb) cont
Continuing.
Breakpoint 2, 0x0000000000400703 in subfoo.2335 ()
(gdb) print bar(1)%i
No symbol "bar" in current context.
#
Dito with GCC 4.8.2.
#
With GCC 4.6.3 and 4.7.3 the respective results of the two print commands in
gdb are:
$1 = -1
value has been optimized out
#
Whereas with GCC 4.4.7 and GCC 4.5.4 the very same version of gdb is able to
show the (expected) value of component i of the first entry of array "bar" at
both breakpoints:
$1 = -1
$2 = -1
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gcc/4.5.4/libexec/gcc/x86_64-unknown-linux-gnu/4.5.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr/local/gcc/4.5.4
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.5.4 (GCC)
###
With Intel Fortran 14.0.1.106 (aka XE 2013 SP1 Update 1) and its accompanying
debugger one can query the value always:
$ ifort -O0 -g -Warn all -c module.f90
$ ifort -O0 -g -Warn all -c debug.f90
$ ifort -O0 -g -Warn all debug.o module.o
$ idbc a.out
Intel(R) Debugger for applications running on Intel(R) 64, Version 13.0, Build
[80.483.23]
------------------
object file name: a.out
Reading symbols from /tmp/a.out...done.
(idb) break module.f90:10
Breakpoint 1 at 0x402ca5: file /tmp/module.f90, line 10.
(idb) break module.f90:14
Breakpoint 2 at 0x402ce8: file /tmp/module.f90, line 14.
(idb) run
Starting program: /tmp/a.out
[New Thread 23410 (LWP 23410)]
Breakpoint 1, MODULE::foo (bar=(...)) at /tmp/module.f90:10
10 call subfoo()
(idb) print bar(1)%i
$1 = -1
(idb) cont
Continuing.
Breakpoint 2, subfoo () at /tmp/module.f90:14
14 bar(1)%i = 1
(idb) print bar(1)%i
$2 = -1
(idb) next
15 print *, bar(1)%i
(idb) print bar(1)%i
$3 = 1