gdbsupport, gdb: give names to observers

Give a name to each observer, this will help produce more meaningful
debug message.

gdbsupport/ChangeLog:

	* observable.h (class observable) <struct observer> <observer>:
	Add name parameter.
	<name>: New field.
	<attach>: Add name parameter, update all callers.

Change-Id: Ie0cc4664925215b8d2b09e026011b7803549fba0
This commit is contained in:
Simon Marchi
2021-04-24 19:26:04 -04:00
parent ec098003e2
commit c90e7d6352
47 changed files with 219 additions and 149 deletions

View File

@ -1125,9 +1125,12 @@ gdbpy_initialize_breakpoints (void)
(PyObject *) &breakpoint_object_type) < 0)
return -1;
gdb::observers::breakpoint_created.attach (gdbpy_breakpoint_created);
gdb::observers::breakpoint_deleted.attach (gdbpy_breakpoint_deleted);
gdb::observers::breakpoint_modified.attach (gdbpy_breakpoint_modified);
gdb::observers::breakpoint_created.attach (gdbpy_breakpoint_created,
"py-breakpoint");
gdb::observers::breakpoint_deleted.attach (gdbpy_breakpoint_deleted,
"py-breakpoint");
gdb::observers::breakpoint_modified.attach (gdbpy_breakpoint_modified,
"py-breakpoint");
/* Add breakpoint types constants. */
for (i = 0; pybp_codes[i].name; ++i)

View File

@ -417,8 +417,10 @@ gdbpy_initialize_finishbreakpoints (void)
(PyObject *) &finish_breakpoint_object_type) < 0)
return -1;
gdb::observers::normal_stop.attach (bpfinishpy_handle_stop);
gdb::observers::inferior_exit.attach (bpfinishpy_handle_exit);
gdb::observers::normal_stop.attach (bpfinishpy_handle_stop,
"py-finishbreakpoint");
gdb::observers::inferior_exit.attach (bpfinishpy_handle_exit,
"py-finishbreakpoint");
return 0;
}

View File

@ -904,18 +904,23 @@ gdbpy_initialize_inferior (void)
infpy_inf_data_key =
register_inferior_data_with_cleanup (NULL, py_free_inferior);
gdb::observers::new_thread.attach (add_thread_object);
gdb::observers::thread_exit.attach (delete_thread_object);
gdb::observers::normal_stop.attach (python_on_normal_stop);
gdb::observers::target_resumed.attach (python_on_resume);
gdb::observers::inferior_call_pre.attach (python_on_inferior_call_pre);
gdb::observers::inferior_call_post.attach (python_on_inferior_call_post);
gdb::observers::memory_changed.attach (python_on_memory_change);
gdb::observers::register_changed.attach (python_on_register_change);
gdb::observers::inferior_exit.attach (python_inferior_exit);
gdb::observers::new_objfile.attach (python_new_objfile);
gdb::observers::inferior_added.attach (python_new_inferior);
gdb::observers::inferior_removed.attach (python_inferior_deleted);
gdb::observers::new_thread.attach (add_thread_object, "py-inferior");
gdb::observers::thread_exit.attach (delete_thread_object, "py-inferior");
gdb::observers::normal_stop.attach (python_on_normal_stop, "py-inferior");
gdb::observers::target_resumed.attach (python_on_resume, "py-inferior");
gdb::observers::inferior_call_pre.attach (python_on_inferior_call_pre,
"py-inferior");
gdb::observers::inferior_call_post.attach (python_on_inferior_call_post,
"py-inferior");
gdb::observers::memory_changed.attach (python_on_memory_change,
"py-inferior");
gdb::observers::register_changed.attach (python_on_register_change,
"py-inferior");
gdb::observers::inferior_exit.attach (python_inferior_exit, "py-inferior");
gdb::observers::new_objfile.attach (python_new_objfile, "py-inferior");
gdb::observers::inferior_added.attach (python_new_inferior, "py-inferior");
gdb::observers::inferior_removed.attach (python_inferior_deleted,
"py-inferior");
membuf_object_type.tp_new = PyType_GenericNew;
if (PyType_Ready (&membuf_object_type) < 0)

View File

@ -630,7 +630,8 @@ gdbpy_initialize_unwind (void)
&setdebuglist, &showdebuglist);
pyuw_gdbarch_data
= gdbarch_data_register_post_init (pyuw_gdbarch_data_init);
gdb::observers::architecture_changed.attach (pyuw_on_new_gdbarch);
gdb::observers::architecture_changed.attach (pyuw_on_new_gdbarch,
"py-unwind");
if (PyType_Ready (&pending_frame_object_type) < 0)
return -1;