From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74329 invoked by alias); 2 Sep 2015 23:59:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 74318 invoked by uid 89); 2 Sep 2015 23:59:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 02 Sep 2015 23:59:58 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8DC272930A; Wed, 2 Sep 2015 19:59:56 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EMlgengElu5i; Wed, 2 Sep 2015 19:59:56 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 5CB2D28F7F; Wed, 2 Sep 2015 19:59:56 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id ECAEC472C4; Wed, 2 Sep 2015 16:59:54 -0700 (PDT) Date: Wed, 02 Sep 2015 23:59:00 -0000 From: Joel Brobecker To: Pierre-Marie de Rodat Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [Ada] Fix handling of array renamings Message-ID: <20150902235954.GC3356@adacore.com> References: <1441178473-18654-1-git-send-email-derodat@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441178473-18654-1-git-send-email-derodat@adacore.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-09/txt/msg00049.txt.bz2 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. > > gdb/ChangeLog: > > * ada-lang.c (ada_evaluate_subexp) : When the input > value is a reference, actually dereference it in order to get > the underlying value. > > gdb/testsuite/ChangeLog: > > * 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 the patch. 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... -- Joel