From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3433 invoked by alias); 17 Dec 2013 12:18:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3362 invoked by uid 89); 17 Dec 2013 12:18:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Dec 2013 12:18:33 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 17 Dec 2013 04:18:31 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 17 Dec 2013 04:18:30 -0800 Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [172.28.50.125]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id rBHCITkC002241; Tue, 17 Dec 2013 12:18:29 GMT Received: from ulliclel004.iul.intel.com (ulliclel004.iul.intel.com [127.0.0.1]) by ulliclel004.iul.intel.com (8.13.8/8.12.8/MailSET/client) with ESMTP id rBHCISh1003909; Tue, 17 Dec 2013 13:18:28 +0100 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id rBHCIN3Z003908; Tue, 17 Dec 2013 13:18:23 +0100 From: Sanimir Agovic To: tromey@redhat.com, palves@redhat.com, xdje42@gmail.com Cc: gdb-patches@sourceware.org, keven.boell@intel.com Subject: [PATCH v4 04/13] vla: enable sizeof operator for indirection Date: Tue, 17 Dec 2013 12:18:00 -0000 Message-Id: <1387282678-3847-5-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1387282678-3847-1-git-send-email-sanimir.agovic@intel.com> References: <1387282678-3847-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00628.txt.bz2 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 (int) * n. 2013-10-18 Sanimir Agovic Keven Boell * eval.c (evaluate_subexp_for_sizeof): Create a indirect value and retrieve the dynamic type size. Change-Id: I3dbe85ebbc87ca93115a1952316b6436f750a16d --- gdb/eval.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/eval.c b/gdb/eval.c index a81e789..b3e45ca 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.8.3.1