vla: print "variable length" for unresolved dynamic bounds
authorSanimir Agovic <sanimir.agovic@intel.com>
Thu, 14 Nov 2013 09:55:52 +0000 (09:55 +0000)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 14 Apr 2014 16:16:30 +0000 (09:16 -0700)
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.

gdb/ChangeLog
gdb/c-typeprint.c

index 955db91ca5869ec2938e5d09e9b6e46b2e0ead23..0630f1c749a3fa4bf6406e85c1e229567b83b686 100644 (file)
@@ -1,3 +1,10 @@
+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
index 4edc9ec3587913b16c3459245a8ecb81b15a796f..d91005850c50d92cfdadfe36e10fe5772ea92257 100644 (file)
@@ -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 ? ")))" : "]"));
This page took 0.028293 seconds and 4 git commands to generate.