From: Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH v3 2/5] Introduce frame_info_ptr smart pointer class
Date: Wed, 24 Aug 2022 16:24:44 +0200 [thread overview]
Message-ID: <1bd52cbc-71ce-672b-9815-7a485e98475a@redhat.com> (raw)
In-Reply-To: <67e2626e-e20c-00a2-3d6b-d58c613060af@palves.net>
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<frame_info_ptr> 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<T> *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
next prev parent reply other threads:[~2022-08-24 14:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-25 17:06 [PATCH v3 0/5] Smart pointer wrapper for frame_info Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 1/5] Remove frame_id_eq Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 2/5] Introduce frame_info_ptr smart pointer class Bruno Larsen via Gdb-patches
2022-07-25 17:52 ` Pedro Alves
2022-08-24 14:24 ` Bruno Larsen via Gdb-patches [this message]
2022-08-24 15:20 ` Pedro Alves
2022-08-24 15:49 ` Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 3/5] Change GDB to use frame_info_ptr Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 4/5] Continue making GDB " Bruno Larsen via Gdb-patches
2022-07-28 16:44 ` Andrew Burgess via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 5/5] gdb/frame: Add reinflation method for frame_info_ptr Bruno Larsen via Gdb-patches
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=1bd52cbc-71ce-672b-9815-7a485e98475a@redhat.com \
--to=gdb-patches@sourceware.org \
--cc=blarsen@redhat.com \
--cc=pedro@palves.net \
--cc=tom@tromey.com \
/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