From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id A547E3858415 for ; Sat, 5 Feb 2022 17:39:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A547E3858415 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 074AB1004044E for ; Sat, 5 Feb 2022 17:39:09 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id GP1gnW8Hh2s5dGP1gnBrpe; Sat, 05 Feb 2022 17:39:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=BOh2EHcG c=1 sm=1 tr=0 ts=61feb63c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=oGFeUVbbRNcA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=vdIMP8WJOF5emipNDXYA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=SrE57ecyDNI1oL6zsmdghJwCbinU9ebQ+B7aitDwHE4=; b=ZWN+yudRhuJttQC111q9w6eDoo fFXPeweekQjOHZUICQZjzh6PUGA3TpFuA+7GxD60A9v+cO9yhOhot5DdtJvljgTUr/CC/UK7VrRF4 yS9EGpph9JhYNsw0gTkDc7kUK; Received: from 75-166-128-165.hlrn.qwest.net ([75.166.128.165]:40790 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nGP1g-000c3s-26; Sat, 05 Feb 2022 10:39:08 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Merge do_val_print and common_val_print Date: Sat, 5 Feb 2022 10:39:06 -0700 Message-Id: <20220205173906.1902537-1-tom@tromey.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.128.165 X-Source-L: No X-Exim-ID: 1nGP1g-000c3s-26 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-128-165.hlrn.qwest.net (prentzel.Home) [75.166.128.165]:40790 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Feb 2022 17:39:11 -0000 The only caller of do_val_print just does a small bit of work before the call. This patch merges the two functions, and removes an unnecessary local variable, making gdb a bit simpler. --- gdb/valprint.c | 56 +++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index 82abcb41734..25e4a8dc8e1 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -989,16 +989,27 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, } } -/* Helper function for val_print and common_val_print that does the - work. Arguments are as to val_print, but FULL_VALUE, if given, is - the value to be printed. */ +/* Print using the given LANGUAGE the value VAL onto stream STREAM according + to OPTIONS. -static void -do_val_print (struct value *value, struct ui_file *stream, int recurse, - const struct value_print_options *options, - const struct language_defn *language) + This is a preferable interface to val_print, above, because it uses + GDB's value mechanism. */ + +void +common_val_print (struct value *value, struct ui_file *stream, int recurse, + const struct value_print_options *options, + const struct language_defn *language) { - int ret = 0; + if (language->la_language == language_ada) + /* The value might have a dynamic type, which would cause trouble + below when trying to extract the value contents (since the value + size is determined from the type size which is unknown). So + get a fixed representation of our value. */ + value = ada_to_fixed_value (value); + + if (value_lazy (value)) + value_fetch_lazy (value); + struct value_print_options local_opts = *options; struct type *type = value_type (value); struct type *real_type = check_typedef (type); @@ -1024,9 +1035,8 @@ do_val_print (struct value *value, struct ui_file *stream, int recurse, if (!options->raw) { - ret = apply_ext_lang_val_pretty_printer (value, stream, recurse, options, - language); - if (ret) + if (apply_ext_lang_val_pretty_printer (value, stream, recurse, options, + language)) return; } @@ -1127,30 +1137,6 @@ value_check_printable (struct value *val, struct ui_file *stream, return 1; } -/* Print using the given LANGUAGE the value VAL onto stream STREAM according - to OPTIONS. - - This is a preferable interface to val_print, above, because it uses - GDB's value mechanism. */ - -void -common_val_print (struct value *val, struct ui_file *stream, int recurse, - const struct value_print_options *options, - const struct language_defn *language) -{ - if (language->la_language == language_ada) - /* The value might have a dynamic type, which would cause trouble - below when trying to extract the value contents (since the value - size is determined from the type size which is unknown). So - get a fixed representation of our value. */ - val = ada_to_fixed_value (val); - - if (value_lazy (val)) - value_fetch_lazy (val); - - do_val_print (val, stream, recurse, options, language); -} - /* See valprint.h. */ void -- 2.31.1