This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 04/10] vla: enable sizeof operator for indirection
- From: Sanimir Agovic <sanimir dot agovic at intel dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 21 Oct 2013 16:40:18 +0200
- Subject: [PATCH 04/10] vla: enable sizeof operator for indirection
- Authentication-results: sourceware.org; auth=none
- References: <1382366424-21010-1-git-send-email-sanimir dot agovic at intel dot com>
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 N.
2013-10-18 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* eval.c (evaluate_subexp_for_sizeof): Create a indirect value and
retrieve the dynamic type size.
Change-Id: I0251a9bece82b221f936f369dcfe9195099b6ee2
---
gdb/eval.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 9e4afa3..ab3cb95 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -3027,6 +3027,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:
--
1.7.0.7