From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99912 invoked by alias); 9 Aug 2017 19:31:28 -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 99469 invoked by uid 89); 9 Aug 2017 19:31:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2100 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Aug 2017 19:31:26 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v79JVJJa007661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 9 Aug 2017 15:31:24 -0400 Received: by simark.ca (Postfix, from userid 112) id CFD6A1EA1D; Wed, 9 Aug 2017 15:31:19 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id CC98F1E895; Wed, 9 Aug 2017 15:31:18 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 09 Aug 2017 19:31:00 -0000 From: Simon Marchi To: John Baldwin Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 3/3] Replace home-grown linked-lists in FreeBSD's native target with STL lists. In-Reply-To: <11454065.pnOhqTuiKx@ralph.baldwin.cx> References: <20170809174754.49166-1-jhb@FreeBSD.org> <20170809174754.49166-4-jhb@FreeBSD.org> <11454065.pnOhqTuiKx@ralph.baldwin.cx> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 9 Aug 2017 19:31:20 +0000 X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00205.txt.bz2 On 2017-08-09 21:15, John Baldwin wrote: > 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. Ah, ok. I thought it could be done trivially, but I can't easily build-test on FreeBSD right now. I agree with you. Simon