Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Matthieu Longo via Gdb <gdb@sourceware.org>
To: Tom Tromey <tom@tromey.com>, Matthieu Longo via Gdb <gdb@sourceware.org>
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: Re: RFC: prototype of C extensions using the Python limited API
Date: Mon, 22 Jun 2026 10:26:41 +0100	[thread overview]
Message-ID: <f108eac4-ab90-41e5-9c2c-d6d07b217105@arm.com> (raw)
In-Reply-To: <877bnvinla.fsf@tromey.com>

On 18/06/2026 21:46, Tom Tromey wrote:
> Matthieu> The prototype is organized as follows:
> Matthieu> - include/
> Matthieu>   - py-ref.hpp: copied from GDB. Addition of a clear() method in gdbpy_ref_policy.
> 
> Do we really need this?
> 
> What if gdb_py_ref is a subclass that adds a custom method instead?

This is for cases when a 'gdbpy_ref<> *' is a member of a Python object.
Py_CLEAR and Py_VISIT have to be called on the 'PyObject *' owned by gdbpy_ref.
This case does not appear in the prototype. I have only one occurrence inside GDB (which I 
introduced), which is perfectly replaceable by a raw 'PyObject *'. It does not seem a big deal to 
discard this.

> 
> I still haven't really read the code.  It's kind of difficult in this
> form.
> 

I just noticed that the patch was not inlined properly in the email. I usually use git-send-email 
for this, but had to add the patch manually here. I used Thunderbird to send it, with 
"mailnews.send_plaintext_flowed = true" so I would have expected the patch to be inlined.

Sorry for this. I can retry to send the inlined patch again.
Is there anything else I can do to make things easier for you ?

> Matthieu>     + gdbpy_heap_type: generic logic for dynamically-allocated types
> Matthieu>     (tp_traverse, tp_clear, tp_dealloc)
> 
> I don't understand why these can't just be methods of the implementation
> class, by which I mean the subclasses of PyObject.  If needed we could
> make an intermediary base class that interposes between the
> implementation and PyObject like
> > struct intermediary : public PyObject {};
> struct type_object : public intermediary { ... };  // eg
> 

The Python object is allocated by Python with PyObject_GC_New, so no C++ initialization is 
performed. Given this constraint, I am not sure that this intermediate class would work.
I haven't tried to check.

Additionally, for the types requiring a __dict__, I noticed that all those inheritances cause more 
issues than it helps.

> Matthieu> I don't expect a thorough review of all the code, but a
> Matthieu> validation of the approach.
> 
> I'll try to send more next week.
> 
> 
> Tom

Matthieu

  reply	other threads:[~2026-06-22  9:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 16:24 Matthieu Longo via Gdb
2026-05-28 16:31 ` Matthieu Longo via Gdb
2026-06-01 10:10   ` Matthieu Longo via Gdb
2026-06-08 13:38     ` Matthieu Longo via Gdb
2026-06-10 16:10       ` Andrew Burgess via Gdb
2026-06-16 17:15         ` Matthieu Longo via Gdb
2026-06-18 20:46           ` Tom Tromey
2026-06-22  9:26             ` Matthieu Longo via Gdb [this message]
2026-06-29 10:37               ` Matthieu Longo via Gdb
2026-06-22 10:24 ` Matthieu Longo via Gdb

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=f108eac4-ab90-41e5-9c2c-d6d07b217105@arm.com \
    --to=gdb@sourceware.org \
    --cc=aburgess@redhat.com \
    --cc=matthieu.longo@arm.com \
    --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