From patchwork Sun Dec 8 18:29:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36618 Received: (qmail 103448 invoked by alias); 8 Dec 2019 18:31:03 -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 101543 invoked by uid 89); 8 Dec 2019 18:30:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 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= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.187) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:13 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway32.websitewelcome.com (Postfix) with ESMTP id D03A4C24E for ; Sun, 8 Dec 2019 12:30:07 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JnipQtcqNtve1JniYrWr; 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=pX+XVgn11IeG0QpJel9jbWnwzYUeaEk095suS2hKvEo=; b=dN6GKhDkvPD7x2Wkd5sij0cQXY GnQqG55hMz2CQ7gb0/rpanWlR+u0Olw3IeQ4y075PwAJFDr14asYSJezVhFUj9oOrmmMmnhKzvUEr xE1cQcG3FQnWX7P8Ipg1Ql/4p; 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-M7; Sun, 08 Dec 2019 11:30:07 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 33/55] Simplify generic_val_print_func Date: Sun, 8 Dec 2019 11:29:36 -0700 Message-Id: <20191208182958.10181-34-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> This removes the call to val_print_scalar_formatted from generic_val_print_func, allowing generic_value_print to call the value-based variant instead. gdb/ChangeLog 2019-12-08 Tom Tromey * valprint.c (generic_val_print_func): Simplify. (generic_val_print, generic_value_print): Update. Change-Id: Id93d45b00c4be05e52e1ade15a7e33df206ac7f0 --- gdb/ChangeLog | 5 +++++ gdb/valprint.c | 41 +++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index c6de058fa23..5c25f98faf8 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -716,22 +716,16 @@ generic_val_print_func (struct type *type, { struct gdbarch *gdbarch = get_type_arch (type); - if (options->format) - { - val_print_scalar_formatted (type, embedded_offset, - original_value, options, 0, stream); - } - else - { - /* FIXME, we should consider, at least for ANSI C language, - eliminating the distinction made between FUNCs and POINTERs - to FUNCs. */ - fprintf_filtered (stream, "{"); - type_print (type, "", stream, -1); - fprintf_filtered (stream, "} "); - /* Try to print what function it points to, and its address. */ - print_address_demangle (options, gdbarch, address, stream, demangle); - } + gdb_assert (!options->format); + + /* FIXME, we should consider, at least for ANSI C language, + eliminating the distinction made between FUNCs and POINTERs to + FUNCs. */ + fprintf_filtered (stream, "{"); + type_print (type, "", stream, -1); + fprintf_filtered (stream, "} "); + /* Try to print what function it points to, and its address. */ + print_address_demangle (options, gdbarch, address, stream, demangle); } /* generic_val_print helper for TYPE_CODE_BOOL. */ @@ -945,8 +939,12 @@ generic_val_print (struct type *type, case TYPE_CODE_FUNC: case TYPE_CODE_METHOD: - generic_val_print_func (type, embedded_offset, address, stream, - original_value, options); + if (options->format) + val_print_scalar_formatted (type, embedded_offset, + original_value, options, 0, stream); + else + generic_val_print_func (type, embedded_offset, address, stream, + original_value, options); break; case TYPE_CODE_BOOL: @@ -1058,8 +1056,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, case TYPE_CODE_FUNC: case TYPE_CODE_METHOD: - generic_val_print_func (type, 0, value_address (val), stream, - val, options); + if (options->format) + value_print_scalar_formatted (val, options, 0, stream); + else + generic_val_print_func (type, 0, value_address (val), stream, + val, options); break; case TYPE_CODE_BOOL: