aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorSanimir Agovic <sanimir.agovic@intel.com>2013-10-12 12:36:16 +0100
committerJoel Brobecker <brobecker@adacore.com>2014-04-14 09:14:11 -0700
commit3c8452d46ac23d455c30438d0885a738e02b56e1 (patch)
treeee4e5f86ade80bff6748d6f4a7d67b51511b55ac /gdb/eval.c
parent4ad88275f81a586e32e86351cc415a97d58ef448 (diff)
downloadgdb-3c8452d46ac23d455c30438d0885a738e02b56e1.zip
gdb-3c8452d46ac23d455c30438d0885a738e02b56e1.tar.gz
gdb-3c8452d46ac23d455c30438d0885a738e02b56e1.tar.bz2
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. gdb/ChangeLog: * 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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 85523cd..22392eb 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -3026,7 +3026,9 @@ 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 = TYPE_TARGET_TYPE (type);
- break;
+ if (is_dynamic_type (type))
+ type = value_type (value_ind (val));
+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
case UNOP_MEMVAL:
(*pos) += 3;