diff mbox

[V3,04/21] vla: reconstruct value to compute bounds of target type

Message ID 1410340929-20653-5-git-send-email-keven.boell@intel.com
State New
Headers show

Commit Message

Keven Boell Sept. 10, 2014, 9:21 a.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.


---
 gdb/c-valprint.c  |   11 ++++++++++-
 gdb/f-typeprint.c |    6 +++++-
 gdb/typeprint.c   |    7 +++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 17963f0..955cca5 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 be719c6..b97e736 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 4d3358f..2f60ff5 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -457,6 +457,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)
     {