From: Tom Tromey <tom@tromey.com>
To: Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 5/6] gdb/continuations: use lambdas instead of function pointers
Date: Wed, 21 Apr 2021 13:43:56 -0600 [thread overview]
Message-ID: <87sg3ja0eb.fsf@tromey.com> (raw)
In-Reply-To: <4d9592aa18ca6528d300a4b77b8a552abdb7600d.1619009681.git.tankut.baris.aktemur@intel.com> (Tankut Baris Aktemur via Gdb-patches's message of "Wed, 21 Apr 2021 14:57:30 +0200")
>>>>> ">" == Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> writes:
>> Use lambdas and std::list to track inferior continuations. This is a
>> refactoring.
Thanks for the patch.
>> @@ -122,7 +39,12 @@ void
>> do_all_inferior_continuations ()
>> {
>> struct inferior *inf = current_inferior ();
>> - do_my_continuations (&inf->continuations);
>> + while (!inf->continuations.empty ())
>> + {
>> + auto &cont = inf->continuations.front ();
>> + inf->continuations.pop_front ();
>> + cont ();
It seems like this sequence can lead to 'cont' referencing an invalid
function, because 'cont' is just a reference, but pop_front will cause
it to be destroyed.
Maybe "auto cont = std::move (...)" would work ok.
Or, delaying the pop until after the callback is called seems fine as
well.
>> + A continuation is a closure (i.e. a lambda) to be called to finish
I think it would be fine to say "A continuation is a std::function"
here, because that encompasses lambdas but also other valid forms, like
ordinary functions.
>> + std::list<std::function<void ()> > continuations;
gdb style usually uses the ">>" token instead of adding the space here.
thanks,
Tom
next prev parent reply other threads:[~2021-04-21 19:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-21 12:57 [PATCH 0/6] Refactoring around inferior continuations Tankut Baris Aktemur via Gdb-patches
2021-04-21 12:57 ` [PATCH 1/6] gdb/infcmd: remove the unused parameter 'args' in 'attach_post_wait' Tankut Baris Aktemur via Gdb-patches
2021-04-21 19:24 ` Tom Tromey
2021-04-21 19:32 ` Simon Marchi via Gdb-patches
2021-04-21 19:47 ` Tom Tromey
2021-04-22 5:57 ` Aktemur, Tankut Baris via Gdb-patches
2021-04-21 12:57 ` [PATCH 2/6] gdb/infcmd: update the comment for 'attach_post_wait' Tankut Baris Aktemur via Gdb-patches
2021-04-21 19:25 ` Tom Tromey
2021-04-21 12:57 ` [PATCH 3/6] gdb/continuations: remove the 'err' from 'do_all_inferior_continuations' Tankut Baris Aktemur via Gdb-patches
2021-04-21 19:29 ` Tom Tromey
2021-04-21 12:57 ` [PATCH 4/6] gdb/continuations: do minor cleanup Tankut Baris Aktemur via Gdb-patches
2021-04-21 19:31 ` Tom Tromey
2021-04-21 12:57 ` [PATCH 5/6] gdb/continuations: use lambdas instead of function pointers Tankut Baris Aktemur via Gdb-patches
2021-04-21 19:43 ` Tom Tromey [this message]
2021-04-22 7:49 ` Aktemur, Tankut Baris via Gdb-patches
2021-04-22 12:50 ` Tom Tromey
2021-04-22 14:07 ` Aktemur, Tankut Baris via Gdb-patches
2021-04-22 14:12 ` Tom Tromey
2021-04-21 12:57 ` [PATCH 6/6] gdb/continuations: turn continuation functions into inferior methods Tankut Baris Aktemur via Gdb-patches
2021-04-21 19:46 ` Tom Tromey
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=87sg3ja0eb.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/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