From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25025 invoked by alias); 6 Feb 2014 16:27:55 -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 24938 invoked by uid 89); 6 Feb 2014 16:27:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2014 16:27:54 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 06 Feb 2014 08:27:50 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 06 Feb 2014 08:27:48 -0800 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [172.28.50.210]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s16GRm5n031097; Thu, 6 Feb 2014 16:27:48 GMT 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 s16GRlfE025326; Thu, 6 Feb 2014 17:27:48 +0100 Received: (from sagovic@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s16GRlXN025325; Thu, 6 Feb 2014 17:27:47 +0100 From: Sanimir Agovic To: tromey@redhat.com, brobecker@adacore.com Cc: keven.boell@intel.com, gdb-patches@sourceware.org Subject: [PATCH v5 08/15] vla: support for DW_AT_count Date: Thu, 06 Feb 2014 16:27:00 -0000 Message-Id: <1391704056-25246-9-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1391704056-25246-1-git-send-email-sanimir.agovic@intel.com> References: <1391704056-25246-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00099.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): 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 | 5 +++++ gdb/gdbtypes.h | 9 +++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1d5fa3d..1e4de21 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14334,6 +14334,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; @@ -14400,15 +14401,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; } } @@ -14461,6 +14460,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)->flags = RANGE_UPPER_BOUND_IS_COUNT; + /* 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 f5bd236..83a2c75 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1674,6 +1674,11 @@ 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)->flags & RANGE_UPPER_BOUND_IS_COUNT) + == RANGE_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 38cd240..100e3f4 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -392,6 +392,12 @@ struct dynamic_prop } data; }; +/* Flags used in main_type.range_bounds for bounds evaluation. */ + +enum range_flags +{ + RANGE_UPPER_BOUND_IS_COUNT = 1 /* High bound contains number of elements. */ +}; /* Determine which field of the union main_type.fields[x].loc is used. */ @@ -622,6 +628,9 @@ struct main_type /* High bound of range. */ struct dynamic_prop high; + + /* Flags about this range. */ + unsigned int flags; } *bounds; } flds_bnds; -- 1.8.4.2