Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Sanimir Agovic <sanimir.agovic@intel.com>
Subject: [PATCH 06/12] vla: support for DW_AT_count
Date: Mon, 14 Apr 2014 17:13:00 -0000	[thread overview]
Message-ID: <1397495596-25364-7-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <1397495596-25364-1-git-send-email-brobecker@adacore.com>

From: Sanimir Agovic <sanimir.agovic@intel.com>

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  <sanimir.agovic@intel.com>
 
+	* 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  <sanimir.agovic@intel.com>
+
 	* 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;
-- 
1.8.3.2


  reply	other threads:[~2014-04-14 17:13 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-10 12:42 [PATCH v6 00/15] Please have a final look Sanimir Agovic
2014-04-10 12:42 ` [PATCH v6 01/15] refactoring: rename create_range_type to create_static_range_type Sanimir Agovic
2014-04-10 12:43 ` [PATCH v6 02/15] vla: introduce new bound type abstraction adapt uses Sanimir Agovic
2014-04-10 12:44 ` [PATCH v6 03/15] type: add c99 variable length array support Sanimir Agovic
2014-04-10 14:21   ` Joel Brobecker
2014-04-10 12:44 ` [PATCH v6 04/15] vla: enable sizeof operator to work with variable length arrays Sanimir Agovic
2014-04-10 12:45 ` [PATCH v6 05/15] vla: enable sizeof operator for indirection Sanimir Agovic
2014-04-10 12:46 ` [PATCH v6 06/15] vla: update type from newly created value Sanimir Agovic
2014-04-10 12:47 ` [PATCH v6 07/15] vla: print "variable length" for unresolved dynamic bounds Sanimir Agovic
2014-04-10 12:48 ` [PATCH v6 08/15] vla: support for DW_AT_count Sanimir Agovic
2014-04-10 12:48 ` [PATCH v6 09/15] vla: resolve dynamic bounds if value contents is a constant byte-sequence Sanimir Agovic
2014-04-10 14:22   ` Joel Brobecker
2014-04-10 12:49 ` [PATCH v6 10/15] vla: evaluate operand of sizeof if its type is a vla Sanimir Agovic
2014-04-10 14:31   ` Joel Brobecker
2014-04-10 12:49 ` [PATCH v6 11/15] test: cover subranges with present DW_AT_count attribute Sanimir Agovic
2014-04-10 12:50 ` [PATCH v6 12/15] test: multi-dimensional c99 vla Sanimir Agovic
2014-04-10 12:51 ` [PATCH v6 13/15] test: evaluate pointers to C99 vla correctly Sanimir Agovic
2014-04-10 12:52 ` [PATCH v6 14/15] test: basic c99 vla tests for C primitives Sanimir Agovic
2014-04-10 12:53 ` [PATCH v6 15/15] test: add mi vla test Sanimir Agovic
2014-04-10 14:39 ` [PATCH v6 00/15] Please have a final look Joel Brobecker
2014-04-10 14:46   ` Joel Brobecker
2014-04-22 15:33     ` Agovic, Sanimir
2014-04-22 16:58       ` Eli Zaretskii
2014-04-11 12:50   ` Agovic, Sanimir
2014-04-11 20:03     ` Keith Seitz
2014-04-11 20:27       ` Joel Brobecker
2014-04-11 20:33         ` Keith Seitz
2014-04-11 21:13           ` Joel Brobecker
2014-04-11 21:19             ` Keith Seitz
2014-04-11 22:33             ` Joel Brobecker
2014-04-14  8:34               ` Agovic, Sanimir
2014-04-14 17:13                 ` [vla v7 pushed] " Joel Brobecker
2014-04-14 17:13                   ` Joel Brobecker [this message]
2014-04-14 17:13                   ` [PATCH 08/12] vla: evaluate operand of sizeof if its type is a vla Joel Brobecker
2014-04-14 17:13                   ` [PATCH 04/12] vla: update type from newly created value Joel Brobecker
2014-04-14 17:13                   ` [PATCH 07/12] vla: resolve dynamic bounds if value contents is a constant byte-sequence Joel Brobecker
2014-04-14 17:13                   ` [PATCH 01/12] type: add c99 variable length array support Joel Brobecker
2014-04-18 19:06                     ` Joel Brobecker
2014-04-14 17:13                   ` [PATCH 02/12] vla: enable sizeof operator to work with variable length arrays Joel Brobecker
2014-04-14 17:13                   ` [PATCH 03/12] vla: enable sizeof operator for indirection Joel Brobecker
2014-04-14 17:13                   ` [PATCH 05/12] vla: print "variable length" for unresolved dynamic bounds Joel Brobecker
2014-04-14 17:14                   ` [PATCH 12/12] test: add mi vla test Joel Brobecker
2014-04-14 17:14                   ` [PATCH 09/12] test: cover subranges with present DW_AT_count attribute Joel Brobecker
2014-04-14 17:14                   ` [PATCH 11/12] test: basic c99 vla tests for C primitives Joel Brobecker
2014-04-14 17:14                   ` [PATCH 10/12] test: evaluate pointers to C99 vla correctly Joel Brobecker
2014-04-14 17:36                   ` [vla v7 pushed] Re: [PATCH v6 00/15] Please have a final look Agovic, Sanimir

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397495596-25364-7-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sanimir.agovic@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox