From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5283 invoked by alias); 17 Dec 2013 12:18:54 -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 5167 invoked by uid 89); 17 Dec 2013 12:18:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 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; Tue, 17 Dec 2013 12:18:52 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 17 Dec 2013 04:18:52 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 17 Dec 2013 04:18:50 -0800 Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [172.28.50.125]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id rBHCIn0s002254; Tue, 17 Dec 2013 12:18:49 GMT Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [127.0.0.1]) by ulliclel004.iul.intel.com (8.13.8/8.12.8/MailSET/client) with ESMTP id rBHCImus003924; Tue, 17 Dec 2013 13:18:48 +0100 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id rBHCIhn4003923; Tue, 17 Dec 2013 13:18:43 +0100 From: Sanimir Agovic To: tromey@redhat.com, palves@redhat.com, xdje42@gmail.com Cc: gdb-patches@sourceware.org, keven.boell@intel.com Subject: [PATCH v4 07/13] vla: support for DW_AT_count Date: Tue, 17 Dec 2013 12:18:00 -0000 Message-Id: <1387282678-3847-8-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1387282678-3847-1-git-send-email-sanimir.agovic@intel.com> References: <1387282678-3847-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00630.txt.bz2 This patch adds support for DW_AT_count as requested in the code review: https://sourceware.org/ml/gdb-patches/2013-11/msg00200.html 2013-11-19 Sanimir Agovic Keven Boell * dwarf2read.c (read_subrange_type): If DW_AT_count is dynamic create the following upper bound dwarf expression 'low + count + 1' by hand. Change-Id: I0f70edd22f2f6d8d7aa32f245e45617a7dc1b24a --- gdb/dwarf2read.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0df385a..10f4e23 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14431,17 +14431,49 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_upper_bound, cu); if (!attr_to_dynamic_prop (attr, die, cu, &high)) { + struct dynamic_prop count; + attr = dwarf2_attr (die, DW_AT_count, cu); - if (attr) + if (attr_to_dynamic_prop (attr, die, cu, &count)) { - int count = dwarf2_get_attr_constant_value (attr, 1); - high.data.const_val = low.data.const_val + count - 1; + if (count.kind == PROP_LOCEXPR) + { + enum bfd_endian byte_order; + struct dwarf2_property_baton *baton = count.data.baton; + const struct dwarf_block blk = {baton->locexpr.size, + baton->locexpr.data}; + /* Allocate a static buffer to hold the following expression: + DW_OP_const8u(1) + CORE_ADDR(8) + DW_OP_plus(1) + + DW_OP_const1s(1), char(1) + DW_OP_minus(1) == 13 bytes. */ + gdb_byte ops[13]; + + ops[0] = DW_OP_const8u; + byte_order = gdbarch_byte_order (get_objfile_arch (cu->objfile)); + store_unsigned_integer (ops + 1, 8, byte_order, + low.data.const_val); + + ops[9] = DW_OP_plus; + ops[10] = DW_OP_const1u; + ops[11] = 1; + ops[12] = DW_OP_minus; + + baton + = obstack_alloc (&cu->objfile->objfile_obstack, + sizeof (struct dwarf2_property_baton)); + /* This should yield the following expression: + high = low + count - 1. + Whereas low is a dwarf expression itself. */ + baton->locexpr = block_to_locexpr_baton (&blk, cu, ops, + sizeof (ops)); + high.data.baton = baton; + high.kind = PROP_LOCEXPR; + } + else if (count.kind == PROP_CONST) + high.data.const_val = low.data.const_val + count.data.const_val - 1; } else - { - /* Unspecified array length. */ - high.data.const_val = low.data.const_val - 1; - } + /* Unspecified array length. */ + high.data.const_val = low.data.const_val - 1; } /* Dwarf-2 specifications explicitly allows to create subrange types -- 1.8.3.1