[3/8] gdb: add program_space parameter to emit_clear_objfiles_event

Message ID 20231004022305.298534-4-simon.marchi@polymtl.ca
State New
Headers
Series Split new_objfile observable |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Simon Marchi Oct. 4, 2023, 2:20 a.m. UTC
  From: Simon Marchi <simon.marchi@efficios.com>

Add program_space space parameters to emit_clear_objfiles_event and
create_clear_objfiles_event_object, making the reference to
current_program_space bubble up a bit.

Change-Id: I5fde2071712781e5d45971fa0ab34d85d3a49a71
---
 gdb/python/py-event.h           | 2 +-
 gdb/python/py-inferior.c        | 2 +-
 gdb/python/py-newobjfileevent.c | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 01386dde84cd..b9e9af4d7329 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -78,7 +78,7 @@  extern gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type,
 
 extern int emit_new_objfile_event (struct objfile *objfile);
 extern int emit_free_objfile_event (struct objfile *objfile);
-extern int emit_clear_objfiles_event (void);
+extern int emit_clear_objfiles_event (program_space *pspace);
 
 extern void evpy_dealloc (PyObject *self);
 extern int evpy_add_attribute (PyObject *event,
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 906d402827ce..e7a9d822409b 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -196,7 +196,7 @@  python_new_objfile (struct objfile *objfile)
 
   if (objfile == NULL)
     {
-      if (emit_clear_objfiles_event () < 0)
+      if (emit_clear_objfiles_event (current_program_space) < 0)
 	gdbpy_print_stack ();
     }
   else
diff --git a/gdb/python/py-newobjfileevent.c b/gdb/python/py-newobjfileevent.c
index 34e8e4923b58..2068d39353a4 100644
--- a/gdb/python/py-newobjfileevent.c
+++ b/gdb/python/py-newobjfileevent.c
@@ -93,14 +93,14 @@  emit_free_objfile_event (struct objfile *objfile)
 /* Subroutine of emit_clear_objfiles_event to simplify it.  */
 
 static gdbpy_ref<>
-create_clear_objfiles_event_object (void)
+create_clear_objfiles_event_object (program_space *pspace)
 {
   gdbpy_ref<> objfile_event
     = create_event_object (&clear_objfiles_event_object_type);
   if (objfile_event == NULL)
     return NULL;
 
-  gdbpy_ref<> py_progspace = pspace_to_pspace_object (current_program_space);
+  gdbpy_ref<> py_progspace = pspace_to_pspace_object (pspace);
   if (py_progspace == NULL || evpy_add_attribute (objfile_event.get (),
 						  "progspace",
 						  py_progspace.get ()) < 0)
@@ -115,12 +115,12 @@  create_clear_objfiles_event_object (void)
    Return -1 if emit fails.  */
 
 int
-emit_clear_objfiles_event (void)
+emit_clear_objfiles_event (program_space *pspace)
 {
   if (evregpy_no_listeners_p (gdb_py_events.clear_objfiles))
     return 0;
 
-  gdbpy_ref<> event = create_clear_objfiles_event_object ();
+  gdbpy_ref<> event = create_clear_objfiles_event_object (pspace);
   if (event != NULL)
     return evpy_emit_event (event.get (), gdb_py_events.clear_objfiles);
   return -1;