public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Michael Weghorn <m.weghorn@posteo.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: Change init order so pretty printers are set in new_objfile event
Date: Wed, 24 Mar 2021 09:45:23 +0000	[thread overview]
Message-ID: <20210324094523.GI5520@embecosm.com> (raw)
In-Reply-To: <f1315204-7972-29b7-4e87-79f1d6c15641@polymtl.ca>

* Simon Marchi <simon.marchi@polymtl.ca> [2021-03-23 14:55:13 -0400]:

> > I have a crazy thought, but I want to mention it in case it has any
> > value.
> > 
> > The core of the idea is to modify the attach functions in
> > gdbsupport/observable.h like this:P
> > 
> >   void attach (const func_type &f, int bias = 0)
> >   {
> >     m_observers.emplace_back (nullptr, f, bias);
> >     if (m_sorted || bias != 0)
> >       {
> > 	m_sorted = true;
> > 	std::sort (m_observers.begin (), m_observers.end (), sort_by_bias);
> >       }
> >   }
> > 
> > Where 'm_sorted' is just a boolean flag, and `sort_by_bias` just
> > orders the observers from highest bias to lowest.  Then, if you have
> > an observer that you want to run late in the process you just attach
> > it with a low bias.  So in py-inferior.c:
> > 
> >   /* Pass a low bias to ensure this observer triggers after any
> >      GDB internal observers.  */
> >   gdb::observers::new_objfile.attach (python_new_objfile, -10);
> > 
> 
> I had similar crazy thoughts once.  Except it wouldn't use arbitrary
> numerical values.  It can be a bit obscure why a certain value is
> assigned to a given observer.
> 
> Instead, when attaching an observer you tell which other observer you'd
> like to run after.  So let's say subsystem bar uses features from
> subsystem foo (so it necessarily knows about foo already), foo would do:
> 
>   // In foo.h
>   extern observer_key foo_new_objfile_observer;
> 
>   // In foo.c, in _initialize_foo
>   foo_new_objfile_observer = gdb::observers::new_objfile.attach (foo_new_objfile);
> 
>   // In bar.c, in _initialize_bar
>   gdb::observers::new_objfile.attach (bar_new_objfile, &foo_new_objfile_observer);

That's fine, but I ran into a case just a couple of days ago where I
wanted observer ordering, but in that case there are two observers
that I would have wanted to be ordered before.

I guess we could chain the dependencies, but I suspect this would
break if observers are detached (e.g. tui observers).

I think the only reliable solution would be to allow for a vector of
dependencies, how would that sound?

Thanks,
Andrew

  reply	other threads:[~2021-03-24  9:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 15:40 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 [this message]
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
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=20210324094523.GI5520@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=m.weghorn@posteo.de \
    --cc=simon.marchi@polymtl.ca \
    /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).