This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH] [Ada] Fix handling of array renamings
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Pierre-Marie de Rodat <derodat at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 2 Sep 2015 16:59:54 -0700
- Subject: Re: [PATCH] [Ada] Fix handling of array renamings
- Authentication-results: sourceware.org; auth=none
- References: <1441178473-18654-1-git-send-email-derodat at adacore dot com>
On Wed, Sep 02, 2015 at 09:21:13AM +0200, Pierre-Marie de Rodat wrote:
> Compilers can materialize renamings of arrays (or of accesses to arrays)
> in Ada into variables whose types are references to the actual array
> types. Before this change, trying to use such an array renaming yielded
> an error in GDB:
> (gdb) print my_array(1)
> cannot subscript or call a record
> (gdb) print my_array_ptr(1)
> cannot subscript or call something of type `(null)'
> This behavior comes from bad handling for array renamings, in particular
> the OP_FUNCALL expression operator handling from ada-lang.c
> (ada_evaluate_subexp): in one place we turn the reference into a
> pointer, but the code that follows expect the value to be an array.
> This patch fixes how we handle references in call/subscript evaluation
> so that we turn these references into the actual array values instead of
> pointers to them.
> * ada-lang.c (ada_evaluate_subexp) <OP_FUNCALL>: When the input
> value is a reference, actually dereference it in order to get
> the underlying value.
> * gdb.ada/array_ptr_renaming.exp: New testcase.
> * gdb.ada/array_ptr_renaming/foo.adb: New file.
> * gdb.ada/array_ptr_renaming/pack.ads: New file.
I had a quick look, and I am (litterally) not sure about
Generally speaking, we try very hard to avoid dereferencing objects,
especially arrays or structs, as this opens the door for accidently
fetching the entire object in situations where only one element was
needed. Since we are dealing with array subscripting, this is
necessarily the case here. Perhaps the object's lifetime is constrained
and thus currently would never trigger that excessive fetch. But I need
to look at the rest of the code in that function more carefully to
assess it, and I am too short on time now to do it.
I'll review again when I get back...