From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30322 invoked by alias); 10 Sep 2014 09:22:19 -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 30244 invoked by uid 89); 10 Sep 2014 09:22:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 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:15 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 10 Sep 2014 02:22:14 -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:12 -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 s8A9MC2O008357; Wed, 10 Sep 2014 10:22:12 +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 s8A9MFPS020720; Wed, 10 Sep 2014 11:22:15 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s8A9MF83020719; Wed, 10 Sep 2014 11:22:15 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: sanimir.agovic@intel.com, Keven Boell Subject: [V3 09/21] vla: add stride support to fortran arrays. Date: Wed, 10 Sep 2014 09:22:00 -0000 Message-Id: <1410340929-20653-10-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> X-SW-Source: 2014-09/txt/msg00260.txt.bz2 2014-05-28 Sanimir Agovic Keven Boell * dwarf2read.c (read_subrange_type): Read dynamic stride attributes. * gdbtypes.c (create_array_type_with_stride): Add stride support (create_range_type): Add stride parameter. (create_static_range_type): Pass default stride parameter. (resolve_dynamic_range): Evaluate stride baton. (resolve_dynamic_type): Adjust data location with the value of byte stride. * gdbtypes.h (TYPE_BYTE_STRIDE): New macro. (TYPE_BYTE_STRIDE_BLOCK): New macro. (TYPE_BYTE_STRIDE_LOCLIST): New macro. (TYPE_BYTE_STRIDE_KIND): New macro. * valarith.c (value_subscripted_rvalue): Use stride. --- gdb/dwarf2read.c | 13 +++++++++++-- gdb/f-valprint.c | 8 +++++++- gdb/gdbtypes.c | 39 +++++++++++++++++++++++++++++++++------ gdb/gdbtypes.h | 17 +++++++++++++++++ gdb/valarith.c | 14 +++++++++++++- 5 files changed, 81 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 41ae49d..939fee3 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14732,7 +14732,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) struct type *base_type, *orig_base_type; struct type *range_type; struct attribute *attr; - struct dynamic_prop low, high; + struct dynamic_prop low, high, stride; int low_default_is_valid; int high_bound_is_count = 0; const char *name; @@ -14752,7 +14752,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) low.kind = PROP_CONST; high.kind = PROP_CONST; + stride.kind = PROP_CONST; high.data.const_val = 0; + stride.data.const_val = 0; /* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow omitting DW_AT_lower_bound. */ @@ -14785,6 +14787,13 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) break; } + attr = dwarf2_attr (die, DW_AT_byte_stride, cu); + if (attr) + if (!attr_to_dynamic_prop (attr, die, cu, &stride, NULL, 0)) + complaint (&symfile_complaints, _("Missing DW_AT_byte_stride " + "- DIE at 0x%x [in module %s]"), + die->offset.sect_off, objfile_name (cu->objfile)); + attr = dwarf2_attr (die, DW_AT_lower_bound, cu); if (attr) attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0); @@ -14861,7 +14870,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) && !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask)) high.data.const_val |= negative_mask; - range_type = create_range_type (NULL, orig_base_type, &low, &high); + range_type = create_range_type (NULL, orig_base_type, &low, &high, &stride); if (high_bound_is_count) TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1; diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 4c45b83..69a57bd 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -122,8 +122,14 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, if (nss != ndimensions) { - size_t dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type)); + size_t dim_size; size_t offs = 0; + LONGEST byte_stride = abs (TYPE_BYTE_STRIDE (range_type)); + + if (byte_stride) + dim_size = byte_stride; + else + dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type)); for (i = lowerbound; (i < upperbound + 1 && (*elts) < options->print_max); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 29c1dbd..f554ee1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -803,7 +803,8 @@ allocate_stub_method (struct type *type) struct type * create_range_type (struct type *result_type, struct type *index_type, const struct dynamic_prop *low_bound, - const struct dynamic_prop *high_bound) + const struct dynamic_prop *high_bound, + const struct dynamic_prop *stride) { if (result_type == NULL) result_type = alloc_type_copy (index_type); @@ -818,6 +819,7 @@ create_range_type (struct type *result_type, struct type *index_type, TYPE_ZALLOC (result_type, sizeof (struct range_bounds)); TYPE_RANGE_DATA (result_type)->low = *low_bound; TYPE_RANGE_DATA (result_type)->high = *high_bound; + TYPE_RANGE_DATA (result_type)->stride = *stride; if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0) TYPE_UNSIGNED (result_type) = 1; @@ -839,7 +841,7 @@ struct type * create_static_range_type (struct type *result_type, struct type *index_type, LONGEST low_bound, LONGEST high_bound) { - struct dynamic_prop low, high; + struct dynamic_prop low, high, stride; low.kind = PROP_CONST; low.data.const_val = low_bound; @@ -847,7 +849,11 @@ create_static_range_type (struct type *result_type, struct type *index_type, high.kind = PROP_CONST; high.data.const_val = high_bound; - result_type = create_range_type (result_type, index_type, &low, &high); + stride.kind = PROP_CONST; + stride.data.const_val = 0; + + result_type = create_range_type (result_type, index_type, + &low, &high, &stride); return result_type; } @@ -1004,16 +1010,21 @@ create_array_type_with_stride (struct type *result_type, if (has_static_range (TYPE_RANGE_DATA (range_type)) && dwarf2_address_data_valid (result_type)) { - LONGEST low_bound, high_bound; + LONGEST low_bound, high_bound, byte_stride; if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) low_bound = high_bound = 0; CHECK_TYPEDEF (element_type); + + byte_stride = abs (TYPE_BYTE_STRIDE (range_type)); + /* Be careful when setting the array length. Ada arrays can be empty arrays with the high_bound being smaller than the low_bound. In such cases, the array length should be zero. */ if (high_bound < low_bound) TYPE_LENGTH (result_type) = 0; + else if (byte_stride > 0) + TYPE_LENGTH (result_type) = byte_stride * (high_bound - low_bound + 1); else if (bit_stride > 0) TYPE_LENGTH (result_type) = (bit_stride * (high_bound - low_bound + 1) + 7) / 8; @@ -1716,7 +1727,7 @@ resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr) struct type *static_range_type; const struct dynamic_prop *prop; const struct dwarf2_locexpr_baton *baton; - struct dynamic_prop low_bound, high_bound; + struct dynamic_prop low_bound, high_bound, stride; struct type *range_copy = copy_type (dyn_range_type); gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE); @@ -1748,10 +1759,17 @@ resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr) high_bound.kind = PROP_UNDEFINED; high_bound.data.const_val = 0; } + + prop = &TYPE_RANGE_DATA (dyn_range_type)->stride; + if (dwarf2_evaluate_property (prop, addr, &value)) + { + stride.kind = PROP_CONST; + stride.data.const_val = value; + } static_range_type = create_range_type (range_copy, TYPE_TARGET_TYPE (range_copy), - &low_bound, &high_bound); + &low_bound, &high_bound, &stride); TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1; return static_range_type; } @@ -1966,6 +1984,15 @@ resolve_dynamic_type_internal (struct type *type, CORE_ADDR addr, prop = TYPE_DATA_LOCATION (resolved_type); if (dwarf2_evaluate_property (prop, addr, &value)) { + struct type *range_type = TYPE_INDEX_TYPE (resolved_type); + + /* Adjust the data location with the value of byte stride if set, which + can describe the separation between successive elements along the + dimension. */ + if (TYPE_BYTE_STRIDE (range_type) < 0) + value += (TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type)) + * TYPE_BYTE_STRIDE (range_type); + TYPE_DATA_LOCATION_ADDR (resolved_type) = value; TYPE_DATA_LOCATION_KIND (resolved_type) = PROP_CONST; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index d7be018..436edf8 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -669,6 +669,10 @@ struct main_type struct dynamic_prop high; + /* * Stride of range. */ + + struct dynamic_prop stride; + /* True if HIGH range bound contains the number of elements in the subrange. This affects how the final hight bound is computed. */ @@ -1219,6 +1223,15 @@ extern void allocate_gnat_aux_type (struct type *); TYPE_RANGE_DATA(range_type)->high.kind #define TYPE_LOW_BOUND_KIND(range_type) \ TYPE_RANGE_DATA(range_type)->low.kind +#define TYPE_BYTE_STRIDE(range_type) \ + TYPE_RANGE_DATA(range_type)->stride.data.const_val +#define TYPE_BYTE_STRIDE_BLOCK(range_type) \ + TYPE_RANGE_DATA(range_type)->stride.data.locexpr +#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \ + TYPE_RANGE_DATA(range_type)->stride.data.loclist +#define TYPE_BYTE_STRIDE_KIND(range_type) \ + TYPE_RANGE_DATA(range_type)->stride.kind + /* Attribute accessors for the type data location. */ #define TYPE_DATA_LOCATION(thistype) \ @@ -1250,6 +1263,9 @@ extern void allocate_gnat_aux_type (struct type *); TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \ TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) +#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \ + (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0) + #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \ (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) @@ -1718,6 +1734,7 @@ extern struct type *create_array_type_with_stride extern struct type *create_range_type (struct type *, struct type *, const struct dynamic_prop *, + const struct dynamic_prop *, const struct dynamic_prop *); extern struct type *create_array_type (struct type *, struct type *, diff --git a/gdb/valarith.c b/gdb/valarith.c index 2f3b58a..3d4595f 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -194,9 +194,21 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) struct type *array_type = check_typedef (value_type (array)); struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); unsigned int elt_size = TYPE_LENGTH (elt_type); - unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); + unsigned int elt_offs = longest_to_int (index - lowerbound); + LONGEST elt_stride = TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type)); struct value *v; + if (elt_stride > 0) + elt_offs *= elt_stride; + else if (elt_stride < 0) + { + int offs = (elt_offs + 1) * elt_stride; + + elt_offs = TYPE_LENGTH (array_type) + offs; + } + else + elt_offs *= elt_size; + if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) && elt_offs >= TYPE_LENGTH (array_type))) { -- 1.7.9.5