From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11924 invoked by alias); 21 Oct 2013 14:40:41 -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 11801 invoked by uid 89); 21 Oct 2013 14:40:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Oct 2013 14:40:40 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 21 Oct 2013 07:40:36 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by AZSMGA002.ch.intel.com with ESMTP; 21 Oct 2013 07:40:35 -0700 Received: from ulliclel001.iul.intel.com (ulliclel001.iul.intel.com [172.28.50.199]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id r9LEeXQ9030718 for ; Mon, 21 Oct 2013 15:40:34 +0100 Received: from ulliclel001.iul.intel.com (localhost [127.0.0.1]) by ulliclel001.iul.intel.com (8.14.4/8.12.8/MailSET/client) with ESMTP id r9LEeXx0021120 for ; Mon, 21 Oct 2013 16:40:33 +0200 Received: (from sagovic@localhost) by ulliclel001.iul.intel.com (8.14.4/8.12.8/MailSET/Submit) id r9LEeWDU021119 for gdb-patches@sourceware.org; Mon, 21 Oct 2013 16:40:32 +0200 From: Sanimir Agovic To: gdb-patches@sourceware.org Subject: [PATCH 04/10] vla: enable sizeof operator for indirection Date: Mon, 21 Oct 2013 14:40:00 -0000 Message-Id: <1382366424-21010-5-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1382366424-21010-1-git-send-email-sanimir.agovic@intel.com> References: <1382366424-21010-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00634.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 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: 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