From patchwork Thu Apr 10 12:40:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Agovic, Sanimir" X-Patchwork-Id: 480 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id A2DB836005B for ; Thu, 10 Apr 2014 05:48:04 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 574D813CFB3E; Thu, 10 Apr 2014 05:48:04 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id 3187F115248D for ; Thu, 10 Apr 2014 05:48:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=BuwmvlA75gw+bbVo7NfWZOCPS3O+f08 uyHUIdbxxQeaBO7NY2EbEOqxR8d3QiFp3k2NntiEpVJqtXwt9wuCfX1kAkiYRdWc SueAJYEq2rpN0mf0y5F+QJ7J5X9l8+0FMTZcmpQw+IrEMJknnR2lAr6deI7FK7u4 NOIMyy4Mtp2M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=GKRPQCYWJkTH11Ih6aCIvBSYfEs=; b=aCqVP EhGPiLd47tdJoD00eClNO7+Q1Cm8wq0NpEJJS+693MtC1+vEYw0LSs0+1ojnyGhK nhAtF4ecHDUX64KA5D1G+FCDTdJNeY6tek4kRtDOivovJAoywD6f/z52WZiKrOdc tto9n+LEQ0U190D+TIiJHC26ehtDuXFo3mops4= Received: (qmail 30692 invoked by alias); 10 Apr 2014 12:48:02 -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 30619 invoked by uid 89); 10 Apr 2014 12:48:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 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; Thu, 10 Apr 2014 12:48:00 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 10 Apr 2014 05:47:58 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 10 Apr 2014 05:47:34 -0700 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 s3AClIcx010118; Thu, 10 Apr 2014 13:47:23 +0100 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 s3ACkHht026768; Thu, 10 Apr 2014 14:46:37 +0200 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id s3ACkBKh026767; Thu, 10 Apr 2014 14:46:11 +0200 From: Sanimir Agovic To: brobecker@adacore.com Cc: gdb-patches@sourceware.org, tromey@redhat.com Subject: [PATCH v6 08/15] vla: support for DW_AT_count Date: Thu, 10 Apr 2014 14:40:10 +0200 Message-Id: <1397133617-26681-9-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> References: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in 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): Convert DW_AT_count to a dynamic property and store it as the high bound and flag the range accordingly. * gdbtypes.c (resolve_dynamic_bounds): If range is flagged as RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound. * gdbtypes.h (enum range_flags): New enum. (struct range_bounds): Add flags member. Signed-off-by: Sanimir Agovic --- gdb/dwarf2read.c | 18 ++++++++++-------- gdb/gdbtypes.c | 4 ++++ gdb/gdbtypes.h | 6 +++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 436d0db..155bdb1 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14340,6 +14340,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct attribute *attr; struct dynamic_prop low, high; int low_default_is_valid; + int high_bound_is_count = 0; const char *name; LONGEST negative_mask; @@ -14406,15 +14407,13 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) if (!attr_to_dynamic_prop (attr, die, cu, &high)) { attr = dwarf2_attr (die, DW_AT_count, cu); - if (attr) - { - int count = dwarf2_get_attr_constant_value (attr, 1); - high.data.const_val = low.data.const_val + count - 1; - } - else + if (attr_to_dynamic_prop (attr, die, cu, &high)) { - /* Unspecified array length. */ - high.data.const_val = low.data.const_val - 1; + /* If bounds are constant do the final calculation here. */ + if (low.kind == PROP_CONST && high.kind == PROP_CONST) + high.data.const_val = low.data.const_val + high.data.const_val - 1; + else + high_bound_is_count = 1; } } @@ -14467,6 +14466,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) range_type = create_range_type (NULL, orig_base_type, &low, &high); + if (high_bound_is_count) + TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1; + /* Ada expects an empty array on no boundary attributes. */ if (attr == NULL && cu->language != language_ada) TYPE_HIGH_BOUND_KIND (range_type) = PROP_UNDEFINED; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index ce582f8..61a5b3d 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1625,6 +1625,10 @@ resolve_dynamic_bounds (struct type *type, CORE_ADDR addr) { high_bound.kind = PROP_CONST; high_bound.data.const_val = value; + + if (TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count) + high_bound.data.const_val + = low_bound.data.const_val + high_bound.data.const_val - 1; } else { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 36e4a5f..d0757e5 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -392,7 +392,6 @@ struct dynamic_prop } data; }; - /* Determine which field of the union main_type.fields[x].loc is used. */ enum field_loc_kind @@ -622,6 +621,11 @@ struct main_type /* High bound of range. */ struct dynamic_prop high; + + /* True if HIGH range bound contains the number of elements in the + subrange. This affects how the final hight bound is computed. */ + + int flag_upper_bound_is_count : 1; } *bounds; } flds_bnds;