This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: gdb can't print array element for fortran
On Tue, 16 Mar 2010 16:16:21 +0100, Joel Brobecker wrote:
> This seems like a reasonable workaround, especially since we already
> have some special handling of attr->form == DW_FORM_block1 for range
> types. So I guess we never have block2/block4 or even block attributes
> for the upper bound in practice?
* I cannot imagine a case something else than DW_FORM_block1 would be used but
sure GDB should handled all the DW_FORM_block* cases to be correct.
* The maintained offtrunk patch archer-jankratochvil-vla is using
attr_form_is_block() for the full DW_FORM_block* support.
* As the existing FSF GDB code was already limited to DW_FORM_block1.
* The new patch code fragment application scope should match the scope of the
existing FSF GDB code.
* This patch will need to be reverted/merged-out on future import of some form
of the archer-jankratochvil-vla branch therefore I wanted to minimize any
effort for its import as it should have been spent rather on preparing
archer-jankratochvil-vla for the merge instead.
=> Chose the minimal patchset satisfying Chandru's requirements.
> > range_type = create_range_type (NULL, base_type, low, high);
> >
> > + if (attr && attr->form == DW_FORM_block1)
> > + TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
>
> Can you add a quick comment, with a FIXME to show that this is temporary?
> There's already some useful comments just slightly earlier in the code,
> perhaps we just ought to refer to that, somehow.
Done (forgot the FIXME keyword I see now, sorry).
> Pre-approved with the addition of the comment.
Checked-in.
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2010-03/msg00158.html
--- src/gdb/ChangeLog 2010/03/16 18:47:14 1.11491
+++ src/gdb/ChangeLog 2010/03/16 20:51:23 1.11492
@@ -1,3 +1,10 @@
+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.
+
2010-03-16 Holger Hans Peter Freyther <zecke@selfish.org>
* linux-record.c (record_linux_msghdr): Remove unintended semicolons.
--- src/gdb/dwarf2read.c 2010/03/15 20:49:53 1.368
+++ src/gdb/dwarf2read.c 2010/03/16 20:51:23 1.369
@@ -6074,6 +6074,12 @@
range_type = create_range_type (NULL, base_type, low, high);
+ /* Mark arrays with dynamic length at least as an array of unspecified
+ length. GDB could check the boundary but before it gets implemented at
+ least allow accessing the array elements. */
+ 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;
--- src/gdb/valarith.c 2010/02/11 21:45:25 1.81
+++ src/gdb/valarith.c 2010/03/16 20:51:23 1.82
@@ -198,7 +198,8 @@
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);