From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1454 invoked by alias); 4 Dec 2013 14:21:57 -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 1429 invoked by uid 89); 4 Dec 2013 14:21:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,RDNS_NONE,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mga01.intel.com Received: from Unknown (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Dec 2013 14:20:54 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 04 Dec 2013 06:20:46 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 04 Dec 2013 06:20:35 -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 rB4EKUks021453; Wed, 4 Dec 2013 14:20:30 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 rB4EKTU5013368; Wed, 4 Dec 2013 15:20:29 +0100 Received: (from sagovic@localhost) by ulliclel004.iul.intel.com (8.13.8/8.13.1/Submit) id rB4EKND9013293; Wed, 4 Dec 2013 15:20: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 v3 06/13] vla: print "dynamic length" for unresolved dynamic bounds Date: Wed, 04 Dec 2013 14:21:00 -0000 Message-Id: <1386166785-28037-7-git-send-email-sanimir.agovic@intel.com> In-Reply-To: <1386166785-28037-1-git-send-email-sanimir.agovic@intel.com> References: <1386166785-28037-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00134.txt.bz2 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. Change-Id: Ic6a5fc08c8651ef18760bdacacc492ed44fe4af4 Signed-off-by: Sanimir Agovic --- gdb/c-typeprint.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 2757337..4acb2b0 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -689,7 +689,10 @@ 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) + 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 ? ")))" : "]")); -- 1.8.3.1