From: John Baldwin <jhb@freebsd.org>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 3/3] Replace home-grown linked-lists in FreeBSD's native target with STL lists.
Date: Wed, 09 Aug 2017 19:15:00 -0000 [thread overview]
Message-ID: <11454065.pnOhqTuiKx@ralph.baldwin.cx> (raw)
In-Reply-To: <d012801425c76ed9a72d24c5819f9299@polymtl.ca>
On Wednesday, August 09, 2017 08:16:29 PM Simon Marchi wrote:
> On 2017-08-09 19:47, John Baldwin wrote:
> > diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
> > index 721e72b85c..c89343a24f 100644
> > --- a/gdb/fbsd-nat.c
> > +++ b/gdb/fbsd-nat.c
> > @@ -41,6 +41,8 @@
> > #include "elf-bfd.h"
> > #include "fbsd-nat.h"
> >
> > +#include <list>
> > +
> > /* Return the name of a file that can be opened to get the symbols for
> > the child process identified by PID. */
> >
> > @@ -712,13 +714,7 @@ fbsd_update_thread_list (struct target_ops *ops)
> > sake. FreeBSD versions newer than 9.1 contain both fixes.
> > */
> >
> > -struct fbsd_fork_info
> > -{
> > - struct fbsd_fork_info *next;
> > - ptid_t ptid;
> > -};
> > -
> > -static struct fbsd_fork_info *fbsd_pending_children;
> > +static std::list<ptid_t> fbsd_pending_children;
>
> Can't this be a forward_list as well?
Not trivially. fbsd_is_child_pending has to walk the list looking for a
specific PID and remove that specific list entry (not always the first
entry). Right now this is using the following loop:
for (auto it = fbsd_pending_children.begin ();
it != fbsd_pending_children.end (); it++)
if (it->pid () == pid)
{
ptid_t ptid = *it;
fbsd_pending_children.erase (it);
return ptid;
}
return null_ptid;
I'm not sure if it's legal to do something like this for a forward_list:
for (auto it = fbsd_pending_children.before_begin ();
it + 1 != fbsd_pending_children.end (); it++)
if ((it + 1)->pid () == pid)
{
ptid_t ptid = *(it + 1);
fbsd_pending_childern.erase_after (it);
return ptid;
}
return null_ptid;
Even if it is legal, I'm not sure it is more readable. These lists should
generally be quite small, so I think readability is more important than
optimization in this case.
--
John Baldwin
next prev parent reply other threads:[~2017-08-09 19:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 17:49 [PATCH v2 0/3] Some C++-ification of the FreeBSD target John Baldwin
2017-08-09 17:49 ` [PATCH v2 3/3] Replace home-grown linked-lists in FreeBSD's native target with STL lists John Baldwin
2017-08-09 18:16 ` Simon Marchi
2017-08-09 19:15 ` John Baldwin [this message]
2017-08-09 19:31 ` Simon Marchi
2017-08-09 17:49 ` [PATCH v2 1/3] Fix compile in the !HAVE_KINFO_GETVMMAP case John Baldwin
2017-08-09 17:49 ` [PATCH v2 2/3] Replace remaining cleanups in fbsd-nat.c John Baldwin
2017-08-10 13:26 ` Pedro Alves
2017-08-10 14:51 ` John Baldwin
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=11454065.pnOhqTuiKx@ralph.baldwin.cx \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--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