From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id HcfnI+rq92gtAAIAWB0awg (envelope-from ) for ; Tue, 21 Oct 2025 16:19:54 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=VxVg0wRu; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 830801E0BC; Tue, 21 Oct 2025 16:19:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 9DBA11E057 for ; Tue, 21 Oct 2025 16:19:53 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 092A23858C25 for ; Tue, 21 Oct 2025 20:19:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 092A23858C25 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=VxVg0wRu Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id D28033858C56 for ; Tue, 21 Oct 2025 20:19:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D28033858C56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D28033858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761077953; cv=none; b=I8wIbYJEVh3eFpTTpwhFE4WRMeLph2knGtMVxNT0l4WkIL3N2Bc33/QlJJZPoSPP/5ZcXWusztqWkkR7/wzX+pmHbhUJGEqo6e0HEZ1IlJf85oBPZSMshN89Tul5p36er//mG9mpZJi6k0Blw/tajCLIMSWGO4jmQCc1dzl32NI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761077953; c=relaxed/simple; bh=uyMuVenDmhVJ2/z0YVKdl/J3QKe7nz+1kZNhFD5Ortk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k17nmA4Oey1nKc/AFjIe+gWYwQl/gtLEdAgEQ2tgCO+7cDch+J87ITuD+vWSfYiLED6FWVOTe9jSwwxSEmo2jfEJQ7kpOIxniGBz8A54IHfkabetakQfuLnXaXsz9NeBeD2UR5Dl6ta2jeOTwu5+QbFBBxO1DQ4fi66ZXD5MRN8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D28033858C56 Received: from eig-obgw-5001b.ext.cloudfilter.net ([10.0.29.181]) by cmsmtp with ESMTPS id BGt0viZ4Hv724BIp7vcQlP; Tue, 21 Oct 2025 20:19:13 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id BIp5v1ujkzw4nBIp6vzn0q; Tue, 21 Oct 2025 20:19:12 +0000 X-Authority-Analysis: v=2.4 cv=Y434sgeN c=1 sm=1 tr=0 ts=68f7eac1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=x6icFKpwvdMA:10 a=ItBw4LHWJt0A:10 a=20KFwNOVAAAA:8 a=M_fT1jFzpe3xfKXGHWcA:9 a=VS4QxaUSPT0UtbFnIvSC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To: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=2u8K2URepoyRauujpHe0N2WO62/vlRcDVLe9pH9lsr4=; b=VxVg0wRu0JZ6DPycRbhiVjY54t 7Tpms/Ep9HcBaCYheMCZLLJpPdOAbZRcg4w6tF6vjPqO4Y+T0aa1R+dUSr6T9nkkq4KC89SnZPHX5 o2ZApU0CWYFDVv7LroiM6LEnS; Received: from 97-122-110-68.hlrn.qwest.net ([97.122.110.68]:54944 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vBIp5-00000002cIF-25Cc; Tue, 21 Oct 2025 14:19:11 -0600 From: Tom Tromey To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2] infcall: Add support for integer literals as reference function paramters In-Reply-To: (Keith Seitz's message of "Mon, 20 Oct 2025 12:36:09 -0700") References: <92575c2eb6805095b41ebbe62ba99b81e4e5dd63.1760629738.git.keiths@redhat.com> X-Attribution: Tom Date: Tue, 21 Oct 2025 14:19:10 -0600 Message-ID: <877bwom2ip.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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: 97.122.110.68 X-Source-L: No X-Exim-ID: 1vBIp5-00000002cIF-25Cc X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-68.hlrn.qwest.net (bapiya) [97.122.110.68]:54944 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfAFE7w5NqKA5+Bb1sVLHG0TBica4OFNwpsfkRvhSGDI1w5a6u6B8zwDr1P50iLFAVzp18UUZL7jxvAIv7+fOtlpIVtlPiFX8N9XotYHrTggZGsKYWDiN kw2mRM8oCMFNz7bdDLYDBeD9LzHl44gc7Dr6TCfCVPVciAZIGXh0ulJ9tz37eCtgs6GwchYFtkQ7kbT8hGcaXZjfUvl6ihuJ83o= 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 >>>>> "Keith" == Keith Seitz writes: Keith> This patch attempts to mitigate the shortcomings of passing literals Keith> to inferior function calls requiring references. The specific use case here Keith> is std::map's operator[]: Thanks for doing this. Keith> struct value * Keith> -value_coerce_to_target (struct value *val) Keith> +value_coerce_to_target (struct value *val, struct type *param_type) Keith> { I wasn't totally sold on doing the work here and not in value_arg_coerce but I guess it makes sense. Keith> + if (param_type != nullptr && param_type->language () == language_cplus Keith> + && TYPE_IS_REFERENCE (param_type)) Keith> + { Can we get here with a value that has an address, and so we don't need to make a copy? Like if there's a local variable 'x', and you do 'print map[x]'? If the argument is already in memory, then just casting its address to a reference would be a lot better, especially because memcpy()ing the data into the inferior is only really correct for trivially-copyable types. I don't know if that property (trivially-copyable) is all that easy to detect in gdb, but if it is, I guess it would make sense to detect it and throw an exception. Since in that case we'd be looking at something like a callee that wants memory but where the object has been SROA'd or something along those lines. Tom