Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 0/3] Use C++ type traits check to catch bugs in Python API
Date: Fri, 15 May 2026 11:00:45 +0100	[thread overview]
Message-ID: <cover.1778839043.git.aburgess@redhat.com> (raw)

While looking at a bug with the Python API I realised that we could
make use of static_assert and C++ type traits to catch this class of
bug.

This series has 3 patches, #1 adds the static_assert check to every
place in GDB where we don't currently have a bug.  Patch #2 fixes an
existing bug in GDB, and then adds the final static_assert which
covers this case.  Patch #3 adds a new test that scans the GDB source
code to make sure that there is a suitable static_assert for every
PyObject sub-class, this ensures the static_assert will be added to
any new code going forward.

Thanks,
Andrew

---

Andrew Burgess (3):
  gdb/python: add type traits check for all PyObject sub-classes
  gdb/python: fix use of frame_info_ptr within pending_frame_object
  gdb/testsuite: add a test to check for Python traits static_assert

 gdb/python/py-arch.c                          |   2 +
 gdb/python/py-block.c                         |   4 +
 gdb/python/py-breakpoint.c                    |   2 +
 gdb/python/py-cmd.c                           |   2 +
 gdb/python/py-color.c                         |   2 +
 gdb/python/py-connection.c                    |   2 +
 gdb/python/py-corefile.c                      |   4 +
 gdb/python/py-disasm.c                        |   8 +
 gdb/python/py-events.h                        |   2 +
 gdb/python/py-frame.c                         |   2 +
 gdb/python/py-instruction.c                   |   2 +
 gdb/python/py-lazy-string.c                   |   2 +
 gdb/python/py-linetable.c                     |   6 +
 gdb/python/py-membuf.c                        |   2 +
 gdb/python/py-micmd.c                         |   2 +
 gdb/python/py-param.c                         |   2 +
 gdb/python/py-prettyprint.c                   |   2 +
 gdb/python/py-record-btrace.c                 |   2 +
 gdb/python/py-record.c                        |   2 +
 gdb/python/py-record.h                        |   4 +
 gdb/python/py-ref.h                           |   3 +
 gdb/python/py-registers.c                     |   8 +
 gdb/python/py-style.c                         |   2 +
 gdb/python/py-symbol.c                        |   2 +
 gdb/python/py-symtab.c                        |   4 +
 gdb/python/py-tui.c                           |   2 +
 gdb/python/py-type.c                          |   4 +
 gdb/python/py-unwind.c                        |  55 +++---
 gdb/python/py-value.c                         |   2 +
 gdb/python/python-internal.h                  |   2 +
 gdb/python/python-traits.h                    |  92 +++++++++++
 gdb/testsuite/gdb.gdb/python-traits-check.exp | 156 ++++++++++++++++++
 32 files changed, 368 insertions(+), 20 deletions(-)
 create mode 100644 gdb/python/python-traits.h
 create mode 100644 gdb/testsuite/gdb.gdb/python-traits-check.exp


base-commit: 80491726b42ff67e06e07068e0e29b66b7595a73
-- 
2.25.4


             reply	other threads:[~2026-05-15 10:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 10:00 Andrew Burgess [this message]
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
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=cover.1778839043.git.aburgess@redhat.com \
    --to=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