From patchwork Wed Sep 10 09:21:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 2724 Received: (qmail 29956 invoked by alias); 10 Sep 2014 09:22:16 -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 29728 invoked by uid 89); 10 Sep 2014 09:22:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 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; Wed, 10 Sep 2014 09:22:14 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 10 Sep 2014 02:22:12 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 10 Sep 2014 02:22:10 -0700 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [172.28.50.14]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s8A9M9ea008342; Wed, 10 Sep 2014 10:22:09 +0100 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [127.0.0.1]) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8) with ESMTP id s8A9MDqU020700; Wed, 10 Sep 2014 11:22:13 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s8A9MD26020699; Wed, 10 Sep 2014 11:22:13 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: sanimir.agovic@intel.com, Keven Boell Subject: [V3 04/21] vla: reconstruct value to compute bounds of target type Date: Wed, 10 Sep 2014 11:21:52 +0200 Message-Id: <1410340929-20653-5-git-send-email-keven.boell@intel.com> In-Reply-To: <1410340929-20653-1-git-send-email-keven.boell@intel.com> References: <1410340929-20653-1-git-send-email-keven.boell@intel.com> Printing a pointer to an array, gdb tries to print the target type including its bounds. To follow this semantic with vla, this patch re-constructs the value to resolve the bounds of the target type. 2014-05-28 Sanimir Agovic Keven Boell * typeprint.c (whatis_exp): Re-construct value to compute bounds of target type. * c-valprint.c (c_value_print): Re-construct value to compute bounds of target type. --- gdb/c-valprint.c | 11 ++++++++++- gdb/f-typeprint.c | 6 +++++- gdb/typeprint.c | 7 +++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 17963f0..955cca5 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -537,7 +537,16 @@ c_value_print (struct value *val, struct ui_file *stream, { /* normal case */ fprintf_filtered (stream, "("); - type_print (value_type (val), "", stream, -1); + if (is_dynamic_type (TYPE_TARGET_TYPE (type))) + { + struct value *v; + + v = value_ind (val); + v = value_addr (v); + type_print (value_type (v), "", stream, -1); + } + else + type_print (value_type (val), "", stream, -1); fprintf_filtered (stream, ") "); } } diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index be719c6..b97e736 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -85,7 +85,11 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream, /* For demangled function names, we have the arglist as part of the name, so don't print an additional pair of ()'s. */ - demangled_args = varstring[strlen (varstring) - 1] == ')'; + if (strlen (varstring) > 0) + demangled_args = varstring[strlen (varstring) - 1] == ')'; + else + demangled_args = 0; + f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0); } } diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 4d3358f..2f60ff5 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -457,6 +457,13 @@ whatis_exp (char *exp, int show) type = value_type (val); + if (TYPE_CODE (type) == TYPE_CODE_PTR) + if (is_dynamic_type (TYPE_TARGET_TYPE (type))) + { + val = value_addr (value_ind (val)); + type = value_type (val); + } + get_user_print_options (&opts); if (opts.objectprint) {