[V4,13/18] vla: reconstruct value to compute bounds of target type

Message ID 1421243390-24015-14-git-send-email-keven.boell@intel.com
State New, archived
Headers

Commit Message

Keven Boell Jan. 14, 2015, 1:49 p.m. UTC
  Printing a pointer to an array, gdb tries to print the
target type including its bounds. To follow this
semantic with vla, this patch re-constructs the value to
resolve the bounds of the target type.

2014-05-28  Sanimir Agovic  <sanimir.agovic@intel.com>
            Keven Boell  <keven.boell@intel.com>

	* typeprint.c (whatis_exp): Re-construct value to
	compute bounds of target type.
	* c-valprint.c (c_value_print): Re-construct value
	to compute bounds of target type.



Signed-off-by: Keven Boell <keven.boell@intel.com>
---
 gdb/c-valprint.c  |   11 ++++++++++-
 gdb/f-typeprint.c |    6 +++++-
 gdb/typeprint.c   |    7 +++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 8d8b744..565730e 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -537,7 +537,16 @@  c_value_print (struct value *val, struct ui_file *stream,
 	{
 	  /* normal case */
 	  fprintf_filtered (stream, "(");
-	  type_print (value_type (val), "", stream, -1);
+	  if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
+	    {
+	      struct value *v;
+
+	      v = value_ind (val);
+	      v = value_addr (v);
+	      type_print (value_type (v), "", stream, -1);
+	    }
+	  else
+	    type_print (value_type (val), "", stream, -1);
 	  fprintf_filtered (stream, ") ");
 	}
     }
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 5754cd4..5d795f9 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -85,7 +85,11 @@  f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
       /* For demangled function names, we have the arglist as part of the name,
          so don't print an additional pair of ()'s.  */
 
-      demangled_args = varstring[strlen (varstring) - 1] == ')'; 
+      if (strlen (varstring) > 0)
+        demangled_args = varstring[strlen (varstring) - 1] == ')';
+      else
+        demangled_args = 0;
+
       f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0);
    }
 }
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index d39e2e3..b6ced51 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -456,6 +456,13 @@  whatis_exp (char *exp, int show)
 
   type = value_type (val);
 
+  if (TYPE_CODE (type) == TYPE_CODE_PTR)
+    if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
+      {
+	val = value_addr (value_ind (val));
+	type = value_type (val);
+      }
+
   get_user_print_options (&opts);
   if (opts.objectprint)
     {