Can GDB be used to print values of allocatable arrays of a derived type in Fortran 90?

Neal Kruis <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAOG8z52-7p0TmgvmCay8xVXJzyTBBbFqhsqMyTx3FVncqrD7eQ@mail.gmail.com>
GDB users,

I just posted this question to Stack Overflow:

http://stackoverflow.com/questions/16447741/can-gdb-be-used-to-print-values-of-allocatable-arrays-of-a-derived-type-in-fortr

I have the following data structure in a Fortran90 program:

TYPE derivedType
  CHARACTER(100)     :: name      = ' '
  INTEGER            :: type      = 0
  REAL(KIND(1.0D0))  :: property  = 0.0
END TYPE derivedType

TYPE (derivedType), ALLOCATABLE, DIMENSION(:) :: arrayOfDerivedTypes

When I try to debug and print values in GDB like:

(gdb) p arrayOfDerivedTypes(1)%name

I get non-sensical values (often stings of zeros, forward slashes and
letters), or completely wrong values (like arrayOfDerivedTypes(1)%name
= 9, when I know that it is = 2). How can I get GDB to print the
correct values?

Background

I am aware of:

this bug: http://sourceware.org/bugzilla/show_bug.cgi?id=9395
this branch of GDB: http://sourceware.org/gdb/wiki/ProjectArcher
and this blog post on printing allocatable arrays:
http://numericalnoob.blogspot.be/2012/08/fortran-allocatable-arrays-and-pointers.html

I don't want to go through the trouble of compiling a separate branch
of GDB to test if it solves this problem if someone already knows that
it won't or if there is a better solution available.

Please let me know (either here or on Stack Overflow) if you have any
suggestions.

Neal Kruis
Big Ladder Software
http://www.bigladdersoftware.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.