From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43256 invoked by alias); 9 Aug 2017 19:15:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 43216 invoked by uid 89); 9 Aug 2017 19:15:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Aug 2017 19:15:28 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 0BC8C10AF07; Wed, 9 Aug 2017 15:15:22 -0400 (EDT) From: John Baldwin To: Simon Marchi 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 Message-ID: <11454065.pnOhqTuiKx@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: References: <20170809174754.49166-1-jhb@FreeBSD.org> <20170809174754.49166-4-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00203.txt.bz2 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 > > + > > /* 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 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