This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3 06/13] vla: print "dynamic length" for unresolved dynamic bounds
- From: Sanimir Agovic <sanimir dot agovic at intel dot com>
- To: tromey at redhat dot com, palves at redhat dot com, xdje42 at gmail dot com
- Cc: gdb-patches at sourceware dot org, keven dot boell at intel dot com
- Date: Wed, 4 Dec 2013 15:19:37 +0100
- Subject: [PATCH v3 06/13] vla: print "dynamic length" for unresolved dynamic bounds
- Authentication-results: sourceware.org; auth=none
- References: <1386166785-28037-1-git-send-email-sanimir dot agovic at intel dot com>
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.
2013-08-30 Keven Boell <keven.boell@intel.com>
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.
Change-Id: Ic6a5fc08c8651ef18760bdacacc492ed44fe4af4
Signed-off-by: Sanimir Agovic <sanimir.agovic@intel.com>
---
gdb/c-typeprint.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 2757337..4acb2b0 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -689,7 +689,10 @@ 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)
+ 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 ? ")))" : "]"));
--
1.8.3.1