From: "Andrew Burgess" <aburgess@broadcom.com>
To: "Mathew Yeates" <mat.yeates@gmail.com>,
"Jan Kratochvil" <jan.kratochvil@redhat.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: RE: multidimensional fortran arrays
Date: Tue, 07 Sep 2010 22:19:00 -0000 [thread overview]
Message-ID: <89AE14E37D740B4796DC14566DF6325ECB7E034783@SJEXCHCCR02.corp.ad.broadcom.com> (raw)
In-Reply-To: <AANLkTinFe-hr1T22x7R9q7ZRW7PS+9vAHGNTb-tkQgzO@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]
The attached patch might fix the issue for you. It should apply cleanly to 7.2
I'll write a test and submit to the patches list in a couple of days. Let me know if you run into any problems.
Andrew
> -----Original Message-----
> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On
> Behalf Of Mathew Yeates
> Sent: 07 September 2010 05:34
> To: Jan Kratochvil
> Cc: gdb@sourceware.org
> Subject: Re: multidimensional fortran arrays
>
> gdb shouldn't claim to support gfortran until this is fixed.
> Seriously, I cant print the value of a multidimensional array?
>
> On Thu, Sep 2, 2010 at 10:46 PM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
> > On Thu, 02 Sep 2010 19:29:07 +0200, Mathew Yeates wrote:
> >> I mentioned this before but got no reply. So I have been getting the
> >> address of the array and using "x/f".
> >> But now I am using 4 dimensional arrays and this is getting old.
> >>
> >> Anyone have any ideas how to fix this? print myarray(1,2) -> "so
> such
> >> vec element"
> >
> > For some reason it really does not work even for static arrays.
> > program a
> > integer :: v (2, 3, 4)
> > v (:, :, :) = 10
> > v (2, 3, 4) = 20
> > v (2, 3, 4) = 20 ! line 5
> > end
> > (gdb) b 5
> > (gdb) r
> > (gdb) p v(2,3,4)
> > no such vector element
> >
> > It works on archer-jankratochvil-vla
> > (gdb) p v(2,3,4)
> > $1 = 20
> > available at
> > http://sourceware.org/gdb/wiki/ArcherBranchManagement
> > (or Fedora releases) but the support has some other problems and I
> should
> > merge it to FSF GDB soon.
> >
> >
> > Thanks,
> > Jan
> >
[-- Attachment #2: arrays.patch --]
[-- Type: application/octet-stream, Size: 3641 bytes --]
diff -rcp gdb-7.2-clean/gdb/ChangeLog gdb-7.2/gdb/ChangeLog
*** gdb-7.2-clean/gdb/ChangeLog 2010-09-03 00:37:25.000000000 +0100
--- gdb-7.2/gdb/ChangeLog 2010-09-07 22:58:01.229977481 +0100
***************
*** 1,3 ****
--- 1,13 ----
+ 2010-09-07 Andrew Burgess <aburgess@broadcom.com>
+
+ * valarith.c (value_subscripted_rvalue) Walk through
+ multi-dimensional arrays to find the element type for the
+ array. Allows the upper bound check to work with multi-dimensional
+ arrays.
+ * eval.c (evaluate_subexp_standard) Remove hack from
+ multi_f77_subscript case now that multi-dimensional arrays are
+ supported in valarith.c
+
2010-09-02 Joel Brobecker <brobecker@adacore.com>
* NEWS: Replace "Changes since GDB 7.1" by "Changes in GDB 7.2".
diff -rcp gdb-7.2-clean/gdb/eval.c gdb-7.2/gdb/eval.c
*** gdb-7.2-clean/gdb/eval.c 2010-07-07 17:15:15.000000000 +0100
--- gdb-7.2/gdb/eval.c 2010-09-07 22:44:31.493976944 +0100
*************** evaluate_subexp_standard (struct type *e
*** 2296,2311 ****
subscript_array[nargs - i - 1] -= lower;
! /* If we are at the bottom of a multidimensional
! array type then keep a ptr to the last ARRAY
! type around for use when calling value_subscript()
! below. This is done because we pretend to value_subscript
! that we actually have a one-dimensional array
! of base element type that we apply a simple
! offset to. */
!
! if (i < nargs - 1)
! tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
}
/* Now let us calculate the offset for this item */
--- 2296,2302 ----
subscript_array[nargs - i - 1] -= lower;
! tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
}
/* Now let us calculate the offset for this item */
*************** evaluate_subexp_standard (struct type *e
*** 2316,2329 ****
offset_item =
array_size_array[i - 1] * offset_item + subscript_array[i - 1];
- /* Let us now play a dirty trick: we will take arg1
- which is a value node pointing to the topmost level
- of the multidimensional array-set and pretend
- that it is actually a array of the final element
- type, this will ensure that value_subscript()
- returns the correct type value */
-
- deprecated_set_value_type (arg1, tmp_type);
return value_subscripted_rvalue (arg1, offset_item, 0);
}
--- 2307,2312 ----
diff -rcp gdb-7.2-clean/gdb/valarith.c gdb-7.2/gdb/valarith.c
*** gdb-7.2-clean/gdb/valarith.c 2010-06-07 17:11:31.000000000 +0100
--- gdb-7.2/gdb/valarith.c 2010-09-07 22:52:25.154057798 +0100
*************** struct value *
*** 193,199 ****
value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
{
struct type *array_type = check_typedef (value_type (array));
! struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
unsigned int elt_size = TYPE_LENGTH (elt_type);
unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
struct value *v;
--- 193,208 ----
value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
{
struct type *array_type = check_typedef (value_type (array));
! struct type *elt_type = array_type;
!
! /* Peel of the array indices until we reach the array element type */
! do {
! elt_type = TYPE_TARGET_TYPE(elt_type);
! }
! while ( TYPE_CODE(elt_type) == TYPE_CODE_ARRAY);
!
! elt_type = check_typedef(elt_type);
!
unsigned int elt_size = TYPE_LENGTH (elt_type);
unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
struct value *v;
next prev parent reply other threads:[~2010-09-07 22:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 17:29 Mathew Yeates
2010-09-03 5:47 ` Jan Kratochvil
2010-09-07 4:34 ` Mathew Yeates
2010-09-07 22:19 ` Andrew Burgess [this message]
2010-09-09 16:37 ` Mathew Yeates
2010-09-13 23:14 ` Mathew Yeates
2010-09-14 7:32 ` Andrew Burgess
2010-09-15 17:45 ` Tom Tromey
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=89AE14E37D740B4796DC14566DF6325ECB7E034783@SJEXCHCCR02.corp.ad.broadcom.com \
--to=aburgess@broadcom.com \
--cc=gdb@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=mat.yeates@gmail.com \
/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