From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lQ4kFMo0BmPLmSwAWB0awg (envelope-from ) for ; Wed, 24 Aug 2022 10:25:14 -0400 Received: by simark.ca (Postfix, from userid 112) id 44EC11E4A7; Wed, 24 Aug 2022 10:25:14 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=UazpTrku; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.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 E83B51E13B for ; Wed, 24 Aug 2022 10:25:12 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 757C9385C413 for ; Wed, 24 Aug 2022 14:25:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 757C9385C413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661351109; bh=8yapvKcD7uGzqQFPJreQ+A/KC6GyiiMTYss6/7FbXKY=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UazpTrku0Kv8vVSSSJ6RB6b9C87K5phlDzuEIyGyNBqSGn6UG9OiMsHrsDzlKKE5t XSzraA7hxj4whJqgWskLd+fiju85ylFsT7PbbgvDjaiRbK18OWgbeyCDwMs6hgRFCb wxvvtIECaSOSOQ8tcWfJpTIVGANVWK3+qxTxZ3wk= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0054C385C8B1 for ; Wed, 24 Aug 2022 14:24:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0054C385C8B1 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-179-co-heGdvOS2SMZgChFuVxw-1; Wed, 24 Aug 2022 10:24:47 -0400 X-MC-Unique: co-heGdvOS2SMZgChFuVxw-1 Received: by mail-ej1-f71.google.com with SMTP id qw34-20020a1709066a2200b00730ca5a94bfso5233533ejc.3 for ; Wed, 24 Aug 2022 07:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=8yapvKcD7uGzqQFPJreQ+A/KC6GyiiMTYss6/7FbXKY=; b=A24ASrfdgqzBGrP3zFzBv1v25KkKHFYlKQxkx41IvsUHlgArPiOkGkSb0S/wMWCN8n gT8ytvS9G5i+4ffJnCNjiVyoY7L7He9e70tHAh6KVwem73y4I5MyMeQLiB+EDcvhZDCa JSHR/Hs8shCAOAIW4v2MsmCyHT6BBtGCMiRjEhwbH7cW1ujx2QKUJdfTkIXpvQelG3qT XaCCltUsSKerw16fucGCoYKXWcp64vGgkav5KJhspdrU8/U1+k+C2SGhBnc1dPcC0xxb rE0E/IMbm1gor5Q5u20R2xMn8K/kpiZrnkLvFQdiJzAx7H0dp/c5TtZb/I8Vx2cwbc85 9Ziw== X-Gm-Message-State: ACgBeo0DuzP/YwboaOeCOklc2gFwkqNB/iHTR7kDNt/RPTSkUKvoUEwv 9TIcXyqoOfW4DIQi0tkj/DciVM5o9c45lfmSCWMOgBcr9LNx1e+cLklSq2zShezL9jNx7st1cmA Is0CYE+DQRho6OsGLdy7NZA== X-Received: by 2002:aa7:cc05:0:b0:447:8654:7fa9 with SMTP id q5-20020aa7cc05000000b0044786547fa9mr2195082edt.298.1661351086063; Wed, 24 Aug 2022 07:24:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR4vIj3EgwDmdfIQe8lYhszvVtnv1CD5PWJyFeHTN+t2f0mC1pDtr+MmYJp8Yfv0ZRmmPYSegA== X-Received: by 2002:aa7:cc05:0:b0:447:8654:7fa9 with SMTP id q5-20020aa7cc05000000b0044786547fa9mr2195071edt.298.1661351085858; Wed, 24 Aug 2022 07:24:45 -0700 (PDT) Received: from [10.43.2.105] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id k23-20020a17090632d700b00722e50dab2csm1235743ejk.109.2022.08.24.07.24.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Aug 2022 07:24:45 -0700 (PDT) Message-ID: <1bd52cbc-71ce-672b-9815-7a485e98475a@redhat.com> Date: Wed, 24 Aug 2022 16:24:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v3 2/5] Introduce frame_info_ptr smart pointer class To: Pedro Alves , gdb-patches@sourceware.org References: <20220725170637.79699-1-blarsen@redhat.com> <20220725170637.79699-3-blarsen@redhat.com> <67e2626e-e20c-00a2-3d6b-d58c613060af@palves.net> In-Reply-To: <67e2626e-e20c-00a2-3d6b-d58c613060af@palves.net> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: , From: Bruno Larsen via Gdb-patches Reply-To: Bruno Larsen Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi Pedro, Thanks for the review, and sorry for the delayed response. On 25/07/2022 19:52, Pedro Alves wrote: > 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. I'm not sure why you mention it being a full frame_info object. root was never a usable frame_info_ptr, it was just used as a pointer to the frame_info_ptr list from the outside, and to make intrusive list operations easy as we don't have to check for an empty list. I did reword the comment to: /* All frame_info_ptr objects are kept on an intrusive 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".  It is only used to simplify intrusive_list operations.  */ to hopefully explain things better. > >> + 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)); Ah, this was just inherited from github. I have fixed this for v4 > -- Cheers, Bruno