From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>, Simon Marchi <simon.marchi@polymtl.ca>
Cc: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] [gdb/build] Fix build breaker with -std=c++11
Date: Tue, 8 Aug 2023 02:30:54 +0200 [thread overview]
Message-ID: <9863d400-87aa-f31e-ac49-f2ef2b5011b3@suse.de> (raw)
In-Reply-To: <87r0oe7b2k.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
On 8/8/23 00:16, Tom Tromey wrote:
> Simon> When we encounter things like this, should we add some greppable
> Simon> TODO comment to record an actionable item for when we switch to a
> Simon> more recent C++ version?
>
> FWIW I know of one other instance of this, in gdb_demangle:
>
> std::string copy = name;
> run_on_main_thread ([=] ()
> {
> report_failed_demangle (copy.c_str (), core_dump_allowed,
>
> Here, the name is copied twice, but with move captures there could be
> just a single copy.
Like so?
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-build-Use-move-capture-in-gdb_demangle.patch --]
[-- Type: text/x-patch, Size: 1141 bytes --]
From 7a6f3e7e39701b2b0e2f3b8f761e7c32f46af4a6 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Tue, 8 Aug 2023 01:34:45 +0200
Subject: [PATCH] [gdb/build] Use move capture in gdb_demangle
Use move capture in gdb_demangle when compiling for c++14 or higher, to save a
std::string copy.
Tested on x86_64-linux.
Reported-By: Tom Tromey <tom@tromey.com>
---
gdb/cp-support.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 2fb9d9ef0b2..0300727434d 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1656,7 +1656,13 @@ gdb_demangle (const char *name, int options)
we might be in a background thread. Instead, arrange for
the reporting to happen on the main thread. */
std::string copy = name;
- run_on_main_thread ([=] ()
+ run_on_main_thread ([
+#if __cplusplus >= 201402L
+ =, copy = std::move (copy)
+#else
+ =
+#endif
+ ] ()
{
report_failed_demangle (copy.c_str (), core_dump_allowed,
crash_signal);
base-commit: ddbe8c3c8a8665e77f9ebb108c5627a6ebecb81f
--
2.35.3
next prev parent reply other threads:[~2023-08-08 0:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-06 23:59 Tom de Vries
2023-08-07 14:35 ` Simon Marchi
2023-08-07 17:15 ` Tom de Vries
2023-08-07 18:01 ` John Baldwin
2023-08-07 23:11 ` Tom de Vries
2023-08-08 5:37 ` John Baldwin
2023-08-07 22:16 ` Tom Tromey
2023-08-08 0:30 ` Tom de Vries [this message]
2023-08-08 22:19 ` Tom Tromey
2023-08-08 15:21 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9863d400-87aa-f31e-ac49-f2ef2b5011b3@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).