* gdb can't print array element for fortran
@ 2010-03-12 13:06 Chandru
2010-03-15 17:13 ` Joel Brobecker
0 siblings, 1 reply; 7+ messages in thread
From: Chandru @ 2010-03-12 13:06 UTC (permalink / raw)
To: gdb-patches
This mail pertains to the discussion had on gdb mailing list sometime
back here http://sourceware.org/ml/gdb-patches/2009-01/msg00251.html.
After a small discussion with Jan I made the following changes and
these didn't seem to work. Any inputs or thoughts would be helpful.
thanks
Chandru
--- src/gdb/gdbtypes.c.orig 2010-02-25 00:00:19.000000000 +0530
+++ src/gdb/gdbtypes.c 2010-02-25 00:03:16.000000000 +0530
@@ -727,6 +727,14 @@ create_range_type (struct type *result_t
if (low_bound >= 0)
TYPE_UNSIGNED (result_type) = 1;
+ if (high_bound < low_bound)
+ {
+ if (high_bound == -1)
+ TYPE_HIGH_BOUND_UNDEFINED(result_type) = 1;
+ else
+ TYPE_HIGH_BOUND_UNDEFINED(result_type) = 0;
+ }
+
return result_type;
}
--- src/gdb/valarith.c.orig 2010-02-25 00:00:26.000000000 +0530
+++ src/gdb/valarith.c 2010-02-25 00:04:37.000000000 +0530
@@ -198,7 +198,7 @@ value_subscripted_rvalue (struct value *
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 || ((elt_offs >= TYPE_LENGTH (array_type)) && !TYPE_HIGH_BOUND_UNDEFINED(array_type)))
error (_("no such vector element"));
v = allocate_value (elt_type);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: gdb can't print array element for fortran
2010-03-12 13:06 gdb can't print array element for fortran Chandru
@ 2010-03-15 17:13 ` Joel Brobecker
2010-03-15 20:52 ` Tom Tromey
0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2010-03-15 17:13 UTC (permalink / raw)
To: Chandru; +Cc: gdb-patches
> This mail pertains to the discussion had on gdb mailing list sometime
> back here http://sourceware.org/ml/gdb-patches/2009-01/msg00251.html.
> After a small discussion with Jan I made the following changes and
> these didn't seem to work. Any inputs or thoughts would be helpful.
Does anyone else have an opinion on this patch. It looks wrong to me
(sorry Chandru): Arrays with a high bound that's less than the low bound
can exist, at least in Ada. It's just an empty array.
I haven't looked at Jan's work for the Fortran VLA stuff in a while,
so I can't remember how he dealt with this issue. But I think his
approach might be more correct.
> --- src/gdb/gdbtypes.c.orig 2010-02-25 00:00:19.000000000 +0530
> +++ src/gdb/gdbtypes.c 2010-02-25 00:03:16.000000000 +0530
> @@ -727,6 +727,14 @@ create_range_type (struct type *result_t
> if (low_bound >= 0)
> TYPE_UNSIGNED (result_type) = 1;
>
> + if (high_bound < low_bound)
> + {
> + if (high_bound == -1)
> + TYPE_HIGH_BOUND_UNDEFINED(result_type) = 1;
> + else
> + TYPE_HIGH_BOUND_UNDEFINED(result_type) = 0;
> + }
> +
> return result_type;
> }
>
> --- src/gdb/valarith.c.orig 2010-02-25 00:00:26.000000000 +0530
> +++ src/gdb/valarith.c 2010-02-25 00:04:37.000000000 +0530
> @@ -198,7 +198,7 @@ value_subscripted_rvalue (struct value *
> 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 || ((elt_offs >= TYPE_LENGTH (array_type)) && !TYPE_HIGH_BOUND_UNDEFINED(array_type)))
> error (_("no such vector element"));
>
> v = allocate_value (elt_type);
--
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: gdb can't print array element for fortran
2010-03-15 17:13 ` Joel Brobecker
@ 2010-03-15 20:52 ` Tom Tromey
2010-03-15 23:46 ` Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-03-15 20:52 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Chandru, gdb-patches
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>> This mail pertains to the discussion had on gdb mailing list sometime
>> back here http://sourceware.org/ml/gdb-patches/2009-01/msg00251.html.
>> After a small discussion with Jan I made the following changes and
>> these didn't seem to work. Any inputs or thoughts would be helpful.
Joel> Does anyone else have an opinion on this patch. It looks wrong to me
Joel> (sorry Chandru): Arrays with a high bound that's less than the low bound
Joel> can exist, at least in Ada. It's just an empty array.
Additionally, if the proposed changes don't actually work, I guess some
other approach is needed anyhow.
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.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb can't print array element for fortran
2010-03-15 20:52 ` Tom Tromey
@ 2010-03-15 23:46 ` Jan Kratochvil
2010-03-16 15:16 ` Joel Brobecker
0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2010-03-15 23:46 UTC (permalink / raw)
To: Tom Tromey; +Cc: Joel Brobecker, Chandru, gdb-patches
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);
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: gdb can't print array element for fortran
2010-03-15 23:46 ` Jan Kratochvil
@ 2010-03-16 15:16 ` Joel Brobecker
2010-03-16 21:04 ` Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2010-03-16 15:16 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Tom Tromey, Chandru, gdb-patches
> 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.
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?
Just one request:
> 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.
Pre-approved with the addition of the comment.
--
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb can't print array element for fortran
2010-03-16 15:16 ` Joel Brobecker
@ 2010-03-16 21:04 ` Jan Kratochvil
0 siblings, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2010-03-16 21:04 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Tom Tromey, Chandru, gdb-patches
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);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdb can't print array element for fortran
@ 2010-03-18 11:24 Nick Roberts
0 siblings, 0 replies; 7+ messages in thread
From: Nick Roberts @ 2010-03-18 11:24 UTC (permalink / raw)
To: Chandru; +Cc: gdb-patches
> This mail pertains to the discussion had on gdb mailing list sometime
> back here http://sourceware.org/ml/gdb-patches/2009-01/msg00251.html.
> After a small discussion with Jan I made the following changes and
> these didn't seem to work. Any inputs or thoughts would be helpful.
Hmm, the example given in January works with GDB 6.8. It looks like a
regression due to this change:
2008-04-22 Markus Deuling <deuling@de.ibm.com>
* eval.c (evaluate_subexp_standard): Use value_subscripted_rvalue for
multi_f77_subscript to support values from registers.
* valarith.c (value_subscripted_rvalue): Remove prototype and static.
* value.h (value_subscripted_rvalue): Add prototype.
* f-typeprint.c (f_type_print_base): Add support for TYPE_CODE_UNION.
Fix output.
* f-valprint.c (f_val_print): Likewise.
--
Nick http://users.snap.net.nz/~nickrob
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-03-18 11:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-12 13:06 gdb can't print array element for fortran Chandru
2010-03-15 17:13 ` Joel Brobecker
2010-03-15 20:52 ` Tom Tromey
2010-03-15 23:46 ` Jan Kratochvil
2010-03-16 15:16 ` Joel Brobecker
2010-03-16 21:04 ` Jan Kratochvil
2010-03-18 11:24 Nick Roberts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox