From: Matthieu Longo Date: Tue, 27 Jan 2026 12:33:42 +0000 (+0000) Subject: gdb: make remaining Python extension objects inherit from PyObject X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91bf037a394e4bc1dc885aed39fc745fd516fe56;p=thirdparty%2Fbinutils-gdb.git gdb: make remaining Python extension objects inherit from PyObject 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 --- diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 765a21ae0b7..eb4a7c63530 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -22,8 +22,8 @@ #include "disasm.h" #include "python-internal.h" -struct arch_object { - PyObject_HEAD +struct arch_object : public PyObject +{ struct gdbarch *gdbarch; }; diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index 3a59d767b5c..bebbb32d844 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -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. */ diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c index a125907948c..9f5d0e2fdcb 100644 --- a/gdb/python/py-disasm.c +++ b/gdb/python/py-disasm.c @@ -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; diff --git a/gdb/python/py-instruction.c b/gdb/python/py-instruction.c index b7ab6e4668f..df64d85988f 100644 --- a/gdb/python/py-instruction.c +++ b/gdb/python/py-instruction.c @@ -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. */ diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 41f958744c1..58cdea69f56 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -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; diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index 0ea2d843dd3..384ced68a32 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -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 diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index f305661fa43..8765b1b383d 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -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; diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index a920e6f3cf7..6900bf64585 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -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 = diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index d9534c02331..3fcf653f4ba 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -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; diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c index 3c985c172e1..294da0725e1 100644 --- a/gdb/python/py-record.c +++ b/gdb/python/py-record.c @@ -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; diff --git a/gdb/python/py-record.h b/gdb/python/py-record.h index 039a1b125e3..35ab54cf6ab 100644 --- a/gdb/python/py-record.h +++ b/gdb/python/py-record.h @@ -25,10 +25,8 @@ #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; diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c index 3d1683805d1..0ec708364dd 100644 --- a/gdb/python/py-registers.c +++ b/gdb/python/py-registers.c @@ -32,9 +32,8 @@ static const registry::key 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::size_type index; diff --git a/gdb/python/py-style.c b/gdb/python/py-style.c index f404864251c..aa6eccaadbe 100644 --- a/gdb/python/py-style.c +++ b/gdb/python/py-style.c @@ -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; diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 76f001b99da..d1ebe852eaa 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -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. */ diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index f9fd848ea0e..7c0779a8270 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -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; diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index f6fdb7e5080..e19be1d2701 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -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;