aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorSanimir Agovic <sanimir.agovic@intel.com>2013-10-12 12:36:16 +0100
committerSanimir Agovic <sanimir.agovic@intel.com>2014-04-11 13:43:50 +0100
commit04b19544ef6a97b62b2cc4a3170b900e046ab185 (patch)
tree5fd7230a68abe5ef3f36b1411997588b202bd322 /gdb/eval.c
parent26cb189f8b46dbe7b2d485525329a8919005ca8a (diff)
vla: enable sizeof operator for indirection
This patch enables the sizeof operator for indirections: 1| void foo (size_t n) { 2| int vla[n]; 3| int *vla_ptr = &vla; 4| } (gdb) p sizeof(*vla_ptr) yields sizeof (size_t) * n. * eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect value and retrieve the dynamic type size.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 26454f60a2..1f4c8697e0 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -3026,6 +3026,8 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
error (_("Attempt to take contents of a non-pointer value."));
type = check_typedef (TYPE_TARGET_TYPE (type));
+ if (is_dynamic_type (type))
+ type = value_type (value_ind (val));
return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
case UNOP_MEMVAL: