diff options
author | Sanimir Agovic <sanimir.agovic@intel.com> | 2013-11-14 09:55:52 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2014-04-14 09:16:30 -0700 |
commit | 1d42e4c4d85cb12ce07a5349b1b2e11dce2d077d (patch) | |
tree | 17e22305c49e8b67135d385d67fc079469536540 /gdb | |
parent | 9f1f738adae6b28c4f7db7e3607b4c224f1f7612 (diff) | |
download | gdb-1d42e4c4d85cb12ce07a5349b1b2e11dce2d077d.zip gdb-1d42e4c4d85cb12ce07a5349b1b2e11dce2d077d.tar.gz gdb-1d42e4c4d85cb12ce07a5349b1b2e11dce2d077d.tar.bz2 |
vla: print "variable length" for unresolved dynamic bounds
1| void foo (size_t n) {
2| int vla[n];
3| }
Given the following expression
(gdb) ptype &vla
Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus
does not resolve the bounds information and misinterprets the high
bound as a constant. The current output is:
type = int (*)[1289346]
this patch deals with this case and prints:
type = int (*)[variable length]
instead.
gdb/ChangeLog:
* 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
length.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/c-typeprint.c | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 955db91..0630f1c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 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 + length. + +2014-04-14 Sanimir Agovic <sanimir.agovic@intel.com> + * ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value. (ada_template_to_fixed_record_type_1): Likewise. diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 4edc9ec..d910058 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -689,7 +689,11 @@ c_type_print_varspec_suffix (struct type *type, fprintf_filtered (stream, (is_vector ? " __attribute__ ((vector_size(" : "[")); - if (get_array_bounds (type, &low_bound, &high_bound)) + /* Bounds are not yet resolved, print a bounds placeholder instead. */ + if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR + || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST) + fprintf_filtered (stream, "variable length"); + else if (get_array_bounds (type, &low_bound, &high_bound)) fprintf_filtered (stream, "%s", plongest (high_bound - low_bound + 1)); fprintf_filtered (stream, (is_vector ? ")))" : "]")); |