[V4,13/18] vla: reconstruct value to compute bounds of target type
Commit Message
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(-)
@@ -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, ") ");
}
}
@@ -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);
}
}
@@ -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)
{