From patchwork Wed Sep 10 09:21:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 2723 Received: (qmail 29830 invoked by alias); 10 Sep 2014 09:22:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 29717 invoked by uid 89); 10 Sep 2014 09:22:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Sep 2014 09:22:14 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 10 Sep 2014 02:22:11 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 10 Sep 2014 02:22:10 -0700 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [172.28.50.14]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s8A9M9Yd008339; Wed, 10 Sep 2014 10:22:09 +0100 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [127.0.0.1]) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8) with ESMTP id s8A9MDp4020696; Wed, 10 Sep 2014 11:22:13 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s8A9MCU1020695; Wed, 10 Sep 2014 11:22:12 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: sanimir.agovic@intel.com, Keven Boell Subject: [V3 03/21] vla: make field selection work with vla Date: Wed, 10 Sep 2014 11:21:51 +0200 Message-Id: <1410340929-20653-4-git-send-email-keven.boell@intel.com> In-Reply-To: <1410340929-20653-1-git-send-email-keven.boell@intel.com> References: <1410340929-20653-1-git-send-email-keven.boell@intel.com> In Fortran vla are pointers to arrays. Thus a type only contains a pointer to such array and we need to re-read the field to retrieve the correct vla. old (wrong value): (gdb) p type_var%vla(14) $1 = 1 new (correct value): (gdb) p type_var%vla(14) $1 = 42 2014-05-28 Sanimir Agovic Keven Boell * value.c (value_primitive_field): Re-evaluate field value to get the actual value. --- gdb/value.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 4ed70e7..769cbbb 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3038,13 +3038,22 @@ value_primitive_field (struct value *arg1, int offset, v = allocate_value_lazy (type); else { - v = allocate_value (type); - value_contents_copy_raw (v, value_embedded_offset (v), - arg1, value_embedded_offset (arg1) + offset, - TYPE_LENGTH (type)); + if (TYPE_DATA_LOCATION (type) + && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) + v = value_at_lazy (type, value_address (arg1) + offset); + else + { + v = allocate_value (type); + value_contents_copy_raw (v, value_embedded_offset (v), + arg1, value_embedded_offset (arg1) + offset, + TYPE_LENGTH (type)); + } } - v->offset = (value_offset (arg1) + offset - + value_embedded_offset (arg1)); + + if (!TYPE_DATA_LOCATION (type) + || !TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) + v->offset = (value_offset (arg1) + offset + + value_embedded_offset (arg1)); } set_value_component_location (v, arg1); VALUE_REGNUM (v) = VALUE_REGNUM (arg1);