This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA] Add handling of null Ada arrays
- From: "Pierre Muller" <muller at ics dot u-strasbg dot fr>
- To: "'Joel Brobecker'" <brobecker at adacore dot com>, <gdb-patches at sourceware dot org>
- Date: Wed, 9 Jan 2008 10:21:42 +0100
- Subject: RE: [RFA] Add handling of null Ada arrays
- References: <20080109063342.GE20580@adacore.com>
At least in pascal language it is quite
common to use things like
type
BigArray = Array [1..0xffffffff] of integer;
if you want to be sure that you will never get into
troubles due to range checking...
Of course you cannot allocate a pointer to such a type
directly, and it would eat up a lot of memory space.
But this kind of types always gave problems
inside gdb, because when you wanted to look at
the value gdb would try to copy the whole array...
even if cases where it would only display the first elements,
which is kind of silly, no?
Do not interpret this remark as an argument against
your patch, I just wanted to state that arrays with
strange bound values have several problems...
Pierre Muller
Pascal language maintainer.
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Joel Brobecker
> Sent: Wednesday, January 09, 2008 7:34 AM
> To: gdb-patches@sourceware.org
> Subject: [RFA] Add handling of null Ada arrays
>
> Hello,
>
> In Ada, arrays can be empty by setting the high bound to a smaller
> value than the low bound. For instance, a typical declaration would be:
>
> type Empty_Array is array (1 .. 0) of Integer;
>
> The attached patch fixes a bug when trying to print a variable of such
> a type:
>
> (gdb) print my_table
> object size is larger than varsize-limit
>
> The problem is that we compute the array length using the bounds from
> the index type without checking first that the high bound is larger or
> equal to the small bound. There were a couple of places were we did
> that, so we made some adjustments there.
>
> 2008-01-09 Joel Brobecker <brobecker@adacore.com>
>
> * gdbtypes.c (create_array_type): Add handling of null Ada
> arrays.
> (check_typedef): Likewise.
>
> I was able to write a testcase too:
>
> 2008-01-09 Joel Brobecker <brobecker@adacore.com>
>
> * gdb.ada/null_array: New test program.
> * gdb.ada/null_array.exp: New testcase.
>
> Tested on x86-linux, no regression.
> OK to commit?
>
> Thanks,
> --
> Joel