From patchwork Sun Dec 8 18:29:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36607 Received: (qmail 102033 invoked by alias); 8 Dec 2019 18:30:35 -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 101258 invoked by uid 89); 8 Dec 2019 18:30:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1843, H*r:esmtpa, HX-Spam-Relays-External:esmtpa, H*RU:esmtpa X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.54.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:13 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id E322A400C57AF for ; Sun, 8 Dec 2019 11:19:52 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JniNEmTOdBHe1JniXAEu; Sun, 08 Dec 2019 12:30:07 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=q90PmZymd2c36+EFoOjWKD2bE2AgXL5rCjQRYjeN6ac=; b=sriOHyLLkJ9lBKJFUcaBJLnlX+ B9Ah/9k+8KpGhs7CK1vvk4JTvPpeiOJcfEXhJcd1IVPHhftjX2TdRKTG6mqQsm1/JbqBzYtAUOJe5 LnZS8OxANZsj5yU97aYMRcF52; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:53624 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1ie1Jn-0045Im-4L; Sun, 08 Dec 2019 11:30:07 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 30/55] Introduce generic_value_print_ptr Date: Sun, 8 Dec 2019 11:29:33 -0700 Message-Id: <20191208182958.10181-31-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> This introduces generic_value_print_ptr, a value-based analogue of generic_val_print_ptr, and changes generic_value_print to use it. gdb/ChangeLog 2019-12-08 Tom Tromey * valprint.c (generic_value_print): Call generic_value_print_ptr. * valprint.c (generic_value_print_ptr): New function. Change-Id: I733b2bb5a074dd98bdb4cc1d60ae9b166532d15d --- gdb/ChangeLog | 5 +++++ gdb/valprint.c | 26 ++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index 562a2acdda1..980dd3b024e 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -488,6 +488,26 @@ generic_val_print_ptr (struct type *type, } } +/* generic_value_print helper for TYPE_CODE_PTR. */ + +static void +generic_value_print_ptr (struct value *val, struct ui_file *stream, + const struct value_print_options *options) +{ + + if (options->format && options->format != 's') + value_print_scalar_formatted (val, options, 0, stream); + else + { + struct type *type = check_typedef (value_type (val)); + struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); + const gdb_byte *valaddr = value_contents_for_printing (val); + CORE_ADDR addr = unpack_pointer (type, valaddr); + + print_unpacked_pointer (type, elttype, addr, stream, options); + } +} + /* generic_val_print helper for TYPE_CODE_MEMBERPTR. */ @@ -1026,13 +1046,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_MEMBERPTR: - generic_val_print_memberptr (type, 0, stream, - val, options); + value_print_scalar_formatted (val, options, 0, stream); break; case TYPE_CODE_PTR: - generic_val_print_ptr (type, 0, stream, - val, options); + generic_value_print_ptr (val, stream, options); break; case TYPE_CODE_REF: