Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Heckel, Bernhard" <bernhard.heckel@intel.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3][PING] fort_dyn_array: Support evaluation of dynamic elements inside arrays.
Date: Mon, 04 Apr 2016 09:22:00 -0000	[thread overview]
Message-ID: <57023253.8090600@intel.com> (raw)
In-Reply-To: <1458204189-13267-3-git-send-email-bernhard.heckel@intel.com>



On 17/03/2016 09:43, Bernhard Heckel wrote:
> Resolve type of an array's element to be printed in case it is dynamic.
> Otherwise we don't use the correct boundaries nor the right location.
>
> Before:
>    ptype fivearr(1)
>    type = Type five
>        Type one
>            integer(kind=4) :: ivla(34196784:34196832,34197072:34197120,34197360:34197408)
>        End Type one :: tone
>    End Type five
>
> After:
>    ptype fivearr(1)
>    type = Type five
>        Type one
>            integer(kind=4) :: ivla(2,4,6)
>        End Type one :: tone
>    End Type five
>
> 2016-02-24  Bernhard Heckel  <bernhard.heckel@intel.com>
>
> gdb/Changelog:
> 	* valarith.c (value_address): Resolve dynamic types.
>
> gdb/testsuite/Changelog:
> 	* gdb.fortran/vla-type.f90: Add test for static and dynamic arrays
> 	of dynamic types.
> 	* gdb.fortran/vla-type.exp: Add test for static and dynamic arrays
> 	of dynamic types.
>
> ---
>   gdb/testsuite/gdb.fortran/vla-type.exp | 52 ++++++++++++++++++++++++++++++++++
>   gdb/testsuite/gdb.fortran/vla-type.f90 | 20 +++++++++++--
>   gdb/valarith.c                         |  9 ++++++
>   3 files changed, 79 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 1d09451..f9c0b61 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -96,3 +96,55 @@ gdb_test "ptype fivev" \
>                        "\\s+integer\\\(kind=4\\\) :: ivla\\\(10,10,10\\\)" \
>                        "\\s+End Type one :: tone" \
>                        "End Type five" ]
> +
> +# Check array of types containing a VLA
> +gdb_breakpoint [gdb_get_line_number "fivearr-filled"]
> +gdb_continue_to_breakpoint "fivearr-filled"
> +gdb_test "print fivearr(1)%tone%ivla(1, 2, 3)" " = 1"
> +gdb_test "print fivearr(1)%tone%ivla(2, 2, 10)" "no such vector element"
> +gdb_test "print fivearr(1)%tone%ivla(2, 2, 3)" " = 223"
> +gdb_test "print fivearr(2)%tone%ivla(12, 14, 16)" " = 2"
> +gdb_test "print fivearr(2)%tone%ivla(6, 7, 8)" " = 678"
> +gdb_test "ptype fivearr(1)" \
> +         [multi_line "type = Type five" \
> +                     "\\s+Type one" \
> +                     "\\s+integer\\\(kind=4\\\) :: ivla\\\(2,4,6\\\)" \
> +                     "\\s+End Type one :: tone" \
> +                     "End Type five" ]
> +gdb_test "ptype fivearr(2)" \
> +         [multi_line "type = Type five" \
> +                     "\\s+Type one" \
> +                     "\\s+integer\\\(kind=4\\\) :: ivla\\\(12,14,16\\\)" \
> +                     "\\s+End Type one :: tone" \
> +                     "End Type five" ]
> +
> +# Check allocation status of dynamic array and it's dynamic members
> +gdb_test "ptype fivedynarr" "type = <not allocated>"
> +gdb_test "next" ""
> +gdb_test "ptype fivedynarr(2)" \
> +         [multi_line "type = Type five" \
> +                     "\\s+Type one" \
> +                     "\\s+integer\\\(kind=4\\\) :: ivla\\\(<not allocated>\\\)" \
> +                     "\\s+End Type one :: tone" \
> +                     "End Type five" ]
> +
> +# Check dynamic array of types containing a VLA
> +gdb_breakpoint [gdb_get_line_number "fivedynarr-filled"]
> +gdb_continue_to_breakpoint "fivedynarr-filled"
> +gdb_test "print fivedynarr(1)%tone%ivla(1, 2, 3)" " = 1"
> +gdb_test "print fivedynarr(1)%tone%ivla(2, 2, 10)" "no such vector element"
> +gdb_test "print fivedynarr(1)%tone%ivla(2, 2, 3)" " = 223"
> +gdb_test "print fivedynarr(2)%tone%ivla(12, 14, 16)" " = 2"
> +gdb_test "print fivedynarr(2)%tone%ivla(6, 7, 8)" " = 678"
> +gdb_test "ptype fivedynarr(1)" \
> +         [multi_line "type = Type five" \
> +                     "\\s+Type one" \
> +                     "\\s+integer\\\(kind=4\\\) :: ivla\\\(2,4,6\\\)" \
> +                     "\\s+End Type one :: tone" \
> +                     "End Type five" ]
> +gdb_test "ptype fivedynarr(2)" \
> +         [multi_line "type = Type five" \
> +                     "\\s+Type one" \
> +                     "\\s+integer\\\(kind=4\\\) :: ivla\\\(12,14,16\\\)" \
> +                     "\\s+End Type one :: tone" \
> +                     "End Type five" ]
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.f90 b/gdb/testsuite/gdb.fortran/vla-type.f90
> index a106617..5473124 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.f90
> +++ b/gdb/testsuite/gdb.fortran/vla-type.f90
> @@ -38,6 +38,8 @@ program vla_struct
>     type(three)              :: threev
>     type(four)               :: fourv
>     type(five)               :: fivev
> +  type(five)               :: fivearr (2)
> +  type(five), allocatable  :: fivedynarr (:)
>     logical                  :: l
>     integer                  :: i, j
>   
> @@ -83,6 +85,20 @@ program vla_struct
>     fivev%tone%ivla(1, 2, 3) = 123
>     fivev%tone%ivla(3, 2, 1) = 321
>   
> -  ! dummy statement for bp
> -  l = allocated(fivev%tone%ivla)                  ! fivev-filled
> +  allocate (fivearr(1)%tone%ivla (2, 4, 6))        ! fivev-filled
> +  allocate (fivearr(2)%tone%ivla (12, 14, 16))
> +  fivearr(1)%tone%ivla(:, :, :) = 1
> +  fivearr(1)%tone%ivla(2, 2, 3) = 223
> +  fivearr(2)%tone%ivla(:, :, :) = 2
> +  fivearr(2)%tone%ivla(6, 7, 8) = 678
> +
> +  allocate (fivedynarr(2))                         ! fivearr-filled
> +  allocate (fivedynarr(1)%tone%ivla (2, 4, 6))
> +  allocate (fivedynarr(2)%tone%ivla (12, 14, 16))
> +  fivedynarr(1)%tone%ivla(:, :, :) = 1
> +  fivedynarr(1)%tone%ivla(2, 2, 3) = 223
> +  fivedynarr(2)%tone%ivla(:, :, :) = 2
> +  fivedynarr(2)%tone%ivla(6, 7, 8) = 678
> +
> +  l = allocated(fivedynarr)                        ! fivedynarr-filled
>   end program vla_struct
> diff --git a/gdb/valarith.c b/gdb/valarith.c
> index 7959f3b..62d0e30 100644
> --- a/gdb/valarith.c
> +++ b/gdb/valarith.c
> @@ -207,6 +207,15 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
>           error (_("no such vector element"));
>       }
>   
> +  if (is_dynamic_type (elt_type))
> +    {
> +      gdb_byte *valaddr = NULL;
> +      CORE_ADDR address;
> +
> +      address = value_address (array) + elt_offs;
> +      elt_type = resolve_dynamic_type (elt_type, valaddr, address);
> +    }
> +
>     if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
>       v = allocate_value_lazy (elt_type);
>     else

