Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Inline build_bp_list into its only caller
Date: Mon, 14 Sep 2026 09:48:48 -0400	[thread overview]
Message-ID: <273fbe38-f21e-4ffa-8740-eeebd45f0558@simark.ca> (raw)
In-Reply-To: <20260913173528.3877931-1-tom@tromey.com>

On 9/13/26 1:35 PM, Tom Tromey wrote:
> While working on safety patches for py-breakpoint.c, I ran across
> build_bp_list.  This is called from just one place, and it seems
> cleaner to inline it into its sole caller.
> ---
>  gdb/python/py-breakpoint.c | 35 +++++++++++++----------------------
>  1 file changed, 13 insertions(+), 22 deletions(-)
> 
> diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
> index ecb42cee5f9..e5df4459dd6 100644
> --- a/gdb/python/py-breakpoint.c
> +++ b/gdb/python/py-breakpoint.c
> @@ -1089,26 +1089,6 @@ bppy_repr (PyObject *self)
>  			       bp->bp->hit_count, str.c_str ());
>  }
>  
> -/* Append to LIST the breakpoint Python object associated to B.
> -
> -   Return true on success.  Return false on failure, with the Python error
> -   indicator set.  */
> -
> -static bool
> -build_bp_list (struct breakpoint *b, PyObject *list)
> -{
> -  PyObject *bp = (PyObject *) b->py_bp_object;


> -
> -  /* Not all breakpoints will have a companion Python object.
> -     Only breakpoints that were created via bppy_new, or
> -     breakpoints that were created externally and are tracked by
> -     the Python Scripting API.  */
> -  if (bp == nullptr)
> -    return true;
> -
> -  return PyList_Append (list, bp) == 0;
> -}
> -
>  /* See python-internal.h.  */
>  
>  bool
> @@ -1144,8 +1124,19 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
>    /* If build_bp_list returns false, it signals an error condition.  In that

This comment refers to the new removed function.

>       case abandon building the list and return nullptr.  */
>    for (breakpoint &bp : all_breakpoints ())
> -    if (!build_bp_list (&bp, list.get ()))
> -      return nullptr;
> +    {
> +      PyObject *bp_obj = (PyObject *) bp.py_bp_object;

I'd remove the `bp` variable and use bp.py_bp_object directly.

Otherwise, LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

      reply	other threads:[~2026-09-14 13:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 17:35 Tom Tromey
2026-09-14 13:48 ` Simon Marchi [this message]

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=273fbe38-f21e-4ffa-8740-eeebd45f0558@simark.ca \
    --to=simark@simark.ca \
    --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