From patchwork Mon Apr 14 17:13:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 543 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 0F258360075 for ; Mon, 14 Apr 2014 10:14:14 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id BA96C4BCEFB5; Mon, 14 Apr 2014 10:14:13 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.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-mx22.g.dreamhost.com (Postfix) with ESMTPS id 8A8A54BCEF55 for ; Mon, 14 Apr 2014 10:14:13 -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=mbuqQLAdxNSWX/iZ20KUfB5fI5HOM9/ q6QTjD7+O0UWT3lixeZrfAkpnQIcNjLlYUIE7P3HPcVnl3SmadVANPzl6Qj+CwJa w5PZfPVFsmOpt9cQ5asgS/I7N+CmE7eSAD3C3M8g8pRZak9Q0LSW+VNGFgitsA/x op01UHvnLjbU= 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=njoMtOtGz90e5SNMaidDY0PCjjM=; b=Q1bjx m++qMuhX+JVRSg7DH2aCfXscjOHIaV0ksavWhtHfxv1zQ1EWoMSP60e5EdsNOXZD 5o4sYpv8QGVJNjBPQPKkII7AgkuD7W/DSo5YGKU9FsHm60g0iTQ4cCRhGI8vtUPp /xSL0b9KUiuu63COxMLKfr7w6rkTERA3LYQdHA= Received: (qmail 8473 invoked by alias); 14 Apr 2014 17:13:45 -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 8370 invoked by uid 89); 14 Apr 2014 17:13:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham 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; Mon, 14 Apr 2014 17:13:43 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5B6171160DB; Mon, 14 Apr 2014 13:13:41 -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 JKbWyRunBZ7F; Mon, 14 Apr 2014 13:13:41 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 2745D116132; Mon, 14 Apr 2014 13:13:41 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id B5722E02C0; Mon, 14 Apr 2014 10:13:46 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Sanimir Agovic Subject: [PATCH 06/12] vla: support for DW_AT_count Date: Mon, 14 Apr 2014 10:13:10 -0700 Message-Id: <1397495596-25364-7-git-send-email-brobecker@adacore.com> In-Reply-To: <1397495596-25364-1-git-send-email-brobecker@adacore.com> References: <0377C58828D86C4588AEEC42FC3B85A71D8507B7@IRSMSX105.ger.corp.intel.com> <1397495596-25364-1-git-send-email-brobecker@adacore.com> X-DH-Original-To: gdb@patchwork.siddhesh.in From: Sanimir Agovic This patch adds support for DW_AT_count as requested in the code review: https://sourceware.org/ml/gdb-patches/2013-11/msg00200.html gdb/ChangeLog: * 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. --- gdb/ChangeLog | 9 +++++++++ gdb/dwarf2read.c | 18 ++++++++++-------- gdb/gdbtypes.c | 4 ++++ gdb/gdbtypes.h | 5 +++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0630f1c..717c197 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2014-04-14 Sanimir Agovic + * 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. + +2014-04-14 Sanimir Agovic + * c-typeprint.c (c_type_print_varspec_suffix): Added check for not yet resolved high bound. If unresolved, print "variable length" string to the console instead of random diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index ff66cce..7c64491 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14493,6 +14493,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; @@ -14559,15 +14560,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; } } @@ -14627,6 +14626,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 d510ee6..57101e1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1698,6 +1698,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 97411d1..6c3bb33 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -663,6 +663,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;