From: Simon Marchi <simon.marchi@polymtl.ca>
To: Michael Weghorn <m.weghorn@posteo.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3] gdb: Do autoload before notifying Python side in new_objfile event
Date: Thu, 22 Apr 2021 12:06:28 -0400 [thread overview]
Message-ID: <2e5a3c5f-361d-08b6-3224-660d6abb6687@polymtl.ca> (raw)
In-Reply-To: <8e33b994-44fd-e58a-1309-1c0fb954a900@posteo.de>
On 2021-04-22 11:46 a.m., Michael Weghorn wrote:
>
> On 20/04/2021 23.57, Simon Marchi wrote:
>> Huh, I started working on this because I didn't see your message and
>> didn't realize you had implemented it already. Here's my WIP branch for
>> reference:
>>
>> https://github.com/simark/binutils-gdb/tree/observer-dep
>>
>> I made some random improvements to observable.h in the form of
>> preparatory patches. They could be merged later, or you could rebase
>> your patch on top if you think it would help you.
>
> Thanks, I've rebased on top of commit f7716715f1d2a71a5c95b7ac0e0323b742692e6d
> ("gdbsupport: add observer_debug_printf, OBSERVER_SCOPED_DEBUG_ENTER_EXIT")
> from that WIP branch and dropped those parts from my patch that were already
> included in commits on that branch up to that point.
>
> I've left out the last two patches from that branch which were doing
> similar things to my patch, but it didn't look straightforward to me
> how to reasonably "merge" the two versions.
> I've taken some inspiration for naming (which was nicer on your branch) and split
> my patch into two separate ones similar to how it is done on your branch,
> though (one patch to add the functionality to order observers + corresponding
> unit tests; one patch to make use of that and add the testcase
> for the testsuite).
>
> I was uncertain of whether or not to include your commits from the WIP
> branch in the patch series to send to the mailing list, and haven't done
> so yet in v4 (but can of course do so in the next version if it makes
> sense) that I just sent:
>
> https://sourceware.org/pipermail/gdb-patches/2021-April/178069.html
Thanks! Then I will try to post my patches soon and get them merged.
>> I left a few comments below. But in general this looks great, pretty
>> much what I had in mind when I suggested this idea.
>>
>> Random question for you: while doing this work, I stumbled upon this
>> line in the detach method:
>>
>> m_observers.erase (iter, m_observers.end ());
>>
>> Does that look right to you? Doesn't this delete more observers than
>> the one we want to detach, if there are more observers after it?
>
> As I understand it, that should be OK, since 'std::remove_if' is called
> first, which - as I understand it - should make sure that all
> not-to-be-removed observers will be before 'iter' afterwards.
> http://www.cplusplus.com/reference/algorithm/remove_if/?kw=remove_if
> says:
> "Transforms the range [first,last) into a range with all the elements for which
> pred returns true removed, and returns an iterator to the new end of that
> range.
> The function cannot alter the properties of the object containing the range of
> elements (i.e., it cannot alter the size of an array or a container):
> The removal is done by replacing the elements for which pred returns true
> by the next element for which it does not, and signaling the new size of
> the shortened range by returning an iterator to the element that should be
> considered its new past-the-end element."
Ah, right, I forgot how that worked, thanks.
>> I think we need to call sort_elements even if key == nullptr, because
>> the two observers can be added in any order. If observer A depends on
>> B, A won't have a key (it doesn't need to). If B if registered, then A,
>> you want to sort at that time. So I would just sort all the time on
>> attach.
>
> I think that case should be fine without reordering, because the observer
> is initially always added at the end of the vector (using 'emplace_back'),
> i.e. after all potential dependencies that have been inserted earlier),
> i.e. A already comes after B if it is registered later.
>
> The idea was to avoid reordering the vector if it's not necessary, but
> I don't know whether that makes any difference performance-wise in practice
> and can drop that if you think it makes sense.
> (I've left it in v4 to hear about your opinion first.)
Ok, that makes sense. A comment to explain that would be good though,
since it's not obvious and can seem wrong for others too.
Simon
next prev parent reply other threads:[~2021-04-22 16:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 15:40 [PATCH] gdb: Change init order so pretty printers are set " Michael Weghorn
2021-02-11 9:42 ` Andrew Burgess
2021-02-11 11:23 ` Michael Weghorn
2021-03-02 7:18 ` Michael Weghorn
2021-03-23 18:55 ` Simon Marchi
2021-03-24 9:45 ` Andrew Burgess
2021-03-24 13:51 ` Simon Marchi
2021-03-26 8:33 ` Michael Weghorn
2021-02-11 11:22 ` [PATCH v2] " Michael Weghorn
2021-03-23 8:01 ` [PING] " Michael Weghorn
2021-03-26 8:29 ` [PATCH v3] gdb: Do autoload before notifying Python side " Michael Weghorn
2021-04-12 13:37 ` [PING] " Michael Weghorn
2021-04-20 11:38 ` [PING 2] " Michael Weghorn
2021-04-20 21:57 ` Simon Marchi
2021-04-22 15:46 ` Michael Weghorn
2021-04-22 16:06 ` Simon Marchi [this message]
2021-04-23 6:41 ` Michael Weghorn
2021-04-23 10:48 ` Simon Marchi
2021-04-22 15:44 ` [PATCH v4 0/2] Make sure autoload happens " Michael Weghorn
2021-04-22 15:44 ` [PATCH v4 1/2] gdbsupport: Allow to specify dependencies between observers Michael Weghorn
2021-04-22 15:44 ` [PATCH v4 2/2] gdb: Do autoload before notifying Python side in new_objfile event Michael Weghorn
2021-04-25 1:46 ` [PATCH v4 0/2] Make sure autoload happens " Simon Marchi
2021-04-26 8:18 ` Michael Weghorn
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=2e5a3c5f-361d-08b6-3224-660d6abb6687@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=m.weghorn@posteo.de \
/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).