From patchwork Tue Oct 10 20:39:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 77442 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB3A238582B7 for ; Tue, 10 Oct 2023 20:42:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 3E5003858C52 for ; Tue, 10 Oct 2023 20:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E5003858C52 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (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 ESMTPSA id DC0271E0D2; Tue, 10 Oct 2023 16:42:15 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 03/24] gdb: make interps_notify work with references Date: Tue, 10 Oct 2023 16:39:58 -0400 Message-ID: <20231010204213.111285-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231010204213.111285-1-simon.marchi@efficios.com> References: <20231010204213.111285-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3496.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org From: Simon Marchi A subsequent patch changes the interp::on_solib_loaded and interp::on_solib_unloaded methods to take references. This highlighted that interps_notify did not work with reference parameters. Fix that by changing interps_notify's `args` arg to be a universal reference (&&). Change the type of the method to be auto-deduced as an additional template parameter, otherwise the signature of the callback function would never match: CXX interps.o /home/simark/src/binutils-gdb/gdb/interps.c: In function ‘void interps_notify_signal_received(gdb_signal)’: /home/simark/src/binutils-gdb/gdb/interps.c:378:18: error: no matching function for call to ‘interps_notify(void (interp::*)(gdb_signal), gdb_signal&)’ 378 | interps_notify (&interp::on_signal_received, sig); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/simark/src/binutils-gdb/gdb/interps.c:363:1: note: candidate: ‘template void interps_notify(void (interp::*)(Args ...), Args&& ...)’ 363 | interps_notify (void (interp::*method) (Args...), Args&&... args) | ^~~~~~~~~~~~~~ /home/simark/src/binutils-gdb/gdb/interps.c:363:1: note: template argument deduction/substitution failed: /home/simark/src/binutils-gdb/gdb/interps.c:378:18: note: inconsistent parameter pack deduction with ‘gdb_signal’ and ‘gdb_signal&’ 378 | interps_notify (&interp::on_signal_received, sig); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I0cd9378e24ef039f30f8e14f054f8d7fb539c838 --- gdb/interps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index f91b2b62c1ba..62a30583e8c0 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -358,15 +358,15 @@ current_interpreter (void) /* Helper interps_notify_* functions. Call METHOD on the top-level interpreter of all UIs. */ -template +template void -interps_notify (void (interp::*method) (Args...), Args... args) +interps_notify (MethodType method, Args&&... args) { SWITCH_THRU_ALL_UIS () { interp *tli = top_level_interpreter (); if (tli != nullptr) - (tli->*method) (args...); + (tli->*method) (std::forward(args)...); } }