From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fty9EbkZvGpuqRkAWB0awg (envelope-from ) for ; Tue, 29 Sep 2026 16:04:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1790712249; bh=25pCIhmeC9vGZq8Bcnrr8RmMTvgkfcLTl12BkiqWTJA=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CXHvLJ430TMWnPi3dtFTdvr6Vrar6rxo7OZdXdsMJq1Cl4h4zGiM3DhlcVrjb9JTJ aIw50fL2q23d8sMSDXFzKRqFOw9Eq/iP8+poxI5gyJwWb3Wzeh7xsM3a2R5K27o3AU z5wy/Y2r/pN/mtF1kfG2bbJ2aoOIjet3FwC7IXc0= Received: by simark.ca (Postfix, from userid 112) id 330DE1E01F; Tue, 29 Sep 2026 16:04:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=nKmr5iiO; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3219F1E01F for ; Tue, 29 Sep 2026 16:04:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11C7B4B99F4F for ; Tue, 29 Sep 2026 20:04:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11C7B4B99F4F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=nKmr5iiO Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 0514C4B9DB76 for ; Tue, 29 Sep 2026 20:03:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0514C4B9DB76 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0514C4B9DB76 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790712223; cv=none; b=ap0uu2najUtXHlDo3y4gqM/TD6UK8OAV0CVBxpZJXHjijCSh2BMAAMTHp2Ta3sPNE52eyczO0alb767gegYeNC5RUTvG3BmCvFJM/hnGpIUTBelkG9YYM5PtzBZ+aaiP5lRjyX4Sbf9F104G2EbXncNbLv1IYG2J+r0xLzRJXdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790712223; c=relaxed/simple; bh=25pCIhmeC9vGZq8Bcnrr8RmMTvgkfcLTl12BkiqWTJA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=p6VrDBuTSv7m0IWx9mHwM4yj3tWQdwkZhb6Cg0ic6u2thQ4mlsn+Hd+MG9wbByMVBeDYqSMyJqrmwRdb0MPZ5eUIhvOXssyqRZDIQLgKo+JZdsT/yD2qbRaGCmB09ujKt1zwUIdUBeewhDR+w3Iag1pSF63vMqiA6mTM9j01Bus= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=nKmr5iiO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0514C4B9DB76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1790712222; bh=25pCIhmeC9vGZq8Bcnrr8RmMTvgkfcLTl12BkiqWTJA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=nKmr5iiOG9YaXn3xZsOME1LTYfmT9NBhvNUbAewXpoD69ygIpFV/2MugYUy9kJSqv s9HeTVOIhDak74/jqErlHUOpvYPk7SzMoeCw3GjZkim5Ipn+s3Nm4nPgkqkC4YyVAt 11q60V/IjZHqcgCis61k1keydXocBQHhrlLilHV8= Received: by simark.ca (Postfix) id 890151E01F; Tue, 29 Sep 2026 16:03:42 -0400 (EDT) Message-ID: <867a66f7-edca-4fbd-8477-f558b8c41f09@simark.ca> Date: Tue, 29 Sep 2026 16:03:42 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fix formatted print of functions To: Tom Tromey , gdb-patches@sourceware.org References: <20260929173704.2866399-1-tromey@adacore.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20260929173704.2866399-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 9/29/26 1:37 PM, Tom Tromey wrote: > A user noticed that formatted printing of functions is strange. That > is, printing a function normally does what you'd expect, but "print/d" > or "print/x" will, bizarrely, instead print the value of the first > byte of the function's body: > > (gdb) print main > $1 = {} 0x393c20
> (gdb) print/x main > $2 = 0x41 > > This doesn't seem useful or intuitive to me. > > This patch changes gdb to instead simply print the function pointer > using the specified format. > > Regression tested on x86-64 Fedora 43. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34685 > --- > gdb/testsuite/gdb.base/printcmds.exp | 7 +++++++ > gdb/testsuite/gdb.cp/printmethod.exp | 11 ++++++++++- > gdb/valprint.c | 8 ++++++++ > 3 files changed, 25 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp > index 9de1bcdd1a3..940622abb76 100644 > --- a/gdb/testsuite/gdb.base/printcmds.exp > +++ b/gdb/testsuite/gdb.base/printcmds.exp > @@ -1176,6 +1176,13 @@ proc test_printf_convenience_var {prefix} { > } > } > > +# Test formatted print with a function. See PR gdb/34685. > +proc test_function_print {} { > + set value [get_var_address main] > + gdb_test "print/x main" " = $value" > + gdb_test "print/d main" " = [expr {$value}]" > +} This proc is never called. > + > clean_restart > > gdb_test "print \$pc" "No registers\\." > diff --git a/gdb/testsuite/gdb.cp/printmethod.exp b/gdb/testsuite/gdb.cp/printmethod.exp > index fdc1c91bf23..e19646b0366 100644 > --- a/gdb/testsuite/gdb.cp/printmethod.exp > +++ b/gdb/testsuite/gdb.cp/printmethod.exp > @@ -49,4 +49,13 @@ gdb_test "print theA->nonvirt" \ > "${::valnum_re} = {void \\(A \\* const\\)} $hex " \ > "print nonvirtual method." > > -gdb_exit > +proc test_formatted {exp} { > + set out [get_valueof "" $exp ""] > + regexp -- [subst_vars {^.* ($::hex) .*$}] $out ignore value > + gdb_test "print/x $exp = $value" > + gdb_test "print/d $exp" " = [expr {$value}]" The quotes are wrong on the first gdb_test. Simon