From patchwork Wed Jun 4 05:54:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 1286 Received: (qmail 27895 invoked by alias); 4 Jun 2014 05:54:43 -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 27797 invoked by uid 89); 4 Jun 2014 05:54:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Jun 2014 05:54:41 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 03 Jun 2014 22:54:39 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 03 Jun 2014 22:54:33 -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 s545sW9a020263; Wed, 4 Jun 2014 06:54:33 +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 s545sWGU006295; Wed, 4 Jun 2014 07:54:32 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s545sWHm006294; Wed, 4 Jun 2014 07:54:32 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: sanimir.agovic@intel.com, keven.boell@intel.com Subject: [PATCH 06/23] vla: reconstruct value to compute bounds of target type Date: Wed, 4 Jun 2014 07:54:09 +0200 Message-Id: <1401861266-6240-7-git-send-email-keven.boell@intel.com> In-Reply-To: <1401861266-6240-1-git-send-email-keven.boell@intel.com> References: <1401861266-6240-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. Change-Id: Ia8a25021c7cc206711ca6f359ae5566a367e3b3d Signed-off-by: Keven Boell --- gdb/c-valprint.c | 11 ++++++++++- gdb/typeprint.c | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index f4694b0..8c45276 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -538,7 +538,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/typeprint.c b/gdb/typeprint.c index b4ad431..b3c73a8 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -459,6 +459,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) {