From patchwork Thu Apr 10 12:40:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Agovic, Sanimir" X-Patchwork-Id: 479 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id 3008436005B for ; Thu, 10 Apr 2014 05:47:17 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id DF91B1152423; Thu, 10 Apr 2014 05:47:16 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id B50881134523 for ; Thu, 10 Apr 2014 05:47:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=evcfU+YrAx4SR7nbnmihIh6k8SDbacO cZ/xXe/gW8+JGkD4Rnu4Cm9GRbSgKYKnlsSf7IdOZewbQ7EZKCjsCcTMQ4M6oryH p70xwoEiFAy4cNAJXCOr2jGawnvTMDEk5kym/nW1M6jPDduYT4165vSg6oRcKt6j 7pTIUlB+DvkE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=8D8h3UZnBnXlL0Pq5PlEYY0BALg=; b=turb2 pK2mxLVOe6POgwmlwi7mSqmjME5wX79tG/ae86TAowh6lvNyfHbnn96BgDl776AV RVVL/4k8f7MbY6X/pYaI9L5HkWBDo76clkJeBQqZuYrYMley5UOx0jVpFNX17wQx dNso5sS9CQPc2a75qhuJe4Y8cVKHRHY7npIR+w= Received: (qmail 29686 invoked by alias); 10 Apr 2014 12:47:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 29673 invoked by uid 89); 10 Apr 2014 12:47:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Apr 2014 12:47:13 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 10 Apr 2014 05:42:27 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 10 Apr 2014 05:46:52 -0700 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 s3ACkQlu010080; Thu, 10 Apr 2014 13:46:31 +0100 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 s3ACjZdp026763; Thu, 10 Apr 2014 14:45:55 +0200 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id s3ACjUpQ026762; Thu, 10 Apr 2014 14:45:30 +0200 From: Sanimir Agovic To: brobecker@adacore.com Cc: gdb-patches@sourceware.org, tromey@redhat.com Subject: [PATCH v6 07/15] vla: print "variable length" for unresolved dynamic bounds Date: Thu, 10 Apr 2014 14:40:09 +0200 Message-Id: <1397133617-26681-8-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> References: <1397133617-26681-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in 1| void foo (size_t n) { 2| int vla[n]; 3| } Given the following expression (gdb) ptype &vla Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus does not resolve the bounds information and misinterprets the high bound as a constant. The current output is: type = int (*)[1289346] this patch deals with this case and prints: type = int (*)[variable length] instead. 2013-08-30 Keven Boell Sanimir Agovic * c-typeprint.c (c_type_print_varspec_suffix): Added check for not yet resolved high bound. If unresolved, print "variable length" string to the console instead of random length. Signed-off-by: Sanimir Agovic --- gdb/c-typeprint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 2757337..739d770 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -689,7 +689,11 @@ c_type_print_varspec_suffix (struct type *type, fprintf_filtered (stream, (is_vector ? " __attribute__ ((vector_size(" : "[")); - if (get_array_bounds (type, &low_bound, &high_bound)) + /* Bounds are not yet resolved, print a bounds placeholder instead. */ + if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR + || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST) + fprintf_filtered (stream, "variable length"); + else if (get_array_bounds (type, &low_bound, &high_bound)) fprintf_filtered (stream, "%s", plongest (high_bound - low_bound + 1)); fprintf_filtered (stream, (is_vector ? ")))" : "]"));