* [PATCH] Fix inheritance of finish_breakpoint_object
@ 2026-09-12 14:21 Tom Tromey
2026-09-14 13:38 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-09-12 14:21 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
I noticed that finish_breakpoint_object does not derive from PyObject,
but instead uses the older C-style inheritance. This patch fixes
this.
---
gdb/python/py-finishbreakpoint.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 49e12c00054..f5548636398 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -36,11 +36,8 @@ static const char outofscope_func[] = "out_of_scope";
/* struct implementing the gdb.FinishBreakpoint object by extending
the gdb.Breakpoint class. */
-struct finish_breakpoint_object
+struct finish_breakpoint_object : public gdbpy_breakpoint_object
{
- /* gdb.Breakpoint base class. */
- gdbpy_breakpoint_object py_bp;
-
/* gdb.Symbol object of the function finished by this breakpoint.
nullptr if no debug information was available or return type was VOID. */
@@ -301,7 +298,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
self_bpfinish->function_value = nullptr;
}
- bppy_pending_object = &self_bpfinish->py_bp;
+ bppy_pending_object = self_bpfinish;
bppy_pending_object->number = -1;
bppy_pending_object->bp = NULL;
@@ -325,12 +322,12 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
return gdbpy_handle_gdb_exception (-1, except);
}
- self_bpfinish->py_bp.bp->frame_id = frame_id;
- self_bpfinish->py_bp.is_finish_bp = 1;
+ self_bpfinish->bp->frame_id = frame_id;
+ self_bpfinish->is_finish_bp = 1;
self_bpfinish->initiating_frame = get_frame_id (frame);
/* Bind the breakpoint with the current program space. */
- self_bpfinish->py_bp.bp->pspace = current_program_space;
+ self_bpfinish->bp->pspace = current_program_space;
return 0;
}
@@ -345,7 +342,7 @@ bpfinishpy_out_of_scope (struct finish_breakpoint_object *bpfinish_obj)
gdbpy_breakpoint_object *bp_obj = (gdbpy_breakpoint_object *) bpfinish_obj;
PyObject *py_obj = (PyObject *) bp_obj;
- if (bpfinish_obj->py_bp.bp->enable_state == bp_enabled
+ if (bpfinish_obj->bp->enable_state == bp_enabled
&& PyObject_HasAttrString (py_obj, outofscope_func))
{
gdbpy_ref<> meth_result = gdbpy_call_method (py_obj, outofscope_func);
@@ -388,7 +385,7 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b,
{
bpfinishpy_out_of_scope (finish_bp);
if (delete_bp)
- delete_breakpoint (finish_bp->py_bp.bp);
+ delete_breakpoint (finish_bp->bp);
}
}
catch (const gdb_exception &except)
--
2.49.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix inheritance of finish_breakpoint_object
2026-09-12 14:21 [PATCH] Fix inheritance of finish_breakpoint_object Tom Tromey
@ 2026-09-14 13:38 ` Simon Marchi
2026-09-14 14:12 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2026-09-14 13:38 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 9/12/26 10:21 AM, Tom Tromey wrote:
> I noticed that finish_breakpoint_object does not derive from PyObject,
> but instead uses the older C-style inheritance. This patch fixes
> this.
- Missing
static_assert (gdb::is_python_allocatable_v<finish_breakpoint_object>);
as mandated by the comment in python-traits.h
- The two local variables in bpfinishpy_out_of_scope can be removed, in
favor of just using bpfinish_obj directly.
Otherwise, LGTM.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix inheritance of finish_breakpoint_object
2026-09-14 13:38 ` Simon Marchi
@ 2026-09-14 14:12 ` Simon Marchi
2026-09-14 15:32 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2026-09-14 14:12 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 9/14/26 9:38 AM, Simon Marchi wrote:
> On 9/12/26 10:21 AM, Tom Tromey wrote:
>> I noticed that finish_breakpoint_object does not derive from PyObject,
>> but instead uses the older C-style inheritance. This patch fixes
>> this.
>
> - Missing
>
> static_assert (gdb::is_python_allocatable_v<finish_breakpoint_object>);
>
> as mandated by the comment in python-traits.h
>
> - The two local variables in bpfinishpy_out_of_scope can be removed, in
> favor of just using bpfinish_obj directly.
FYI, I have a patch to remove all those no-unnessary casts and local
variables, I'll send it after you push this one.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix inheritance of finish_breakpoint_object
2026-09-14 14:12 ` Simon Marchi
@ 2026-09-14 15:32 ` Tom Tromey
2026-09-14 15:33 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-09-14 15:32 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
Simon> FYI, I have a patch to remove all those no-unnessary casts and local
Simon> variables, I'll send it after you push this one.
I don't know if it overlaps but I have an unreviewed patch out there
that removes a lot of casts. Can you look at that first? Thanks.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix inheritance of finish_breakpoint_object
2026-09-14 15:32 ` Tom Tromey
@ 2026-09-14 15:33 ` Simon Marchi
0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2026-09-14 15:33 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/14/26 11:32 AM, Tom Tromey wrote:
> Simon> FYI, I have a patch to remove all those no-unnessary casts and local
> Simon> variables, I'll send it after you push this one.
>
> I don't know if it overlaps but I have an unreviewed patch out there
> that removes a lot of casts. Can you look at that first? Thanks.
Ah yes of course I'll do that.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-14 15:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-12 14:21 [PATCH] Fix inheritance of finish_breakpoint_object Tom Tromey
2026-09-14 13:38 ` Simon Marchi
2026-09-14 14:12 ` Simon Marchi
2026-09-14 15:32 ` Tom Tromey
2026-09-14 15:33 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox