mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-05 23:26:51 +08:00
Add gdb.free_objfile event registry
Currently, Python code can use event registries to detect when gdb loads a new objfile, and when gdb clears the objfile list. However, there's no way to detect the removal of an objfile, say when the inferior calls dlclose. This patch adds a gdb.free_objfile event registry and arranges for an event to be emitted in this case.
This commit is contained in:
@ -197,6 +197,20 @@ python_new_objfile (struct objfile *objfile)
|
||||
}
|
||||
}
|
||||
|
||||
/* Emit a Python event when an objfile is about to be removed. */
|
||||
|
||||
static void
|
||||
python_free_objfile (struct objfile *objfile)
|
||||
{
|
||||
if (!gdb_python_initialized)
|
||||
return;
|
||||
|
||||
gdbpy_enter enter_py (objfile->arch ());
|
||||
|
||||
if (emit_free_objfile_event (objfile) < 0)
|
||||
gdbpy_print_stack ();
|
||||
}
|
||||
|
||||
/* Return a reference to the Python object of type Inferior
|
||||
representing INFERIOR. If the object has already been created,
|
||||
return it and increment the reference count, otherwise, create it.
|
||||
@ -853,6 +867,7 @@ gdbpy_initialize_inferior (void)
|
||||
gdb::observers::new_objfile.attach
|
||||
(python_new_objfile, "py-inferior",
|
||||
{ &auto_load_new_objfile_observer_token });
|
||||
gdb::observers::free_objfile.attach (python_free_objfile, "py-inferior");
|
||||
gdb::observers::inferior_added.attach (python_new_inferior, "py-inferior");
|
||||
gdb::observers::inferior_removed.attach (python_inferior_deleted,
|
||||
"py-inferior");
|
||||
|
Reference in New Issue
Block a user