[Bug 1315634] [NEW] gdb does not show heap arrays in fortran

Rostislav rostislav.kouznetsov at gmail.com
Sat May 3 09:50:00 UTC 2014


Public bug reported:

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)

** Affects: gdb (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/1315634

Title:
  gdb does not show  heap arrays in fortran

Status in “gdb” package in Ubuntu:
  New

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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1315634/+subscriptions



More information about the foundations-bugs mailing list