From: Tom Tromey Date: Tue, 21 Oct 2025 16:00:20 +0000 (-0600) Subject: Remove Python API checker defines X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8eeb52e3c7701f03711d51a2209c39d85d109500;p=thirdparty%2Fbinutils-gdb.git Remove Python API checker defines The GCC plugin that implements the Python API checker does not appear to really be maintained. And, as far as I know, it never really worked for C++ code anyway. Considering those factors, and that no one has tried to run it in years, I think it's time to remove the macros from the gdb source. Approved-By: Simon Marchi --- diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 2bf6251a7cb..400c99f2c7a 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -42,8 +42,7 @@ static const registry::key> } \ } while (0) -extern PyTypeObject arch_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("arch_object"); +extern PyTypeObject arch_object_type; /* Associates an arch_object with GDBARCH as gdbarch_data via the gdbarch post init registration mechanism (gdbarch_data_register_post_init). */ @@ -368,8 +367,8 @@ gdbpy_all_architecture_names (PyObject *self, PyObject *args) /* Initializes the Architecture class in the gdb module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_arch (void) +static int +gdbpy_initialize_arch () { arch_object_type.tp_new = PyType_GenericNew; return gdbpy_type_ready (&arch_object_type); diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c index f65b9792e8e..ef030fe7bd5 100644 --- a/gdb/python/py-auto-load.c +++ b/gdb/python/py-auto-load.c @@ -56,8 +56,8 @@ info_auto_load_python_scripts (const char *pattern, int from_tty) &extension_language_python); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_auto_load (void) +static int +gdbpy_initialize_auto_load () { add_setshow_boolean_cmd ("python-scripts", class_support, &auto_load_python_scripts, _("\ diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index 66ccad7e873..cf7b7b31518 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -72,8 +72,7 @@ struct block_syms_iterator_object { } \ } while (0) -extern PyTypeObject block_syms_iterator_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_syms_iterator_object"); +extern PyTypeObject block_syms_iterator_object_type; static const registry::key blpy_objfile_data_key; @@ -523,8 +522,8 @@ blpy_richcompare (PyObject *self, PyObject *other, int op) return PyBool_FromLong (equal == expected); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_blocks (void) +static int +gdbpy_initialize_blocks () { block_object_type.tp_new = PyType_GenericNew; if (gdbpy_type_ready (&block_object_type) < 0) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 9ce867160c4..9fd1fd013d2 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -35,8 +35,7 @@ #include "linespec.h" #include "gdbsupport/common-utils.h" -extern PyTypeObject breakpoint_location_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_location_object"); +extern PyTypeObject breakpoint_location_object_type; struct gdbpy_breakpoint_location_object { @@ -1353,8 +1352,8 @@ gdbpy_breakpoint_modified (struct breakpoint *b) /* Initialize the Python breakpoint code. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_breakpoints (void) +static int +gdbpy_initialize_breakpoints () { int i; @@ -1389,7 +1388,7 @@ gdbpy_initialize_breakpoints (void) /* Initialize the Python BreakpointLocation code. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION +static int gdbpy_initialize_breakpoint_locations () { return gdbpy_type_ready (&breakpoint_location_object_type); diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index dc5e2700059..54bac97146e 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -65,8 +65,7 @@ struct cmdpy_object struct cmd_list_element *sub_list; }; -extern PyTypeObject cmdpy_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("cmdpy_object"); +extern PyTypeObject cmdpy_object_type; /* Constants used by this module. */ static PyObject *invoke_cst; @@ -595,8 +594,8 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) /* Initialize the 'commands' code. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_commands (void) +static int +gdbpy_initialize_commands () { int i; diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c index a6d9ad09037..a64f12450d8 100644 --- a/gdb/python/py-connection.c +++ b/gdb/python/py-connection.c @@ -44,11 +44,9 @@ struct connection_object struct process_stratum_target *target; }; -extern PyTypeObject connection_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("connection_object"); +extern PyTypeObject connection_object_type; -extern PyTypeObject remote_connection_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("remote_connection_object"); +extern PyTypeObject remote_connection_object_type; /* Require that CONNECTION be valid. */ #define CONNPY_REQUIRE_VALID(connection) \ @@ -283,8 +281,8 @@ connpy_get_connection_details (PyObject *self, void *closure) /* Python specific initialization for this file. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_connection (void) +static int +gdbpy_initialize_connection () { if (gdbpy_type_ready (&connection_object_type) < 0) return -1; diff --git a/gdb/python/py-corefile.c b/gdb/python/py-corefile.c index 97f42427af1..244a3992cae 100644 --- a/gdb/python/py-corefile.c +++ b/gdb/python/py-corefile.c @@ -47,8 +47,7 @@ struct corefile_object PyObject *mapped_files; }; -extern PyTypeObject corefile_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("corefile_object"); +extern PyTypeObject corefile_object_type; /* A gdb.CorefileMapped object. */ @@ -73,8 +72,7 @@ struct corefile_mapped_file_object bool is_main_exec_p; }; -extern PyTypeObject corefile_mapped_file_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("corefile_mapped_file_object"); +extern PyTypeObject corefile_mapped_file_object_type; /* A gdb.CorefileMappedFileRegion object. */ @@ -91,8 +89,7 @@ struct corefile_mapped_file_region_object ULONGEST file_offset; }; -extern PyTypeObject corefile_mapped_file_region_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("corefile_mapped_file_region_object"); +extern PyTypeObject corefile_mapped_file_region_object_type; /* Clear the inferior pointer in a Corefile object OBJ when an inferior is deleted. */ diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c index 47ae99cb71c..c4d409eac7d 100644 --- a/gdb/python/py-disasm.c +++ b/gdb/python/py-disasm.c @@ -52,8 +52,7 @@ struct disasm_info_object struct disasm_info_object *next; }; -extern PyTypeObject disasm_info_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_info_object"); +extern PyTypeObject disasm_info_object_type; /* Implement gdb.disassembler.DisassembleAddressPart type. An object of this type represents a small part of a disassembled instruction; a part @@ -74,8 +73,7 @@ struct disasm_addr_part_object struct gdbarch *gdbarch; }; -extern PyTypeObject disasm_addr_part_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_addr_part_object"); +extern PyTypeObject disasm_addr_part_object_type; /* Implement gdb.disassembler.DisassembleTextPart type. An object of this type represents a small part of a disassembled instruction; a part @@ -92,11 +90,9 @@ struct disasm_text_part_object enum disassembler_style style; }; -extern PyTypeObject disasm_text_part_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_text_part_object"); +extern PyTypeObject disasm_text_part_object_type; -extern PyTypeObject disasm_part_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("PyObject"); +extern PyTypeObject disasm_part_object_type; /* Implement gdb.disassembler.DisassemblerResult type, an object that holds the result of calling the disassembler. This is mostly the length of @@ -115,8 +111,7 @@ struct disasm_result_object std::vector> *parts; }; -extern PyTypeObject disasm_result_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("disasm_result_object"); +extern PyTypeObject disasm_result_object_type; /* When this is false we fast path out of gdbpy_print_insn, which should keep the performance impact of the Python disassembler down. This is @@ -1627,7 +1622,7 @@ static struct PyModuleDef python_disassembler_module_def = /* Called to initialize the Python structures in this file. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION +static int gdbpy_initialize_disasm () { /* Create the _gdb.disassembler module, and add it to the _gdb module. */ diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c index da3b52c17b0..0dc98867a94 100644 --- a/gdb/python/py-event.c +++ b/gdb/python/py-event.c @@ -53,8 +53,8 @@ evpy_add_attribute (PyObject *event, const char *name, PyObject *attr) /* Initialize the Python event code. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_event (void) +static int +gdbpy_initialize_event () { return gdbpy_type_ready (&event_object_type); } diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h index 3938368c9ca..54fbf45bf01 100644 --- a/gdb/python/py-event.h +++ b/gdb/python/py-event.h @@ -27,8 +27,7 @@ /* Declare all event types. */ #define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \ - extern PyTypeObject name##_event_object_type \ - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object"); + extern PyTypeObject name##_event_object_type; #include "py-event-types.def" #undef GDB_PY_DEFINE_EVENT_TYPE @@ -82,7 +81,6 @@ extern int emit_clear_objfiles_event (program_space *pspace); extern void evpy_dealloc (PyObject *self); extern int evpy_add_attribute (PyObject *event, - const char *name, PyObject *attr) - CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION; + const char *name, PyObject *attr); #endif /* GDB_PYTHON_PY_EVENT_H */ diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c index 2166f75b19d..8f5993f824e 100644 --- a/gdb/python/py-evtregistry.c +++ b/gdb/python/py-evtregistry.c @@ -22,8 +22,7 @@ events_object gdb_py_events; -extern PyTypeObject eventregistry_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("eventregistry_object"); +extern PyTypeObject eventregistry_object_type; /* Implementation of EventRegistry.connect () -> NULL. Add FUNCTION to the list of listeners. */ @@ -101,8 +100,8 @@ evregpy_dealloc (PyObject *self) /* Initialize the Python event registry code. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_eventregistry (void) +static int +gdbpy_initialize_eventregistry () { return gdbpy_type_ready (&eventregistry_object_type); } diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c index c9059268b73..73a1f08c5b5 100644 --- a/gdb/python/py-evts.c +++ b/gdb/python/py-evts.c @@ -35,7 +35,7 @@ static struct PyModuleDef EventModuleDef = /* Helper function to add a single event registry to the events module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION +static int add_new_registry (eventregistry_object **registryp, const char *name) { *registryp = create_eventregistry_object (); diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 75224b6d2d7..2bf8a8f9db9 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -61,8 +61,7 @@ struct finish_breakpoint_object struct frame_id initiating_frame; }; -extern PyTypeObject finish_breakpoint_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("finish_breakpoint_object"); +extern PyTypeObject finish_breakpoint_object_type; /* Python function to get the 'return_value' attribute of FinishBreakpoint. */ @@ -433,8 +432,8 @@ bpfinishpy_handle_exit (struct inferior *inf) /* Initialize the Python finish breakpoint code. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_finishbreakpoints (void) +static int +gdbpy_initialize_finishbreakpoints () { if (!gdbpy_breakpoint_init_breakpoint_type ()) return -1; diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 722a952d367..e30def81496 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -757,8 +757,8 @@ frapy_richcompare (PyObject *self, PyObject *other, int op) /* Sets up the Frame API in the gdb module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_frames (void) +static int +gdbpy_initialize_frames () { frame_object_type.tp_new = PyType_GenericNew; if (gdbpy_type_ready (&frame_object_type) < 0) diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c index 86a2f3005ea..9105bc5e7bc 100644 --- a/gdb/python/py-function.c +++ b/gdb/python/py-function.c @@ -27,8 +27,7 @@ #include "expression.h" #include "language.h" -extern PyTypeObject fnpy_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("PyObject"); +extern PyTypeObject fnpy_object_type; @@ -135,8 +134,8 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) /* Initialize internal function support. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_functions (void) +static int +gdbpy_initialize_functions () { fnpy_object_type.tp_new = PyType_GenericNew; return gdbpy_type_ready (&fnpy_object_type); diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index 70ceebb36a1..21503168725 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -82,8 +82,8 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, /* Initialize Python readline support. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_gdb_readline (void) +static int +gdbpy_initialize_gdb_readline () { /* Python's readline module conflicts with GDB's use of readline since readline is not reentrant. Ideally, a reentrant wrapper to diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index d926923915a..0351a646a20 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -51,8 +51,7 @@ struct inferior_object PyObject *dict; }; -extern PyTypeObject inferior_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("inferior_object"); +extern PyTypeObject inferior_object_type; /* Deleter to clean up when an inferior is removed. */ struct infpy_deleter @@ -1022,8 +1021,8 @@ gdbpy_selected_inferior (PyObject *self, PyObject *args) inferior_to_inferior_object (current_inferior ()).release ()); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_inferior (void) +static int +gdbpy_initialize_inferior () { if (gdbpy_type_ready (&inferior_object_type) < 0) return -1; diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 08533fe2923..cdbfd40cc4a 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -21,8 +21,7 @@ #include "inferior.h" #include "python-internal.h" -extern PyTypeObject thread_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object"); +extern PyTypeObject thread_object_type; /* Require that INFERIOR be a valid inferior ID. */ #define THPY_REQUIRE_VALID(Thread) \ @@ -404,8 +403,8 @@ gdbpy_selected_thread (PyObject *self, PyObject *args) Py_RETURN_NONE; } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_thread (void) +static int +gdbpy_initialize_thread () { return gdbpy_type_ready (&thread_object_type); } diff --git a/gdb/python/py-instruction.c b/gdb/python/py-instruction.c index 60cd561b19a..a925239ca15 100644 --- a/gdb/python/py-instruction.c +++ b/gdb/python/py-instruction.c @@ -80,8 +80,8 @@ py_insn_get_insn_type () /* Sets up the gdb.Instruction type. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_instruction (void) +static int +gdbpy_initialize_instruction () { if (py_insn_get_insn_type () == nullptr) return -1; diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 265f34a9cdb..b12e82de63d 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -52,8 +52,7 @@ struct lazy_string_object { PyObject *type; }; -extern PyTypeObject lazy_string_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("lazy_string_object"); +extern PyTypeObject lazy_string_object_type; static PyObject * stpy_get_address (PyObject *self, void *closure) @@ -242,8 +241,8 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length, return (PyObject *) str_obj; } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_lazy_string (void) +static int +gdbpy_initialize_lazy_string () { return gdbpy_type_ready (&lazy_string_object_type); } diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index 90cba09c88e..f575305ed94 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -27,8 +27,7 @@ struct linetable_entry_object { CORE_ADDR pc; }; -extern PyTypeObject linetable_entry_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("linetable_entry_object"); +extern PyTypeObject linetable_entry_object_type; struct linetable_object { PyObject_HEAD @@ -38,8 +37,7 @@ struct linetable_object { PyObject *symtab; }; -extern PyTypeObject linetable_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("linetable_object"); +extern PyTypeObject linetable_object_type; struct ltpy_iterator_object { PyObject_HEAD @@ -51,8 +49,7 @@ struct ltpy_iterator_object { PyObject *source; }; -extern PyTypeObject ltpy_iterator_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("ltpy_iterator_object"); +extern PyTypeObject ltpy_iterator_object_type; /* Internal helper function to extract gdb.Symtab from a gdb.LineTable object. */ @@ -284,8 +281,8 @@ ltpy_dealloc (PyObject *self) /* Initialize LineTable, LineTableEntry and LineTableIterator objects. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_linetable (void) +static int +gdbpy_initialize_linetable () { if (gdbpy_type_ready (&linetable_object_type) < 0) return -1; diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c index 817dfba5138..ce8113f9073 100644 --- a/gdb/python/py-membuf.c +++ b/gdb/python/py-membuf.c @@ -32,8 +32,7 @@ struct membuf_object { CORE_ADDR length; }; -extern PyTypeObject membuf_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("membuf_object"); +extern PyTypeObject membuf_object_type; /* Wrap BUFFER, ADDRESS, and LENGTH into a gdb.Membuf object. ADDRESS is the address within the inferior that the contents of BUFFER were read, @@ -98,8 +97,8 @@ get_buffer (PyObject *self, Py_buffer *buf, int flags) /* General Python initialization callback. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_membuf (void) +static int +gdbpy_initialize_membuf () { membuf_object_type.tp_new = PyType_GenericNew; return gdbpy_type_ready (&membuf_object_type); diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c index 07db0cca50d..d160b2b2788 100644 --- a/gdb/python/py-micmd.c +++ b/gdb/python/py-micmd.c @@ -165,8 +165,7 @@ private: using mi_command_py_up = std::unique_ptr; -extern PyTypeObject micmdpy_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("micmdpy_object"); +extern PyTypeObject micmdpy_object_type; /* Holds a Python object containing the string 'invoke'. */ @@ -443,7 +442,7 @@ micmdpy_dealloc (PyObject *obj) /* Python initialization for the MI commands components. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION +static int gdbpy_initialize_micommands () { micmdpy_object_type.tp_new = PyType_GenericNew; diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index a9f5754cfa5..04270bc4aef 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -53,8 +53,7 @@ struct objfile_object PyObject *xmethods; }; -extern PyTypeObject objfile_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("objfile_object"); +extern PyTypeObject objfile_object_type; /* Clear the OBJFILE pointer in an Objfile object and remove the reference. */ @@ -704,8 +703,8 @@ objfile_to_objfile_object (struct objfile *objfile) return gdbpy_ref<>::new_reference (result); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_objfile (void) +static int +gdbpy_initialize_objfile () { return gdbpy_type_ready (&objfile_object_type); } diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index e391fd339c5..7ba00704e05 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -170,8 +170,7 @@ make_setting (parmpy_object *s) gdb_assert_not_reached ("unhandled var type"); } -extern PyTypeObject parmpy_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object"); +extern PyTypeObject parmpy_object_type; /* Some handy string constants. */ static PyObject *set_doc_cst; @@ -953,8 +952,8 @@ parmpy_dealloc (PyObject *obj) } /* Initialize the 'parameters' module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_parameters (void) +static int +gdbpy_initialize_parameters () { int i; diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index 7ca9d88bbd2..15190ebff90 100644 --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -59,8 +59,7 @@ struct pspace_object PyObject *missing_file_handlers; }; -extern PyTypeObject pspace_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pspace_object"); +extern PyTypeObject pspace_object_type; /* Clear the PSPACE pointer in a Pspace object and remove the reference. */ struct pspace_deleter @@ -737,8 +736,8 @@ gdbpy_free_program_space_event (program_space *pspace) gdbpy_program_space_event (pspace, false); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_pspace (void) +static int +gdbpy_initialize_pspace () { gdb::observers::executable_changed.attach (gdbpy_executable_changed, "py-progspace"); diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 7acf70ec83b..3fa3b8da945 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -987,8 +987,8 @@ static PyMappingMethods btpy_list_mapping_methods = /* Sets up the btrace record API. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_btrace (void) +static int +gdbpy_initialize_btrace () { btpy_list_type.tp_new = PyType_GenericNew; btpy_list_type.tp_flags = Py_TPFLAGS_DEFAULT; diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c index 89c2e7745e5..09a2f520bb5 100644 --- a/gdb/python/py-record.c +++ b/gdb/python/py-record.c @@ -607,8 +607,8 @@ static gdb_PyGetSetDef recpy_aux_getset[] = { /* Sets up the record API in the gdb module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_record (void) +static int +gdbpy_initialize_record () { recpy_record_type.tp_new = PyType_GenericNew; recpy_record_type.tp_flags = Py_TPFLAGS_DEFAULT; diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c index 9be2e3ceaf5..a3f8357e075 100644 --- a/gdb/python/py-registers.c +++ b/gdb/python/py-registers.c @@ -46,8 +46,7 @@ struct register_descriptor_iterator_object { struct gdbarch *gdbarch; }; -extern PyTypeObject register_descriptor_iterator_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("register_descriptor_iterator_object"); +extern PyTypeObject register_descriptor_iterator_object_type; /* A register descriptor. */ struct register_descriptor_object { @@ -60,8 +59,7 @@ struct register_descriptor_object { struct gdbarch *gdbarch; }; -extern PyTypeObject register_descriptor_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("register_descriptor_object"); +extern PyTypeObject register_descriptor_object_type; /* Structure for iterator over register groups. */ struct reggroup_iterator_object { @@ -74,8 +72,7 @@ struct reggroup_iterator_object { struct gdbarch *gdbarch; }; -extern PyTypeObject reggroup_iterator_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("reggroup_iterator_object"); +extern PyTypeObject reggroup_iterator_object_type; /* A register group object. */ struct reggroup_object { @@ -85,8 +82,7 @@ struct reggroup_object { const struct reggroup *reggroup; }; -extern PyTypeObject reggroup_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("reggroup_object"); +extern PyTypeObject reggroup_object_type; /* Return a gdb.RegisterGroup object wrapping REGGROUP. The register group objects are cached, and the same Python object will always be @@ -425,7 +421,7 @@ gdbpy_parse_register_id (struct gdbarch *gdbarch, PyObject *pyo_reg_id, /* Initializes the new Python classes from this file in the gdb module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION +static int gdbpy_initialize_registers () { register_descriptor_object_type.tp_new = PyType_GenericNew; diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index b95071f0b46..4b9c2eb23e9 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -645,8 +645,8 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) return return_list.release (); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_symbols (void) +static int +gdbpy_initialize_symbols () { if (gdbpy_type_ready (&symbol_object_type) < 0) return -1; diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 9f7bdb0f132..1bd1993a09e 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -30,8 +30,7 @@ struct symtab_object { struct symtab *symtab; }; -extern PyTypeObject symtab_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symtab_object"); +extern PyTypeObject symtab_object_type; static const gdbpy_registry> stpy_registry; @@ -74,8 +73,7 @@ struct salpy_invalidator } }; -extern PyTypeObject sal_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("sal_object"); +extern PyTypeObject sal_object_type; static const gdbpy_registry> salpy_registry; @@ -423,8 +421,8 @@ symtab_object_to_symtab (PyObject *obj) return ((symtab_object *) obj)->symtab; } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_symtabs (void) +static int +gdbpy_initialize_symtabs () { symtab_object_type.tp_new = PyType_GenericNew; if (gdbpy_type_ready (&symtab_object_type) < 0) diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c index 23a713e1448..23ea17385e1 100644 --- a/gdb/python/py-tui.c +++ b/gdb/python/py-tui.c @@ -55,8 +55,7 @@ struct gdbpy_tui_window bool is_valid () const; }; -extern PyTypeObject gdbpy_tui_window_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("gdbpy_tui_window"); +extern PyTypeObject gdbpy_tui_window_object_type; /* A TUI window written in Python. */ @@ -646,7 +645,7 @@ gdbpy_tui_enabled (bool state) /* Initialize this module. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION +static int gdbpy_initialize_tui () { #ifdef TUI diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 65753fd5fcd..1251c1586a9 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -34,8 +34,7 @@ struct type_object struct type *type; }; -extern PyTypeObject type_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("type_object"); +extern PyTypeObject type_object_type; /* A Field object. */ struct field_object @@ -46,8 +45,7 @@ struct field_object PyObject *dict; }; -extern PyTypeObject field_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("field_object"); +extern PyTypeObject field_object_type; /* A type iterator object. */ struct typy_iterator_object { @@ -60,8 +58,7 @@ struct typy_iterator_object { type_object *source; }; -extern PyTypeObject type_iterator_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("typy_iterator_object"); +extern PyTypeObject type_iterator_object_type; /* This is used to initialize various gdb.TYPE_ constants. */ struct pyty_code @@ -1511,8 +1508,8 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw) return type_to_type_object (type); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_types (void) +static int +gdbpy_initialize_types () { if (gdbpy_type_ready (&type_object_type) < 0) return -1; diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 43125bb67c1..c016f5b1aa0 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -133,11 +133,9 @@ struct cached_frame_info cached_reg_t reg[0]; }; -extern PyTypeObject pending_frame_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pending_frame_object"); +extern PyTypeObject pending_frame_object_type; -extern PyTypeObject unwind_info_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("unwind_info_object"); +extern PyTypeObject unwind_info_object_type; /* An enum returned by pyuw_object_attribute_to_pointer, a function which is used to extract an attribute from a Python object. */ @@ -1017,8 +1015,8 @@ pyuw_on_new_gdbarch (gdbarch *newarch) /* Initialize unwind machinery. */ -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_unwind (void) +static int +gdbpy_initialize_unwind () { gdb::observers::new_architecture.attach (pyuw_on_new_gdbarch, "py-unwind"); diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index c0784396009..12b143c14ea 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -2244,8 +2244,8 @@ gdbpy_is_value_object (PyObject *obj) return PyObject_TypeCheck (obj, &value_object_type); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_values (void) +static int +gdbpy_initialize_values () { return gdbpy_type_ready (&value_object_type); } diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index c10ac5dcd90..afedd0f5008 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -598,8 +598,8 @@ python_xmethod_worker::python_xmethod_worker (PyObject *py_worker, Py_INCREF (this_type); } -static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -gdbpy_initialize_xmethods (void) +static int +gdbpy_initialize_xmethods () { py_match_method_name = PyUnicode_FromString (match_method_name); if (py_match_method_name == NULL) diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 54467ba49f3..bcaebec791d 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -24,34 +24,6 @@ #include "extension-priv.h" #include "registry.h" -/* These WITH_* macros are defined by the CPython API checker that - comes with the Python plugin for GCC. See: - https://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html - The checker defines a WITH_ macro for each attribute it - exposes. Note that we intentionally do not use - 'cpychecker_returns_borrowed_ref' -- that idiom is forbidden in - gdb. */ - -#ifdef WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE -#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) \ - __attribute__ ((cpychecker_type_object_for_typedef (ARG))) -#else -#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) -#endif - -#ifdef WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE -#define CPYCHECKER_SETS_EXCEPTION __attribute__ ((cpychecker_sets_exception)) -#else -#define CPYCHECKER_SETS_EXCEPTION -#endif - -#ifdef WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE -#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION \ - __attribute__ ((cpychecker_negative_result_sets_exception)) -#else -#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION -#endif - /* /usr/include/features.h on linux systems will define _POSIX_C_SOURCE if it sees _GNU_SOURCE (which config.h will define). pyconfig.h defines _POSIX_C_SOURCE to a different value than @@ -349,20 +321,13 @@ extern int gdb_python_initialized; extern PyObject *gdb_module; extern PyObject *gdb_python_module; -extern PyTypeObject value_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("value_object"); -extern PyTypeObject block_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("block_object"); -extern PyTypeObject symbol_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symbol_object"); -extern PyTypeObject event_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object"); -extern PyTypeObject breakpoint_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_object"); -extern PyTypeObject frame_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("frame_object"); -extern PyTypeObject thread_object_type - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object"); +extern PyTypeObject value_object_type; +extern PyTypeObject block_object_type; +extern PyTypeObject symbol_object_type; +extern PyTypeObject event_object_type; +extern PyTypeObject breakpoint_object_type; +extern PyTypeObject frame_object_type; +extern PyTypeObject thread_object_type; /* Ensure that breakpoint_object_type is initialized and return true. If breakpoint_object_type can't be initialized then set a suitable Python @@ -1004,8 +969,7 @@ extern PyObject *gdbpy_gdb_error; extern PyObject *gdbpy_gdb_memory_error; extern PyObject *gdbpy_gdberror_exc; -extern void gdbpy_convert_exception (const struct gdb_exception &) - CPYCHECKER_SETS_EXCEPTION; +extern void gdbpy_convert_exception (const struct gdb_exception &); /* Use this in a 'catch' block to convert the exception E to a Python exception and return value VAL to signal that an exception occurred. @@ -1019,8 +983,7 @@ gdbpy_handle_gdb_exception (T val, const gdb_exception &e) return val; } -int get_addr_from_python (PyObject *obj, CORE_ADDR *addr) - CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION; +int get_addr_from_python (PyObject *obj, CORE_ADDR *addr); gdbpy_ref<> gdb_py_object_from_longest (LONGEST l); gdbpy_ref<> gdb_py_object_from_ulongest (ULONGEST l); @@ -1029,8 +992,7 @@ int gdb_py_int_as_long (PyObject *, long *); PyObject *gdb_py_generic_dict (PyObject *self, void *closure); int gdb_pymodule_addobject (PyObject *module, const char *name, - PyObject *object) - CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION; + PyObject *object); /* Return a Python string (str) object that represents SELF. SELF can be diff --git a/gdb/python/python.c b/gdb/python/python.c index 9c30d99982a..7e1975682f5 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -3203,8 +3203,7 @@ Print a warning." }, /* Define all the event objects. */ #define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \ - PyTypeObject name##_event_object_type \ - CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \ + PyTypeObject name##_event_object_type \ = { \ PyVarObject_HEAD_INIT (NULL, 0) \ "gdb." py_name, /* tp_name */ \