gdb: delay python initialisation until gdbpy_finish_initialization

Delay Python initialisation until gdbpy_finish_initialization.

This is mostly about splitting the existing gdbpy_initialize_*
functions in two, all the calls to register_objfile_data_with_cleanup,
gdbarch_data_register_post_init, etc are moved into new _initialize_*
functions, but everything else is left in the gdbpy_initialize_*
functions.

Then the call to do_start_initialization (in python/python.c) is moved
from the _initialize_python function into gdbpy_finish_initialization.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* python/py-arch.c (_initialize_py_arch): New function.
	(gdbpy_initialize_arch): Move code to _initialize_py_arch.
	* python/py-block.c (_initialize_py_block): New function.
	(gdbpy_initialize_blocks): Move code to _initialize_py_block.
	* python/py-inferior.c (_initialize_py_inferior): New function.
	(gdbpy_initialize_inferior): Move code to _initialize_py_inferior.
	* python/py-objfile.c (_initialize_py_objfile): New function.
	(gdbpy_initialize_objfile): Move code to _initialize_py_objfile.
	* python/py-progspace.c (_initialize_py_progspace): New function.
	(gdbpy_initialize_pspace): Move code to _initialize_py_progspace.
	* python/py-registers.c (_initialize_py_registers): New function.
	(gdbpy_initialize_registers): Move code to
	_initialize_py_registers.
	* python/py-symbol.c (_initialize_py_symbol): New function.
	(gdbpy_initialize_symbols): Move code to _initialize_py_symbol.
	* python/py-symtab.c (_initialize_py_symtab): New function.
	(gdbpy_initialize_symtabs): Move code to _initialize_py_symtab.
	* python/py-type.c (_initialize_py_type): New function.
	(gdbpy_initialize_types): Move code to _initialize_py_type.
	* python/py-unwind.c (_initialize_py_unwind): New function.
	(gdbpy_initialize_unwind): Move code to _initialize_py_unwind.
	* python/python.c (_initialize_python): Move call to
	do_start_initialization to gdbpy_finish_initialization.
	(gdbpy_finish_initialization): Add call to
	do_start_initialization.
This commit is contained in:
Andrew Burgess 2021-04-22 17:11:25 +01:00
parent 913832e99c
commit 8e3685bf25
12 changed files with 125 additions and 48 deletions

View file

@ -511,6 +511,20 @@ del_objfile_sal (struct objfile *objfile, void *datum)
}
}
void _initialize_py_symtab ();
void
_initialize_py_symtab ()
{
/* Register an objfile "free" callback so we can properly
invalidate symbol tables, and symbol table and line data
structures when an object file that is about to be
deleted. */
stpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_symtab);
salpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_sal);
}
int
gdbpy_initialize_symtabs (void)
{
@ -522,15 +536,6 @@ gdbpy_initialize_symtabs (void)
if (PyType_Ready (&sal_object_type) < 0)
return -1;
/* Register an objfile "free" callback so we can properly
invalidate symbol tables, and symbol table and line data
structures when an object file that is about to be
deleted. */
stpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_symtab);
salpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, del_objfile_sal);
if (gdb_pymodule_addobject (gdb_module, "Symtab",
(PyObject *) &symtab_object_type) < 0)
return -1;