From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Inline build_bp_list into its only caller
Date: Sun, 13 Sep 2026 11:35:28 -0600 [thread overview]
Message-ID: <20260913173528.3877931-1-tom@tromey.com> (raw)
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
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;
+
+ /* 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_obj == nullptr)
+ continue;
+
+ if (PyList_Append (list.get (), bp_obj) < 0)
+ return nullptr;
+ }
return PyList_AsTuple (list.get ());
}
--
2.49.0
next reply other threads:[~2026-09-13 17:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 17:35 Tom Tromey [this message]
2026-09-14 13:48 ` Simon Marchi
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=20260913173528.3877931-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/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