gdb does not show heap arrays in fortran

Bug #1315634 reported by Rostislav
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gdb
Fix Released
Critical
gdb (Debian)
Confirmed
Unknown
gdb (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

The problem description can be found in many places over the internet, e.g. here:
http://numericalnoob.blogspot.fi/2012/08/fortran-allocatable-arrays-and-pointers.html
When debugging simple program

program test
    integer, parameter :: ndata = 8, ndim = 2
    real :: my_stack(ndata)
    real, allocatable, target:: my_heap(:)
    real, pointer:: my_ptr(:,:,:)
    allocate(my_heap(ndata))
    ! read stuff
    do i=1,ndata
        my_stack(i) = real(i)
    end do
    my_heap = my_stack
    my_ptr(1:ndim,1:ndim,1:ndim) => my_heap
    write(*,*) my_stack
    write(*,*) my_heap
    write(*,*) my_ptr
end program test

With gdb from distro (GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7) I get:

....
Breakpoint 1, test () at test.f90:13
13 write(*,*) my_stack
(gdb) p my_stack
$1 = (1, 2, 3, 4, 5, 6, 7, 8)
(gdb) p my_heap
$2 = (0)
(gdb) p my_ptr
$3 = (( ( 0) ) )
(gdb)

With properly compiled gdb on another computer (GNU gdb (GDB) SUSE (7.5.1-0.7.29)) i get

....
Breakpoint 1, test () at test.f90:13
13 write(*,*) my_stack
(gdb) p my_stack
$1 = (1, 2, 3, 4, 5, 6, 7, 8)
(gdb) p my_heap
$2 = (1, 2, 3, 4, 5, 6, 7, 8)
(gdb) p my_ptr
$3 = (( ( 1, 2) ( 3, 4) ) ( ( 5, 6) ( 7, 8) ) )
(gdb)

Revision history for this message
Rostislav (rostislav-kouznetsov) wrote :

Worked around by installing gdb from opensuse RPM package with alien.
It issues a lot of warnings and sometimes crashes, but nore or less usable in Ubuntu.

Revision history for this message
Matthias Klose (doko) wrote :

confirmed. looks like this is an upstream issue, and Suse is carrying a local patch?

Changed in gdb (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Changed in gdb (Debian):
status: Unknown → Confirmed
Revision history for this message
Rostislav (rostislav-kouznetsov) wrote :

Works out-of-the-box in Ubuntu 16.04
Can be closed. Thank you!

Changed in gdb:
importance: Unknown → Critical
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.