]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: make remaining Python extension objects inherit from PyObject
authorMatthieu Longo <matthieu.longo@arm.com>
Tue, 27 Jan 2026 12:33:42 +0000 (12:33 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Thu, 29 Jan 2026 16:46:14 +0000 (16:46 +0000)
Previous patches made some Python extension objects ipublicly inherit
directly or indirectly from PyObject.
In the interest of consistency, this patch makes all remaining Python
extension objects still not inheriting from PyObject do so.

Approved-By: Tom Tromey <tom@tromey.com>
16 files changed:
gdb/python/py-arch.c
gdb/python/py-block.c
gdb/python/py-disasm.c
gdb/python/py-instruction.c
gdb/python/py-lazy-string.c
gdb/python/py-linetable.c
gdb/python/py-param.c
gdb/python/py-prettyprint.c
gdb/python/py-record-btrace.c
gdb/python/py-record.c
gdb/python/py-record.h
gdb/python/py-registers.c
gdb/python/py-style.c
gdb/python/py-type.c
gdb/python/py-unwind.c
gdb/python/py-value.c

index 765a21ae0b798d85cde66175121a81481196fd1d..eb4a7c63530db878902b353e15c3b76f1da15286 100644 (file)
@@ -22,8 +22,8 @@
 #include "disasm.h"
 #include "python-internal.h"
 
-struct arch_object {
-  PyObject_HEAD
+struct arch_object : public PyObject
+{
   struct gdbarch *gdbarch;
 };
 
index 3a59d767b5c2b1acf39ffce3ff4a50ee273bb57a..bebbb32d844b410e31b3d4ccf613906100829942 100644 (file)
@@ -23,8 +23,8 @@
 #include "python-internal.h"
 #include "objfiles.h"
 
-struct block_object {
-  PyObject_HEAD
+struct block_object : public PyObject
+{
   /* The GDB block structure that represents a frame's code block.  */
   const struct block *block;
   /* The backing object file.  There is no direct relationship in GDB
@@ -33,8 +33,8 @@ struct block_object {
   struct objfile *objfile;
 };
 
-struct block_syms_iterator_object {
-  PyObject_HEAD
+struct block_syms_iterator_object : public PyObject
+{
   /* The block.  */
   const struct block *block;
   /* The iterator for that block.  */
index a125907948c9ef08570a0443ef4041ee3550c80c..9f5d0e2fdcbfbaa48cfc6678f7829d4dd43601ba 100644 (file)
@@ -57,10 +57,8 @@ extern PyTypeObject disasm_info_object_type;
    that is an address that should be printed using a call to GDB's
    internal print_address function.  */
 
-struct disasm_addr_part_object
+struct disasm_addr_part_object : public PyObject
 {
-  PyObject_HEAD
-
   /* The address to be formatted.  */
   bfd_vma address;
 
@@ -77,10 +75,8 @@ extern PyTypeObject disasm_addr_part_object_type;
    this type represents a small part of a disassembled instruction; a part
    that is a piece of test along with an associated style.  */
 
-struct disasm_text_part_object
+struct disasm_text_part_object : public PyObject
 {
-  PyObject_HEAD
-
   /* The string that is this part.  */
   std::string *string;
 
index b7ab6e4668f51e507454c371eb54274d23853fe5..df64d85988fecdc8f4f9e4498d0d80ee0aaf964a 100644 (file)
@@ -29,9 +29,8 @@ PyTypeObject py_insn_type = {
 
 /* Python instruction object.  */
 
-struct py_insn_obj {
-  PyObject_HEAD
-};
+struct py_insn_obj: public PyObject
+{};
 
 /* Getter function for gdb.Instruction attributes.  */
 
index 41f958744c1d5e13b0d389cf34591f4d895ed4eb..58cdea69f565b3d279a537abbe4d966ffba2098c 100644 (file)
@@ -23,9 +23,8 @@
 #include "valprint.h"
 #include "language.h"
 
-struct lazy_string_object {
-  PyObject_HEAD
-
+struct lazy_string_object : public PyObject
+{
   /*  Holds the address of the lazy string.  */
   CORE_ADDR address;
 
index 0ea2d843dd34f6a629f6a6ccfa19462b2da3e2cb..384ced68a321e32bbac749de824292a91f83a581 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "python-internal.h"
 
-struct linetable_entry_object {
-  PyObject_HEAD
+struct linetable_entry_object : public PyObject
+{
   /* The line table source line.  */
   int line;
   /* The pc associated with the source line.  */
@@ -29,8 +29,8 @@ struct linetable_entry_object {
 
 extern PyTypeObject linetable_entry_object_type;
 
-struct linetable_object {
-  PyObject_HEAD
+struct linetable_object : public PyObject
+{
   /* The symtab python object.  We store the Python object here as the
      underlying symtab can become invalid, and we have to run validity
      checks on it.  */
@@ -39,8 +39,8 @@ struct linetable_object {
 
 extern PyTypeObject linetable_object_type;
 
-struct ltpy_iterator_object {
-  PyObject_HEAD
+struct ltpy_iterator_object : public PyObject
+{
   /* The current entry in the line table for the iterator  */
   int current_index;
   /* Pointer back to the original source line table object.  Needed to
index f305661fa4318fcf027fa40fcbb5f7b041325d3c..8765b1b383d1c6939cd74a95fc9cea966d5018f8 100644 (file)
@@ -124,10 +124,8 @@ union parmpy_variable
 };
 
 /* A GDB parameter.  */
-struct parmpy_object
+struct parmpy_object : public PyObject
 {
-  PyObject_HEAD
-
   /* The type of the parameter.  */
   enum var_types type;
 
index a920e6f3cf76fe7b2d8424506197e935e4cfbe8a..6900bf645857942bc49d20aa2c720ba1997531cd 100644 (file)
@@ -783,10 +783,8 @@ gdbpy_get_print_options (value_print_options *opts)
 
 /* A ValuePrinter is just a "tag", so it has no state other than that
    required by Python.  */
-struct printer_object
-{
-  PyObject_HEAD
-};
+struct printer_object : public PyObject
+{};
 
 /* The ValuePrinter type object.  */
 PyTypeObject printer_object_type =
index d9534c02331c661a404c95375eb563bdee9c24b8..3fcf653f4ba97271ad4132ae373311bcf22a997a 100644 (file)
@@ -29,9 +29,8 @@
 
 /* Python object for btrace record lists.  */
 
-struct btpy_list_object {
-  PyObject_HEAD
-
+struct btpy_list_object : public PyObject
+{
   /* The thread this list belongs to.  */
   thread_info *thread;
 
index 3c985c172e12cffb9882c624fd0be2b0a223ba29..294da0725e10e10d241bc35c06f116deea326804 100644 (file)
@@ -55,10 +55,8 @@ PyTypeObject recpy_aux_type = {
 };
 
 /* Python RecordGap object.  */
-struct recpy_gap_object
+struct recpy_gap_object : public PyObject
 {
-  PyObject_HEAD
-
   /* Reason code.  */
   int reason_code;
 
index 039a1b125e3e6e452bf02f2d6d1d6f162e801e84..35ab54cf6abf35ebe5925a5e2c1d64005a2946d1 100644 (file)
 #include "record.h"
 
 /* Python Record object.  */
-struct recpy_record_object
+struct recpy_record_object : public PyObject
 {
-  PyObject_HEAD
-
   /* The thread this object refers to.  */
   thread_info *thread;
 
@@ -39,10 +37,8 @@ struct recpy_record_object
 /* Python recorded element object.  This is generic enough to represent
    recorded instructions as well as recorded function call segments, hence the
    generic name.  */
-struct recpy_element_object
+struct recpy_element_object : public PyObject
 {
-  PyObject_HEAD
-
   /* The thread this object refers to.  */
   thread_info *thread;
 
index 3d1683805d1ff378a8f8a7f9a0ea350114fea0e9..0ec708364ddc89c48cf7793292798aa8ba4e4fe7 100644 (file)
@@ -32,9 +32,8 @@ static const registry<gdbarch>::key<gdbpy_register_type>
      gdbpy_register_object_data;
 
 /* Structure for iterator over register descriptors.  */
-struct register_descriptor_iterator_object {
-  PyObject_HEAD
-
+struct register_descriptor_iterator_object : public PyObject
+{
   /* The register group that the user is iterating over.  This will never
      be NULL.  */
   const struct reggroup *reggroup;
@@ -61,9 +60,8 @@ struct register_descriptor_object : public PyObject
 extern PyTypeObject register_descriptor_object_type;
 
 /* Structure for iterator over register groups.  */
-struct reggroup_iterator_object {
-  PyObject_HEAD
-
+struct reggroup_iterator_object : public PyObject
+{
   /* The index into GROUPS for the next group to return.  */
   std::vector<const reggroup *>::size_type index;
 
index f404864251c81f48842dc446ecc551c6325cac18..aa6eccaadbe301ea72020a8ebbe6e856404d8b97 100644 (file)
@@ -36,10 +36,8 @@ static struct {
 };
 
 /* A style.  */
-struct style_object
+struct style_object : public PyObject
 {
-  PyObject_HEAD
-
   /* Underlying style, only valid when STYLE_NAME is NULL.  */
   ui_file_style style;
 
index 76f001b99da4fdc71dba82bd13279b4a6ba97cc9..d1ebe852eaacbafb971b1856f73104b8b9dd03d2 100644 (file)
@@ -42,8 +42,8 @@ struct field_object : public gdbpy_dict_wrapper
 extern PyTypeObject field_object_type;
 
 /* A type iterator object.  */
-struct typy_iterator_object {
-  PyObject_HEAD
+struct typy_iterator_object : public PyObject
+{
   /* The current field index.  */
   int field;
   /* What to return.  */
index f9fd848ea0e9dd772ffaff226ba8a02065e5727c..7c0779a82708d153f40353aa8f12b92ff6d25888 100644 (file)
@@ -66,10 +66,8 @@ show_pyuw_debug (struct ui_file *file, int from_tty,
       }                                                             \
   } while (0)
 
-struct pending_frame_object
+struct pending_frame_object : public PyObject
 {
-  PyObject_HEAD
-
   /* Frame we are unwinding.  */
   frame_info_ptr frame_info;
 
@@ -94,10 +92,8 @@ struct saved_reg
 /* The data we keep for the PyUnwindInfo: pending_frame, saved registers
    and frame ID.  */
 
-struct unwind_info_object
+struct unwind_info_object : public PyObject
 {
-  PyObject_HEAD
-
   /* gdb.PendingFrame for the frame we are unwinding.  */
   PyObject *pending_frame;
 
index f6fdb7e508064682a2a51ab993c87633fd7bba40..e19be1d2701b4bc17c4912864ce9a4074b4cce9d 100644 (file)
@@ -54,8 +54,8 @@
 #define builtin_type_pybool \
   language_bool_type (current_language, gdbpy_enter::get_gdbarch ())
 
-struct value_object {
-  PyObject_HEAD
+struct value_object : public PyObject
+{
   struct value_object *next;
   struct value_object *prev;
   struct value *value;