Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>,
	Chandru <chandru@in.ibm.com>,
	        gdb-patches@sourceware.org
Subject: Re: gdb can't print array element for fortran
Date: Mon, 15 Mar 2010 23:46:00 -0000	[thread overview]
Message-ID: <20100315234543.GA25216@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <m38w9te2aj.fsf@fleche.redhat.com>

On Mon, 15 Mar 2010 21:51:48 +0100, Tom Tromey wrote:
> Joel> I haven't looked at Jan's work for the Fortran VLA stuff in a while,
> Joel> so I can't remember how he dealt with this issue.  But I think his
> Joel> approach might be more correct.
> 
> I too have lost track of this, but my impression is that Jan's current
> patch is rather larger.

The VLA patch of mine does a real calculation of the dynamic sizes.  This
patch just considers dynamically-sized arrays as unbound.

This patch will be superseded by the VLA patch.  But I do not have the VLA
patch ready now in a suitable form for FSF GDB.  Fixed the Chandru's patch if
this partial functionality is enough on its own.

No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.  The
functionality is already tested by the testsuite so the patch does:
-FAIL: gdb.fortran/array-element.exp: print the first element of array a
+PASS: gdb.fortran/array-element.exp: print the first element of array a


Thanks,
Jan


2010-03-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Chandru <chandru@in.ibm.com>

	* dwarf2read.c (read_subrange_type): Set TYPE_HIGH_BOUND_UNDEFINED.
	* valarith.c (value_subscripted_rvalue): Suppress error if
	TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.

--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6074,6 +6074,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
 
   range_type = create_range_type (NULL, base_type, low, high);
 
+  if (attr && attr->form == DW_FORM_block1)
+    TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+
   name = dwarf2_name (die, cu);
   if (name)
     TYPE_NAME (range_type) = name;
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -198,7 +198,8 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
   unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
   struct value *v;
 
-  if (index < lowerbound || elt_offs >= TYPE_LENGTH (array_type))
+  if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
+			     && elt_offs >= TYPE_LENGTH (array_type)))
     error (_("no such vector element"));
 
   v = allocate_value (elt_type);


  reply	other threads:[~2010-03-15 23:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12 13:06 Chandru
2010-03-15 17:13 ` Joel Brobecker
2010-03-15 20:52   ` Tom Tromey
2010-03-15 23:46     ` Jan Kratochvil [this message]
2010-03-16 15:16       ` Joel Brobecker
2010-03-16 21:04         ` Jan Kratochvil
2010-03-18 11:24 Nick Roberts

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=20100315234543.GA25216@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=chandru@in.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.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