gdb/fortran: Show the type for non allocated / associated types
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 1 Mar 2019 11:12:33 +0000 (11:12 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Sat, 15 Jun 2019 23:29:35 +0000 (00:29 +0100)
commit584a927c5ad0d18e9995a0049066b6c503bb7482
treee7235e42ae1098ff109a169478c77dc1ef97accd
parent30056ea04ae3ecd828e2a06e12e6f174ae6659c9
gdb/fortran: Show the type for non allocated / associated types

Show the type of not-allocated and/or not-associated types.  For array
types and pointer to array types we are going to print the number of
ranks.

Consider this Fortran program:

  program test
    integer, allocatable :: vla (:)
    logical l
    allocate (vla(5:12))
    l = allocated (vla)
  end program test

And this GDB session with current HEAD:

  (gdb) start
  ...
  2   integer, allocatable :: vla (:)
  (gdb) n
  4   allocate (vla(5:12))
  (gdb) ptype vla
  type = <not allocated>
  (gdb) p vla
  $1 = <not allocated>
  (gdb)

And the same session with this patch applied:

  (gdb) start
  ...
  2   integer, allocatable :: vla (:)
  (gdb) n
  4   allocate (vla(5:12))
  (gdb) ptype vla
  type = integer(kind=4), allocatable (:)
  (gdb) p vla
  $1 = <not allocated>
  (gdb)

The type of 'vla' is now printed correctly, while the value itself
still shows as '<not allocated>'.  How GDB prints the type of
associated pointers has changed in a similar way.

gdb/ChangeLog:

* f-typeprint.c (f_print_type): Don't return early for not
associated or not allocated types.
(f_type_print_varspec_suffix): Add print_rank parameter and print
ranks of array types in case they dangling.
(f_type_print_base): Add print_rank parameter.

gdb/testsuite/ChangeLog:

* gdb.fortran/pointers.f90: New file.
* gdb.fortran/print_type.exp: New file.
* gdb.fortran/vla-ptype.exp: Adapt expected results.
* gdb.fortran/vla-type.exp: Likewise.
* gdb.fortran/vla-value.exp: Likewise.
* gdb.mi/mi-vla-fortran.exp: Likewise.
gdb/ChangeLog
gdb/f-typeprint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/pointers.f90 [new file with mode: 0644]
gdb/testsuite/gdb.fortran/print_type.exp [new file with mode: 0755]
gdb/testsuite/gdb.fortran/vla-ptype.exp
gdb/testsuite/gdb.fortran/vla-type.exp
gdb/testsuite/gdb.fortran/vla-value.exp
gdb/testsuite/gdb.mi/mi-vla-fortran.exp
This page took 0.026667 seconds and 4 git commands to generate.