public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Christian Biesinger <cbiesinger@google.com>
To: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
Cc: gdb-patches <gdb-patches@sourceware.org>,
	Pedro Alves <palves@redhat.com>
Subject: Re: [PATCH 1/2] gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread'
Date: Wed, 13 May 2020 13:43:26 -0500	[thread overview]
Message-ID: <CAPTJ0XGZ-YY46mLfK_juqUjkWE9PC-gubR3SRUs2mdFe5b3ARg@mail.gmail.com> (raw)
In-Reply-To: <SN6PR11MB28932A28E60B6B26C4DD96DCC4BF0@SN6PR11MB2893.namprd11.prod.outlook.com>

On Wed, May 13, 2020 at 3:26 AM Aktemur, Tankut Baris
<tankut.baris.aktemur@intel.com> wrote:
>
> On Wednesday, May 13, 2020 12:29 AM, Christian Biesinger wrote:
> > On Sun, May 3, 2020 at 10:37 AM Tankut Baris Aktemur via Gdb-patches
> > <gdb-patches@sourceware.org> wrote:
> > > @@ -83,3 +84,27 @@ process_stratum_target::has_execution (inferior *inf)
> > >       through hoops.  */
> > >    return inf->pid != 0;
> > >  }
> > > +
> > > +/* See process-stratum-target.h.  */
> > > +
> > > +std::set<process_stratum_target *>
> > > +all_non_exited_process_targets ()
> > > +{
> > > +  std::set<process_stratum_target *> targets;
> > > +  for (inferior *inf : all_non_exited_inferiors ())
> > > +    targets.insert (inf->process_target ());
> > > +
> > > +  return targets;
> >
> > Instead of creating a new set, it seems like it would be a lot more
> > efficient to just wrap the all_non_exited_inferiors() iterator and
> > return it->process_target(). What do you think?
>
> But the inferiors may share targets and this would not eliminate duplicates from
> appearing, would it?  We would still need a mechanism to remember the previously
> returned process targets and skip duplicates, I think.
>
> A remark about the code above is that the order of elements when iterating the set
> is not necessarily the same order we would get when iterating inferiors (i.e. the
> order of insertion into the set).  I don't think this matters, though.  And as long
> as a new target is not added to or removed from the debug session, the order obtained
> from each call to all_non_exited_process_targets is consistent.

Ah yes, that makes sense. Maybe add a comment that you're using set<>
to remove duplicates?

Christian

      reply	other threads:[~2020-05-13 18:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 15:37 Tankut Baris Aktemur
2020-05-12 22:29 ` Christian Biesinger
2020-05-13  8:26   ` Aktemur, Tankut Baris
2020-05-13 18:43     ` Christian Biesinger [this message]

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=CAPTJ0XGZ-YY46mLfK_juqUjkWE9PC-gubR3SRUs2mdFe5b3ARg@mail.gmail.com \
    --to=cbiesinger@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=tankut.baris.aktemur@intel.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).