Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Bruno Larsen <blarsen@redhat.com>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH v3 2/5] Introduce frame_info_ptr smart pointer class
Date: Mon, 25 Jul 2022 18:52:07 +0100	[thread overview]
Message-ID: <67e2626e-e20c-00a2-3d6b-d58c613060af@palves.net> (raw)
In-Reply-To: <20220725170637.79699-3-blarsen@redhat.com>

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<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));

  reply	other threads:[~2022-07-25 17:52 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 [this message]
2022-08-24 14:24     ` Bruno Larsen via Gdb-patches
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=67e2626e-e20c-00a2-3d6b-d58c613060af@palves.net \
    --to=pedro@palves.net \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --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