-- 

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2016-04-04  9:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17  8:43 [PATCH 0/3] fortran: Enable arrays of structures with dynamic member types Bernhard Heckel
2016-03-17  8:43 ` [PATCH 3/3] fort_dyn_array: Use value constructor instead of raw-buffer manipulation Bernhard Heckel
2016-04-04 13:54   ` Yao Qi
2016-04-05  9:31     ` Heckel, Bernhard
2016-03-17  8:43 ` [PATCH 1/3] fort_dyn_array: Enable dynamic member types inside a structure Bernhard Heckel
2016-04-04  9:22   ` [PATCH 1/3][PING] " Heckel, Bernhard
2016-04-04 13:31   ` [PATCH 1/3] " Yao Qi
2016-04-04 16:24     ` Yao Qi
2016-04-05  7:31     ` Heckel, Bernhard
2016-04-05 10:47       ` Yao Qi
2016-04-05 12:42         ` Heckel, Bernhard
2016-04-06 16:09           ` Yao Qi
2016-04-07  6:03             ` Heckel, Bernhard
2016-03-17  8:43 ` [PATCH 2/3] fort_dyn_array: Support evaluation of dynamic elements inside arrays Bernhard Heckel
2016-04-04  9:22   ` Heckel, Bernhard [this message]
2016-04-04 13:42   ` Yao Qi
2016-04-04  9:21 ` [PATCH 0/3][PING] fortran: Enable arrays of structures with dynamic member types Heckel, Bernhard
2016-04-04 10:50 ` [PATCH 0/3] " Yao Qi
2016-04-04 12:16   ` Heckel, Bernhard
2016-04-04 14:41     ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57023253.8090600@intel.com \
    --to=bernhard.heckel@intel.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox