From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id VyMNF1jY3mLZaBoAWB0awg (envelope-from ) for ; Mon, 25 Jul 2022 13:52:24 -0400 Received: by simark.ca (Postfix, from userid 112) id 4C7DB1E9E9; Mon, 25 Jul 2022 13:52:24 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 940711E21F for ; Mon, 25 Jul 2022 13:52:23 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC6C4383A316 for ; Mon, 25 Jul 2022 17:52:22 +0000 (GMT) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by sourceware.org (Postfix) with ESMTPS id 1BCD338582AE for ; Mon, 25 Jul 2022 17:52:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1BCD338582AE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f45.google.com with SMTP id x23-20020a05600c179700b003a30e3e7989so6846546wmo.0 for ; Mon, 25 Jul 2022 10:52:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6U3rNTvECoG2hbrYvTuHSbGiSh57gV1LC4R+ohY65+4=; b=pJaIZ827QDnNzCjE7ElJ7jSSb2oNyR1ufqQQ9IcTrm0/P/TnM4y4UwhcbcGLR0TDSl AaYvmecRpQF+3dJoQIgoZh6bUXl5VI+ivWvx5xHR2lpfmKr1ll4wP7jMO19tlNSHPpmt B6F95M/NriWoiRs3M8qko6eljU7olYUx3oYHBUvqpB4xpxe7RCp2lKVX/d3ZeT5aBNPk 296ib15uoNTQwFnJgv9cSGqg3IDLmvRrX9wdRhh+fjGQk85TCf4Avr5UcZ87AXCn8kke 6jZxweiqVFYkmbsahEUNYpKVqSwCSmAXwoWZjcmd5Mp2EQJjqLTnk3c9YhgGJ6xxEwF0 ks2A== X-Gm-Message-State: AJIora9o0VmdfxLcW5gDmobhDE0Jxy6ZURoylUUO7PbjI7xeCTs/AZLF 6nQo/bpXR7+TNuqu/zTMNQc= X-Google-Smtp-Source: AGRyM1t9Le+Apdom1aILp0CxdGvQs8NJ8hfYvOxFYAO/iIJIjP9cQpYPiysCie2YqrFd2xUoyFkPhw== X-Received: by 2002:a05:600c:1d06:b0:3a3:19ee:6963 with SMTP id l6-20020a05600c1d0600b003a319ee6963mr9604102wms.89.1658771529965; Mon, 25 Jul 2022 10:52:09 -0700 (PDT) Received: from ?IPv6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id i8-20020adfdec8000000b0021e860f1bd4sm4536453wrn.100.2022.07.25.10.52.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Jul 2022 10:52:09 -0700 (PDT) Subject: Re: [PATCH v3 2/5] Introduce frame_info_ptr smart pointer class To: Bruno Larsen , gdb-patches@sourceware.org References: <20220725170637.79699-1-blarsen@redhat.com> <20220725170637.79699-3-blarsen@redhat.com> From: Pedro Alves Message-ID: <67e2626e-e20c-00a2-3d6b-d58c613060af@palves.net> Date: Mon, 25 Jul 2022 18:52:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20220725170637.79699-3-blarsen@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2022-07-25 6:06 p.m., Bruno Larsen via Gdb-patches wrote: > + > +private: > + > + /* The underlying pointer. */ > + frame_info *m_ptr = nullptr; > + > + /* All frame_info_ptr objects are kept on a circular doubly-linked > + list. This keeps their construction and destruction costs > + reasonably small. To make the implementation a little simpler, > + we guarantee that there is always at least one object on the list > + -- this "root". */ This comment is stale -- this is no longer a full frame_info object. > + static intrusive_list root; > diff --git a/gdbsupport/intrusive_list.h b/gdbsupport/intrusive_list.h > index 6812266159a..48b2123582f 100644 > --- a/gdbsupport/intrusive_list.h > +++ b/gdbsupport/intrusive_list.h > @@ -391,13 +391,13 @@ class intrusive_list > void pop_front () > { > gdb_assert (!this->empty ()); > - erase_element (*m_front); > + erase (*m_front); > } > > void pop_back () > { > gdb_assert (!this->empty ()); > - erase_element (*m_back); > + erase (*m_back); > } > > private: > @@ -451,7 +451,8 @@ class intrusive_list > m_back = &elem; > } > > - void erase_element (T &elem) > +public: > + void erase (T &elem) > { > intrusive_list_node *elem_node = as_node (&elem); > > @@ -486,7 +487,6 @@ class intrusive_list > elem_node->prev = INTRUSIVE_LIST_UNLINKED_VALUE; > } > > -public: > /* Remove the element pointed by I from the list. The element > pointed by I is not destroyed. */ > iterator erase (const_iterator i) > @@ -494,7 +494,7 @@ class intrusive_list > iterator ret = i; > ++ret; > > - erase_element (*i); > + erase (*i); > > return ret; > } > API changes to utilities like this are better done in their own separate patch, with a rationale, along with unit test changes (in this case, some new test in gdb/unittests/intrusive_list-selftests.c). However, intrusive_list's API is modeled on Boost's intrusive list, and there, you see that there's no erase(T&) member: https://www.boost.org/doc/libs/1_67_0/doc/html/boost/intrusive/list.html I'd rather not deviate unless there's a good reason. AFAICT, you did the change for this: > + ~frame_info_ptr () > + { > + root.erase (*this); > + } which you should be able to tweak to use pre-existing API, like: root.erase (root.iterator_to (*this));