Message ID | 20231010204213.111285-4-simon.marchi@efficios.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> 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 <patchwork@sourceware.org>; 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 <gdb-patches@sourceware.org>; 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 <simon.marchi@efficios.com> To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@polymtl.ca> 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org |
Series |
C++ification of struct so_list
|
|
Commit Message
Simon Marchi
Oct. 10, 2023, 8:39 p.m. UTC
From: Simon Marchi <simon.marchi@polymtl.ca>
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<class ... Args> 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(-)
Comments
Hi Simon, Just a nit below. On Tue, Oct 10, 2023 at 04:39:58PM -0400, Simon Marchi wrote: > From: Simon Marchi <simon.marchi@polymtl.ca> > > 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<class ... Args> 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 <typename ...Args> > +template <typename MethodType, typename ...Args> > 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>(args)...); ^ Space missing before the "(". Best, Lancelot. > } > } > > -- > 2.42.0 >
On 10/11/23 04:48, Lancelot SIX wrote: >> 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 <typename ...Args> >> +template <typename MethodType, typename ...Args> >> 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>(args)...); > ^ > > Space missing before the "(". > > Best, > Lancelot. Thanks, fixed locally. Simon
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 <typename ...Args> +template <typename MethodType, typename ...Args> 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>(args)...); } }