From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/3] gdb/python: add type traits check for all PyObject sub-classes
Date: Fri, 15 May 2026 11:10:58 -0600 [thread overview]
Message-ID: <87tss8ha3h.fsf@tromey.com> (raw)
In-Reply-To: <491de87828ea40daa77a485da4e14e476e0c7a1d.1778839043.git.aburgess@redhat.com> (Andrew Burgess's message of "Fri, 15 May 2026 11:00:46 +0100")
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
Andrew> The problem is that Python is written in C, and PyObject_New doesn't
Andrew> call any constructors for `some_new_type`, nor for any of the fields
Andrew> within `some_new_type`.
Since working on the Python safety series, I have been wondering if we
could remedy this. That is, give gdb's classes constructors and
destructors and arrange for these to be called in-place in tp_init /
whatever the destroy one is.
This way we could use idiomatic gdb code, which would be safer.
I was planning to investigate this more deeply once Matthew Longo's work
was done, since I didn't want to touch all the type objects and cause
conflicts.
Andrew> +
Andrew> +template <typename T>
Andrew> +struct is_python_allocatable {
Andrew> + static constexpr bool value =
Andrew> + std::is_trivially_destructible_v<T> &&
Andrew> + std::is_trivially_copyable_v<T>;
Brace and operator placement.
Otherwise this looks good to me.
If the tp_init experiment works out I suppose we may end up reverting
this. But IMO it's best not to wait on something that might not happen.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
next prev parent reply other threads:[~2026-05-15 17:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 10:00 [PATCH 0/3] Use C++ type traits check to catch bugs in Python API Andrew Burgess
2026-05-15 10:00 ` [PATCH 1/3] gdb/python: add type traits check for all PyObject sub-classes Andrew Burgess
2026-05-15 17:10 ` Tom Tromey [this message]
2026-05-16 12:27 ` Andrew Burgess
2026-05-15 10:00 ` [PATCH 2/3] gdb/python: fix use of frame_info_ptr within pending_frame_object Andrew Burgess
2026-05-15 17:22 ` Tom Tromey
2026-05-16 12:28 ` Andrew Burgess
2026-05-15 10:00 ` [PATCH 3/3] gdb/testsuite: add a test to check for Python traits static_assert Andrew Burgess
2026-05-15 17:31 ` Tom Tromey
2026-05-16 12:29 ` Andrew Burgess
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=87tss8ha3h.fsf@tromey.com \
--to=tom@tromey.com \
--cc=aburgess@redhat.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