From patchwork Wed Jan 14 13:49:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 4678 Received: (qmail 27522 invoked by alias); 14 Jan 2015 13:50:17 -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 26990 invoked by uid 89); 14 Jan 2015 13:50:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Jan 2015 13:50:05 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 14 Jan 2015 05:44:34 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 14 Jan 2015 05:49:48 -0800 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 t0EDnlp6007067; Wed, 14 Jan 2015 13:49:47 GMT 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 t0EDnuIo024099; Wed, 14 Jan 2015 14:49:56 +0100 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id t0EDnu7N024098; Wed, 14 Jan 2015 14:49:56 +0100 From: Keven Boell To: gdb-patches@sourceware.org Cc: Keven Boell Subject: [V4 13/18] vla: reconstruct value to compute bounds of target type Date: Wed, 14 Jan 2015 14:49:45 +0100 Message-Id: <1421243390-24015-14-git-send-email-keven.boell@intel.com> In-Reply-To: <1421243390-24015-1-git-send-email-keven.boell@intel.com> References: <1421243390-24015-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. Signed-off-by: Keven Boell --- 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 8d8b744..565730e 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 5754cd4..5d795f9 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 d39e2e3..b6ced51 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -456,6 +456,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) {