mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 07:53:51 +08:00
gdb/python: break dependencies between gdbpy_initialize_* functions
In a later commit in this series I will propose removing all of the explicit gdbpy_initialize_* calls from python.c and replace these calls with a more generic mechanism. One of the side effects of this generic mechanism is that the order in which the various Python sub-systems within GDB are initialized is no longer guaranteed. On the whole I don't think this matters, most of the sub-systems are independent of each other, though testing did reveal a few places where we did have dependencies, though I don't think those dependencies were explicitly documented in a comment anywhere. This commit removes the first dependency issue, with this and the next commit, all of the implicit inter-sub-system dependencies will be replaced by explicit dependencies, which will allow me to, I think, clean up how the sub-systems are initialized. The dependency is around the py_insn_type. This type is setup in gdbpy_initialize_instruction and used in gdbpy_initialize_record. Rather than depend on the calls to these two functions being in a particular order, in this commit I propose adding a new function py_insn_get_insn_type. This function will take care of setting up the py_insn_type type and calling PyType_Ready. This helper function can be called from gdbpy_initialize_record and gdbpy_initialize_instruction, and the py_insn_type will be initialized just once. To me this is better, the dependency is now really obvious, but also, we no longer care in which order gdbpy_initialize_record and gdbpy_initialize_instruction are called. There should be no user visible changes after this commit.
This commit is contained in:
@ -563,7 +563,7 @@ gdbpy_initialize_record (void)
|
||||
recpy_insn_type.tp_getset = recpy_insn_getset;
|
||||
recpy_insn_type.tp_richcompare = recpy_element_richcompare;
|
||||
recpy_insn_type.tp_hash = recpy_element_hash;
|
||||
recpy_insn_type.tp_base = &py_insn_type;
|
||||
recpy_insn_type.tp_base = py_insn_get_insn_type ();
|
||||
|
||||
recpy_func_type.tp_new = PyType_GenericNew;
|
||||
recpy_func_type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
|
Reference in New Issue
Block a user