From patchwork Mon Apr 14 17:13:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 542 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 49564360075 for ; Mon, 14 Apr 2014 10:14:04 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id E584C1393127; Mon, 14 Apr 2014 10:14:03 -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 C0160136F763 for ; Mon, 14 Apr 2014 10:14:03 -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=tI6zqm/cX1QXPsht7hH+dtItvKCI2jB pYnSxomUgDl729eUo+YXIrdz1lha1dJG90slTsl0JuKMyUtrvHz+N2y+dy2Hr7Vh lwZ0URR5IKz+3QOFhi9z1f+UUQOI73Y5CrtUUOi5pBp1eujF1bTcolGbZa45woHj ylVF1IK/ptCw= 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=l/b/uRGiJEzP4bEGd5nWvcLHrR8=; b=jCbLx azjtg8Z38cq3DUxPil1uxYp1u3s25gC4HxnCN1dau80kjYdwXNO2HbbtQ3XriPfW dVfLK+2kDOfEL84MHV3hvdVzE0kSAKzT4OsGAjALhnkfvp17qGWBEgKahIe+3tsK dWhi4VLM3yazaf2py7b6GoKdJvqm3n1fh/4NHs= Received: (qmail 8020 invoked by alias); 14 Apr 2014 17:13:41 -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 7842 invoked by uid 89); 14 Apr 2014 17:13:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 14 Apr 2014 17:13:37 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 33BE21160DD; Mon, 14 Apr 2014 13:13:36 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id wyQB8kukW7J8; Mon, 14 Apr 2014 13:13:36 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id F2DCA1160DB; Mon, 14 Apr 2014 13:13:35 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 7A47FE02C0; Mon, 14 Apr 2014 10:13:41 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Sanimir Agovic Subject: [PATCH 05/12] vla: print "variable length" for unresolved dynamic bounds Date: Mon, 14 Apr 2014 10:13:09 -0700 Message-Id: <1397495596-25364-6-git-send-email-brobecker@adacore.com> In-Reply-To: <1397495596-25364-1-git-send-email-brobecker@adacore.com> References: <0377C58828D86C4588AEEC42FC3B85A71D8507B7@IRSMSX105.ger.corp.intel.com> <1397495596-25364-1-git-send-email-brobecker@adacore.com> X-DH-Original-To: gdb@patchwork.siddhesh.in From: Sanimir Agovic 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. gdb/ChangeLog: * 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. --- gdb/ChangeLog | 7 +++++++ gdb/c-typeprint.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 955db91..0630f1c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2014-04-14 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. + +2014-04-14 Sanimir Agovic + * ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value. (ada_template_to_fixed_record_type_1): Likewise. diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 4edc9ec..d910058 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 ? ")))" : "]"));