gdbsupport, gdb: give names to observers
authorSimon Marchi <simon.marchi@polymtl.ca>
Sat, 24 Apr 2021 23:26:04 +0000 (19:26 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sat, 24 Apr 2021 23:26:41 +0000 (19:26 -0400)
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

47 files changed:
gdb/ada-lang.c
gdb/ada-tasks.c
gdb/agent.c
gdb/aix-thread.c
gdb/annotate.c
gdb/arm-tdep.c
gdb/auto-load.c
gdb/auxv.c
gdb/break-catch-syscall.c
gdb/breakpoint.c
gdb/bsd-uthread.c
gdb/cli/cli-interp.c
gdb/dummy-frame.c
gdb/extension.c
gdb/frame.c
gdb/guile/scm-breakpoint.c
gdb/inflow.c
gdb/infrun.c
gdb/jit.c
gdb/linux-tdep.c
gdb/linux-thread-db.c
gdb/m68k-linux-tdep.c
gdb/mi/mi-cmd-break.c
gdb/mi/mi-interp.c
gdb/printcmd.c
gdb/python/py-breakpoint.c
gdb/python/py-finishbreakpoint.c
gdb/python/py-inferior.c
gdb/python/py-unwind.c
gdb/ravenscar-thread.c
gdb/record-btrace.c
gdb/regcache.c
gdb/remote.c
gdb/sol-thread.c
gdb/solib-aix.c
gdb/solib-svr4.c
gdb/solib.c
gdb/symfile-mem.c
gdb/symfile.c
gdb/symtab.c
gdb/tui/tui-hooks.c
gdb/tui/tui-interp.c
gdb/tui/tui-win.c
gdb/tui/tui-winsource.c
gdb/unittests/observable-selftests.c
gdbsupport/ChangeLog
gdbsupport/observable.h

index d170a1e662a7ecfd79fc5bf65a1602d23f254373..28f14c9ae53cf4c5edc2a3a3196a7a57512813cb 100644 (file)
@@ -13494,7 +13494,7 @@ DWARF attribute."),
                                           NULL, xcalloc, xfree);
 
   /* The ada-lang observers.  */
-  gdb::observers::new_objfile.attach (ada_new_objfile_observer);
-  gdb::observers::free_objfile.attach (ada_free_objfile_observer);
-  gdb::observers::inferior_exit.attach (ada_inferior_exit);
+  gdb::observers::new_objfile.attach (ada_new_objfile_observer, "ada-lang");
+  gdb::observers::free_objfile.attach (ada_free_objfile_observer, "ada-lang");
+  gdb::observers::inferior_exit.attach (ada_inferior_exit, "ada-lang");
 }
index a5908d4361eb9419a80ed9c76609b73dd928c464..a9c6b5eb1b3ad294bfaa8e0396f4632f958cfaba 100644 (file)
@@ -1478,8 +1478,10 @@ void
 _initialize_tasks ()
 {
   /* Attach various observers.  */
-  gdb::observers::normal_stop.attach (ada_tasks_normal_stop_observer);
-  gdb::observers::new_objfile.attach (ada_tasks_new_objfile_observer);
+  gdb::observers::normal_stop.attach (ada_tasks_normal_stop_observer,
+                                     "ada-tasks");
+  gdb::observers::new_objfile.attach (ada_tasks_new_objfile_observer,
+                                     "ada-tasks");
 
   /* Some new commands provided by this module.  */
   add_info ("tasks", info_tasks_command,
index 79bb32ea55cbcebbed79d344f97c289025760c2b..5e52865b3788bd7b92bcf458aed9f1f9324638d2 100644 (file)
@@ -78,7 +78,8 @@ void _initialize_agent ();
 void
 _initialize_agent ()
 {
-  gdb::observers::new_objfile.attach (agent_new_objfile);
+  gdb::observers::new_objfile.attach (agent_new_objfile,
+                                     "agent");
 
   add_setshow_enum_cmd ("agent", class_run,
                        can_use_agent_enum,
index fc34210cf9e2e77ad81f35f28a539eba7ae456b2..889cb65fdcdb84af5da9e600f5218e18f4500c05 100644 (file)
@@ -1839,11 +1839,12 @@ void
 _initialize_aix_thread ()
 {
   /* Notice when object files get loaded and unloaded.  */
-  gdb::observers::new_objfile.attach (new_objfile);
+  gdb::observers::new_objfile.attach (new_objfile, "aix-thread");
 
   /* Add ourselves to inferior_created event chain.
      This is needed to enable the thread target on "attach".  */
-  gdb::observers::inferior_created.attach (aix_thread_inferior_created);
+  gdb::observers::inferior_created.attach (aix_thread_inferior_created,
+                                          "aix-thread");
 
   add_setshow_boolean_cmd ("aix-thread", class_maintenance, &debug_aix_thread,
                           _("Set debugging of AIX thread module."),
index 3d42aec0e860efee7352329912250a3fea5094d2..8c813732eba6d0bb01547a8c91a891d6c9f2634b 100644 (file)
@@ -627,8 +627,8 @@ void _initialize_annotate ();
 void
 _initialize_annotate ()
 {
-  gdb::observers::breakpoint_created.attach (breakpoint_changed);
-  gdb::observers::breakpoint_deleted.attach (breakpoint_changed);
-  gdb::observers::breakpoint_modified.attach (breakpoint_changed);
-  gdb::observers::thread_exit.attach (annotate_thread_exited);
+  gdb::observers::breakpoint_created.attach (breakpoint_changed, "annotate");
+  gdb::observers::breakpoint_deleted.attach (breakpoint_changed, "annotate");
+  gdb::observers::breakpoint_modified.attach (breakpoint_changed, "annotate");
+  gdb::observers::thread_exit.attach (annotate_thread_exited, "annotate");
 }
index 23540092e77f12dc5d8196a4f8e4706bf21755df..056973f3492033cb85342d5d9350477a6522c8c5 100644 (file)
@@ -9553,7 +9553,7 @@ _initialize_arm_tdep ()
   gdbarch_register (bfd_arch_arm, arm_gdbarch_init, arm_dump_tdep);
 
   /* Add ourselves to objfile event chain.  */
-  gdb::observers::new_objfile.attach (arm_exidx_new_objfile);
+  gdb::observers::new_objfile.attach (arm_exidx_new_objfile, "arm-tdep");
 
   /* Register an ELF OS ABI sniffer for ARM binaries.  */
   gdbarch_register_osabi_sniffer (bfd_arch_arm,
index 1dfcf21eeebf220853371342e1c0c92bf78f7f65..239efa346064fccf26664afcac3501d55363aa61 100644 (file)
@@ -1503,7 +1503,7 @@ _initialize_auto_load ()
   char *guile_name_help;
   const char *suffix;
 
-  gdb::observers::new_objfile.attach (auto_load_new_objfile);
+  gdb::observers::new_objfile.attach (auto_load_new_objfile, "auto-load");
 
   add_setshow_boolean_cmd ("gdb-scripts", class_support,
                           &auto_load_gdb_scripts, _("\
@@ -1613,7 +1613,8 @@ This option has security implications for untrusted inferiors."),
                                     show_auto_load_safe_path,
                                     auto_load_set_cmdlist_get (),
                                     auto_load_show_cmdlist_get ());
-  gdb::observers::gdb_datadir_changed.attach (auto_load_gdb_datadir_changed);
+  gdb::observers::gdb_datadir_changed.attach (auto_load_gdb_datadir_changed,
+                                             "auto-load");
 
   cmd = add_cmd ("add-auto-load-safe-path", class_support,
                 add_auto_load_safe_path,
index 6507df192e56dfbd83fdf8136c45ba9eee005a5c..2bcf9f452e3eb2541cc3e5cfaa0b1caac4179d91 100644 (file)
@@ -600,7 +600,7 @@ _initialize_auxv ()
 This is information provided by the operating system at program startup."));
 
   /* Observers used to invalidate the auxv cache when needed.  */
-  gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf);
-  gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf);
-  gdb::observers::executable_changed.attach (invalidate_auxv_cache);
+  gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf, "auxv");
+  gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf, "auxv");
+  gdb::observers::executable_changed.attach (invalidate_auxv_cache, "auxv");
 }
index 7335377f8992e0f432265b12b8ed0806bd815366..9100ac6d544415c03c59babfb9c60dd724798cff 100644 (file)
@@ -607,7 +607,8 @@ _initialize_break_catch_syscall ()
 {
   initialize_syscall_catchpoint_ops ();
 
-  gdb::observers::inferior_exit.attach (clear_syscall_counts);
+  gdb::observers::inferior_exit.attach (clear_syscall_counts,
+                                       "break-catch-syscall");
 
   add_catch_command ("syscall", _("\
 Catch system calls by their names, groups and/or numbers.\n\
index a20464a10623184d1eeea7e0afa88348f2efbe6c..9cc53f8ef54ed3c21b2b672431bac260009a8cab 100644 (file)
@@ -15646,9 +15646,12 @@ _initialize_breakpoint ()
 
   initialize_breakpoint_ops ();
 
-  gdb::observers::solib_unloaded.attach (disable_breakpoints_in_unloaded_shlib);
-  gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile);
-  gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change);
+  gdb::observers::solib_unloaded.attach (disable_breakpoints_in_unloaded_shlib,
+                                        "breakpoint");
+  gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile,
+                                      "breakpoint");
+  gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change,
+                                        "breakpoint");
 
   breakpoint_chain = 0;
   /* Don't bother to call set_breakpoint_count.  $bpnum isn't useful
@@ -16232,6 +16235,8 @@ This is useful for formatted output in user-defined commands."));
 
   automatic_hardware_breakpoints = true;
 
-  gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed);
-  gdb::observers::thread_exit.attach (remove_threaded_breakpoints);
+  gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed,
+                                          "breakpoint");
+  gdb::observers::thread_exit.attach (remove_threaded_breakpoints,
+                                     "breakpoint");
 }
index 3cb8f64c89a7243d916d7acf4a854195af1a6619..f8353f070419c46770d934057a2f9aceed83cfce 100644 (file)
@@ -550,7 +550,10 @@ _initialize_bsd_uthread ()
 {
   bsd_uthread_data = gdbarch_data_register_pre_init (bsd_uthread_init);
 
-  gdb::observers::inferior_created.attach (bsd_uthread_inferior_created);
-  gdb::observers::solib_loaded.attach (bsd_uthread_solib_loaded);
-  gdb::observers::solib_unloaded.attach (bsd_uthread_solib_unloaded);
+  gdb::observers::inferior_created.attach (bsd_uthread_inferior_created,
+                                          "bsd-uthread");
+  gdb::observers::solib_loaded.attach (bsd_uthread_solib_loaded,
+                                      "bsd-uthread");
+  gdb::observers::solib_unloaded.attach (bsd_uthread_solib_unloaded,
+                                        "bsd-uthread");
 }
index 882384e9a9155f2c09cc57d9c29bac792654202d..31fe934bdfff6792b556e59938de5a076450f05d 100644 (file)
@@ -482,14 +482,16 @@ _initialize_cli_interp ()
   interp_factory_register (INTERP_CONSOLE, cli_interp_factory);
 
   /* If changing this, remember to update tui-interp.c as well.  */
-  gdb::observers::normal_stop.attach (cli_on_normal_stop);
-  gdb::observers::end_stepping_range.attach (cli_on_end_stepping_range);
-  gdb::observers::signal_received.attach (cli_on_signal_received);
-  gdb::observers::signal_exited.attach (cli_on_signal_exited);
-  gdb::observers::exited.attach (cli_on_exited);
-  gdb::observers::no_history.attach (cli_on_no_history);
-  gdb::observers::sync_execution_done.attach (cli_on_sync_execution_done);
-  gdb::observers::command_error.attach (cli_on_command_error);
+  gdb::observers::normal_stop.attach (cli_on_normal_stop, "cli-interp");
+  gdb::observers::end_stepping_range.attach (cli_on_end_stepping_range,
+                                            "cli-interp");
+  gdb::observers::signal_received.attach (cli_on_signal_received, "cli-interp");
+  gdb::observers::signal_exited.attach (cli_on_signal_exited, "cli-interp");
+  gdb::observers::exited.attach (cli_on_exited, "cli-interp");
+  gdb::observers::no_history.attach (cli_on_no_history, "cli-interp");
+  gdb::observers::sync_execution_done.attach (cli_on_sync_execution_done,
+                                             "cli-interp");
+  gdb::observers::command_error.attach (cli_on_command_error, "cli-interp");
   gdb::observers::user_selected_context_changed.attach
-    (cli_on_user_selected_context_changed);
+    (cli_on_user_selected_context_changed, "cli-interp");
 }
index 8269a401cb0c11f89ad5d8546667e51c2883196b..6bbcbba48bfcaddf316cb15b94ab503934ee1a66 100644 (file)
@@ -439,5 +439,5 @@ _initialize_dummy_frame ()
           _("Print the contents of the internal dummy-frame stack."),
           &maintenanceprintlist);
 
-  gdb::observers::inferior_created.attach (cleanup_dummy_frames);
+  gdb::observers::inferior_created.attach (cleanup_dummy_frames, "dummy-frame");
 }
index 0e0d42685fc7e44d698c9245c893f075e61d66c6..85d410e8a7aea72719f7ec0856ca1799c7941272 100644 (file)
@@ -900,5 +900,5 @@ void _initialize_extension ();
 void
 _initialize_extension ()
 {
-  gdb::observers::before_prompt.attach (ext_lang_before_prompt);
+  gdb::observers::before_prompt.attach (ext_lang_before_prompt, "extension");
 }
index dc9fdd41646fbb52463ec8bbc73d670011ed6448..2032abb2738d72d28f61d0d845d392a611cee451 100644 (file)
@@ -3179,7 +3179,8 @@ _initialize_frame ()
 
   frame_stash_create ();
 
-  gdb::observers::target_changed.attach (frame_observer_target_changed);
+  gdb::observers::target_changed.attach (frame_observer_target_changed,
+                                        "frame");
 
   add_basic_prefix_cmd ("backtrace", class_maintenance, _("\
 Set backtrace specific variables.\n\
index af63893461ba2fd10b4f7c204ad9596b783c756c..25b438b72103bd0e3caa0d7848d26eb1989fa959 100644 (file)
@@ -1322,8 +1322,10 @@ gdbscm_initialize_breakpoints (void)
   scm_set_smob_free (breakpoint_smob_tag, bpscm_free_breakpoint_smob);
   scm_set_smob_print (breakpoint_smob_tag, bpscm_print_breakpoint_smob);
 
-  gdb::observers::breakpoint_created.attach (bpscm_breakpoint_created);
-  gdb::observers::breakpoint_deleted.attach (bpscm_breakpoint_deleted);
+  gdb::observers::breakpoint_created.attach (bpscm_breakpoint_created,
+                                            "scm-breakpoint");
+  gdb::observers::breakpoint_deleted.attach (bpscm_breakpoint_deleted,
+                                            "scm-breakpoint");
 
   gdbscm_define_integer_constants (breakpoint_integer_constants, 1);
   gdbscm_define_functions (breakpoint_functions, 1);
index b3d90aa87cab656ffa50d7b2458f915396d152e0..994c73e40ee82c4a9edbd51360ec00766d6d4a13 100644 (file)
@@ -963,5 +963,5 @@ _initialize_inflow ()
   /* OK, figure out whether we have job control.  */
   have_job_control ();
 
-  gdb::observers::inferior_exit.attach (inflow_inferior_exit);
+  gdb::observers::inferior_exit.attach (inflow_inferior_exit, "inflow");
 }
index 2c31cf452b10752508561051fcd6490c554a0721..cfec07994f4c22b8bedb895d5821f874f9dd7259 100644 (file)
@@ -9759,11 +9759,13 @@ enabled by default on some platforms."),
   inferior_ptid = null_ptid;
   target_last_wait_ptid = minus_one_ptid;
 
-  gdb::observers::thread_ptid_changed.attach (infrun_thread_ptid_changed);
-  gdb::observers::thread_stop_requested.attach (infrun_thread_stop_requested);
-  gdb::observers::thread_exit.attach (infrun_thread_thread_exit);
-  gdb::observers::inferior_exit.attach (infrun_inferior_exit);
-  gdb::observers::inferior_execd.attach (infrun_inferior_execd);
+  gdb::observers::thread_ptid_changed.attach (infrun_thread_ptid_changed,
+                                             "infrun");
+  gdb::observers::thread_stop_requested.attach (infrun_thread_stop_requested,
+                                               "infrun");
+  gdb::observers::thread_exit.attach (infrun_thread_thread_exit, "infrun");
+  gdb::observers::inferior_exit.attach (infrun_inferior_exit, "infrun");
+  gdb::observers::inferior_execd.attach (infrun_inferior_execd, "infrun");
 
   /* Explicitly create without lookup, since that tries to create a
      value with a void typed value, and when we get here, gdbarch
index d10cc70222cb08870861a57d6ccb1be6ca662e6f..296b436c7964ac6b84e261f2a68f061acf165617 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1243,10 +1243,10 @@ _initialize_jit ()
                           show_jit_debug,
                           &setdebuglist, &showdebuglist);
 
-  gdb::observers::inferior_created.attach (jit_inferior_created_hook);
-  gdb::observers::inferior_execd.attach (jit_inferior_created_hook);
-  gdb::observers::inferior_exit.attach (jit_inferior_exit_hook);
-  gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted);
+  gdb::observers::inferior_created.attach (jit_inferior_created_hook, "jit");
+  gdb::observers::inferior_execd.attach (jit_inferior_created_hook, "jit");
+  gdb::observers::inferior_exit.attach (jit_inferior_exit_hook, "jit");
+  gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted, "jit");
 
   jit_gdbarch_data = gdbarch_data_register_pre_init (jit_gdbarch_data_init);
   if (is_dl_available ())
index 19604b5ff9a3feb17783dab3d0ac7b5f8105e9ca..927e69bf1e1e2032fc1758e2b4bef54c7219a254 100644 (file)
@@ -2694,9 +2694,12 @@ _initialize_linux_tdep ()
     gdbarch_data_register_pre_init (init_linux_gdbarch_data);
 
   /* Observers used to invalidate the cache when needed.  */
-  gdb::observers::inferior_exit.attach (invalidate_linux_cache_inf);
-  gdb::observers::inferior_appeared.attach (invalidate_linux_cache_inf);
-  gdb::observers::inferior_execd.attach (invalidate_linux_cache_inf);
+  gdb::observers::inferior_exit.attach (invalidate_linux_cache_inf,
+                                       "linux-tdep");
+  gdb::observers::inferior_appeared.attach (invalidate_linux_cache_inf,
+                                           "linux-tdep");
+  gdb::observers::inferior_execd.attach (invalidate_linux_cache_inf,
+                                        "linux-tdep");
 
   add_setshow_boolean_cmd ("use-coredump-filter", class_files,
                           &use_coredump_filter, _("\
index de8687e99c730f9643d1b99ba351b75eaa57a830..1c6ea4debd8819a96f156abad11a18b4e237588d 100644 (file)
@@ -2028,10 +2028,11 @@ as they are loaded."),
                           &maintenance_show_cmdlist);
 
   /* Add ourselves to objfile event chain.  */
-  gdb::observers::new_objfile.attach (thread_db_new_objfile);
+  gdb::observers::new_objfile.attach (thread_db_new_objfile, "linux-thread-db");
 
   /* Add ourselves to inferior_created event chain.
      This is needed to handle debugging statically linked programs where
      the new_objfile observer won't get called for libpthread.  */
-  gdb::observers::inferior_created.attach (thread_db_inferior_created);
+  gdb::observers::inferior_created.attach (thread_db_inferior_created,
+                                          "linux-thread-db");
 }
index 7b3cd5f2d9e194aedf11df5c03c04850a69ef84a..c72f4851b4c549b7d49f340dfd1edb3f9ffafa45 100644 (file)
@@ -429,5 +429,6 @@ _initialize_m68k_linux_tdep ()
 {
   gdbarch_register_osabi (bfd_arch_m68k, 0, GDB_OSABI_LINUX,
                          m68k_linux_init_abi);
-  gdb::observers::inferior_created.attach (m68k_linux_inferior_created);
+  gdb::observers::inferior_created.attach (m68k_linux_inferior_created,
+                                          "m68k-linux-tdep");
 }
index 5a4a62ce8c3497e9acc64eab4bbcc4502d3e3c38..1b7eaf5e28ff7767dfa094ab19148bda80d30f6b 100644 (file)
@@ -84,7 +84,8 @@ setup_breakpoint_reporting (void)
 {
   if (! mi_breakpoint_observers_installed)
     {
-      gdb::observers::breakpoint_created.attach (breakpoint_notify);
+      gdb::observers::breakpoint_created.attach (breakpoint_notify,
+                                                "mi-cmd-break");
       mi_breakpoint_observers_installed = 1;
     }
 
index 4c5612ee9ee0d3377dc9d1526b09c2c775007e57..144521b03fdf3f9b04bad706d64bd218053a5652 100644 (file)
@@ -1338,33 +1338,40 @@ _initialize_mi_interp ()
   interp_factory_register (INTERP_MI3, mi_interp_factory);
   interp_factory_register (INTERP_MI, mi_interp_factory);
 
-  gdb::observers::signal_received.attach (mi_on_signal_received);
-  gdb::observers::end_stepping_range.attach (mi_on_end_stepping_range);
-  gdb::observers::signal_exited.attach (mi_on_signal_exited);
-  gdb::observers::exited.attach (mi_on_exited);
-  gdb::observers::no_history.attach (mi_on_no_history);
-  gdb::observers::new_thread.attach (mi_new_thread);
-  gdb::observers::thread_exit.attach (mi_thread_exit);
-  gdb::observers::inferior_added.attach (mi_inferior_added);
-  gdb::observers::inferior_appeared.attach (mi_inferior_appeared);
-  gdb::observers::inferior_exit.attach (mi_inferior_exit);
-  gdb::observers::inferior_removed.attach (mi_inferior_removed);
-  gdb::observers::record_changed.attach (mi_record_changed);
-  gdb::observers::normal_stop.attach (mi_on_normal_stop);
-  gdb::observers::target_resumed.attach (mi_on_resume);
-  gdb::observers::solib_loaded.attach (mi_solib_loaded);
-  gdb::observers::solib_unloaded.attach (mi_solib_unloaded);
-  gdb::observers::about_to_proceed.attach (mi_about_to_proceed);
-  gdb::observers::traceframe_changed.attach (mi_traceframe_changed);
-  gdb::observers::tsv_created.attach (mi_tsv_created);
-  gdb::observers::tsv_deleted.attach (mi_tsv_deleted);
-  gdb::observers::tsv_modified.attach (mi_tsv_modified);
-  gdb::observers::breakpoint_created.attach (mi_breakpoint_created);
-  gdb::observers::breakpoint_deleted.attach (mi_breakpoint_deleted);
-  gdb::observers::breakpoint_modified.attach (mi_breakpoint_modified);
-  gdb::observers::command_param_changed.attach (mi_command_param_changed);
-  gdb::observers::memory_changed.attach (mi_memory_changed);
-  gdb::observers::sync_execution_done.attach (mi_on_sync_execution_done);
+  gdb::observers::signal_received.attach (mi_on_signal_received, "mi-interp");
+  gdb::observers::end_stepping_range.attach (mi_on_end_stepping_range,
+                                            "mi-interp");
+  gdb::observers::signal_exited.attach (mi_on_signal_exited, "mi-interp");
+  gdb::observers::exited.attach (mi_on_exited, "mi-interp");
+  gdb::observers::no_history.attach (mi_on_no_history, "mi-interp");
+  gdb::observers::new_thread.attach (mi_new_thread, "mi-interp");
+  gdb::observers::thread_exit.attach (mi_thread_exit, "mi-interp");
+  gdb::observers::inferior_added.attach (mi_inferior_added, "mi-interp");
+  gdb::observers::inferior_appeared.attach (mi_inferior_appeared, "mi-interp");
+  gdb::observers::inferior_exit.attach (mi_inferior_exit, "mi-interp");
+  gdb::observers::inferior_removed.attach (mi_inferior_removed, "mi-interp");
+  gdb::observers::record_changed.attach (mi_record_changed, "mi-interp");
+  gdb::observers::normal_stop.attach (mi_on_normal_stop, "mi-interp");
+  gdb::observers::target_resumed.attach (mi_on_resume, "mi-interp");
+  gdb::observers::solib_loaded.attach (mi_solib_loaded, "mi-interp");
+  gdb::observers::solib_unloaded.attach (mi_solib_unloaded, "mi-interp");
+  gdb::observers::about_to_proceed.attach (mi_about_to_proceed, "mi-interp");
+  gdb::observers::traceframe_changed.attach (mi_traceframe_changed,
+                                            "mi-interp");
+  gdb::observers::tsv_created.attach (mi_tsv_created, "mi-interp");
+  gdb::observers::tsv_deleted.attach (mi_tsv_deleted, "mi-interp");
+  gdb::observers::tsv_modified.attach (mi_tsv_modified, "mi-interp");
+  gdb::observers::breakpoint_created.attach (mi_breakpoint_created,
+                                            "mi-interp");
+  gdb::observers::breakpoint_deleted.attach (mi_breakpoint_deleted,
+                                            "mi-interp");
+  gdb::observers::breakpoint_modified.attach (mi_breakpoint_modified,
+                                             "mi-interp");
+  gdb::observers::command_param_changed.attach (mi_command_param_changed,
+                                               "mi-interp");
+  gdb::observers::memory_changed.attach (mi_memory_changed, "mi-interp");
+  gdb::observers::sync_execution_done.attach (mi_on_sync_execution_done,
+                                             "mi-interp");
   gdb::observers::user_selected_context_changed.attach
-    (mi_user_selected_context_changed);
+    (mi_user_selected_context_changed, "mi-interp");
 }
index a4f62f207d003267ffeb987d036d2b5fe7beb3f4..1c68d19cda1fb63861591033c689908f6627cfb2 100644 (file)
@@ -3186,7 +3186,8 @@ _initialize_printcmd ()
 
   current_display_number = -1;
 
-  gdb::observers::free_objfile.attach (clear_dangling_display_expressions);
+  gdb::observers::free_objfile.attach (clear_dangling_display_expressions,
+                                      "printcmd");
 
   add_info ("address", info_address_command,
            _("Describe where symbol SYM is stored.\n\
index 9650bd023b56e0c9cf0a244429e4128c8bb544c0..b41407136136a6f82b7e4e97c74607fa2e489f25 100644 (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)
index 38b4cc67901f8aab77b775dab42b2265809dd25a..d2a1ec4fa98e1782beb2f044b0f21b68e934adbf 100644 (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;
 }
index a3d5952a10bfccd2480939affb78fac1d1477f86..c2861ccb735c777913e40b4a8e0763978cfdff5b 100644 (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)
index f0574eba6108e2fd41420bc0ae5c7bb908896cc9..5dc8d33f0dc2c2b8ba2a4ef419ae6658dd59d117 100644 (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;
index 1398d1b7c9e6138262f75f6e271a6a4d68a1bfb4..84a0390ac7ce5475c754aa900cbb043c627e36b5 100644 (file)
@@ -714,7 +714,8 @@ _initialize_ravenscar ()
 {
   /* Notice when the inferior is created in order to push the
      ravenscar ops if needed.  */
-  gdb::observers::inferior_created.attach (ravenscar_inferior_created);
+  gdb::observers::inferior_created.attach (ravenscar_inferior_created,
+                                          "ravenscar-thread");
 
   add_basic_prefix_cmd ("ravenscar", no_class,
                        _("Prefix command for changing Ravenscar-specific settings."),
index b7b3c91f85dbb11c38a6fae9d93b1585daa60643..c888ad0cb248f370c5c2ae661b6a00108eeb423e 100644 (file)
@@ -307,7 +307,8 @@ record_btrace_auto_enable (void)
   DEBUG ("attach thread observer");
 
   gdb::observers::new_thread.attach (record_btrace_enable_warn,
-                                    record_btrace_thread_observer_token);
+                                    record_btrace_thread_observer_token,
+                                    "record-btrace");
 }
 
 /* Disable automatic tracing of new threads.  */
index bf3c6f43e6af89fc65d020232015f62b887179c3..d2386308b8226ea4c40ddbbc4ac36d6700a18272 100644 (file)
@@ -2084,8 +2084,10 @@ _initialize_regcache ()
   regcache_descr_handle
     = gdbarch_data_register_post_init (init_regcache_descr);
 
-  gdb::observers::target_changed.attach (regcache_observer_target_changed);
-  gdb::observers::thread_ptid_changed.attach (regcache_thread_ptid_changed);
+  gdb::observers::target_changed.attach (regcache_observer_target_changed,
+                                        "regcache");
+  gdb::observers::thread_ptid_changed.attach (regcache_thread_ptid_changed,
+                                             "regcache");
 
   add_cmd ("register-cache", class_maintenance, reg_flush_command,
           _("Force gdb to flush its register and frame cache."),
index 2e365df9bbaeb6fceb096a6215f037c720aa4b42..a7312a9fc2d176e42d16fc672e22925ae336f8ac 100644 (file)
@@ -14842,7 +14842,7 @@ _initialize_remote ()
   add_target (extended_remote_target_info, extended_remote_target::open);
 
   /* Hook into new objfile notification.  */
-  gdb::observers::new_objfile.attach (remote_new_objfile);
+  gdb::observers::new_objfile.attach (remote_new_objfile, "remote");
 
 #if 0
   init_remote_threadtests ();
index 825f69131fc46e4e6d4b240e811b3fca50add169..18eacf1062aaa9ef902e440b1cd4db56128be577 100644 (file)
@@ -1190,7 +1190,7 @@ _initialize_sol_thread ()
           _("Show info on Solaris user threads."), &maintenanceinfolist);
 
   /* Hook into new_objfile notification.  */
-  gdb::observers::new_objfile.attach (sol_thread_new_objfile);
+  gdb::observers::new_objfile.attach (sol_thread_new_objfile, "sol-thread");
   return;
 
  die:
index faccf299899b6623d7f7b75e7bf12ff3d3de7392..4b58058ffef88355d45157582472f16bff5fcc31 100644 (file)
@@ -737,7 +737,8 @@ _initialize_solib_aix ()
     = solib_aix_in_dynsym_resolve_code;
   solib_aix_so_ops.bfd_open = solib_aix_bfd_open;
 
-  gdb::observers::normal_stop.attach (solib_aix_normal_stop_observer);
+  gdb::observers::normal_stop.attach (solib_aix_normal_stop_observer,
+                                     "solib-aix");
 
   /* Debug this file's internals.  */
   add_setshow_boolean_cmd ("aix-solib", class_maintenance,
index 531469484e546ed33a037abc3d9d0fafa3de559e..60eeac5f4befab548c4d74de77942195eb1e2b03 100644 (file)
@@ -3296,5 +3296,6 @@ _initialize_svr4_solib ()
   svr4_so_ops.update_breakpoints = svr4_update_solib_event_breakpoints;
   svr4_so_ops.handle_event = svr4_handle_solib_event;
 
-  gdb::observers::free_objfile.attach (svr4_free_objfile_observer);
+  gdb::observers::free_objfile.attach (svr4_free_objfile_observer,
+                                      "solib-svr4");
 }
index d32b2210005fdd6a5013cfd566620d6afeae9cf6..f3cd48fde77c4b7ffa44179d44f99c4beabb2280 100644 (file)
@@ -1556,11 +1556,12 @@ _initialize_solib ()
 {
   solib_data = gdbarch_data_register_pre_init (solib_init);
 
-  gdb::observers::free_objfile.attach (remove_user_added_objfile);
+  gdb::observers::free_objfile.attach (remove_user_added_objfile,
+                                      "solib");
   gdb::observers::inferior_execd.attach ([] (inferior *inf)
     {
       solib_create_inferior_hook (0);
-    });
+    }, "solib");
 
   add_com ("sharedlibrary", class_files, sharedlibrary_command,
           _("Load shared object library symbols for files matching REGEXP."));
index c6766479d02f81633f704c2114316bd199e63f91..cc3a777f006ea1997b4096815cb8fc1804981415 100644 (file)
@@ -218,5 +218,5 @@ _initialize_symfile_mem ()
 
   /* Want to know of each new inferior so that its vsyscall info can
      be extracted.  */
-  gdb::observers::inferior_created.attach (add_vsyscall_page);
+  gdb::observers::inferior_created.attach (add_vsyscall_page, "symfile-mem");
 }
index 7dfe1ee1ca0153e0252591f29eb0c9b41afb72d9..5defc22870d66b8913c611c60a3e26897ed0252d 100644 (file)
@@ -3814,7 +3814,7 @@ _initialize_symfile ()
 {
   struct cmd_list_element *c;
 
-  gdb::observers::free_objfile.attach (symfile_free_objfile);
+  gdb::observers::free_objfile.attach (symfile_free_objfile, "symfile");
 
 #define READNOW_READNEVER_HELP \
   "The '-readnow' option will cause GDB to read the entire symbol file\n\
index 274ddfd1dae26763050d048c9ecbebb6d8046b09..061177e1d238d0c7c7d3947bcfd389ae8de67689 100644 (file)
@@ -6906,7 +6906,8 @@ If zero then the symbol cache is disabled."),
                     class_maintenance, 0, &maintenancelist);
   deprecate_cmd (c, "maintenancelist flush symbol-cache");
 
-  gdb::observers::executable_changed.attach (symtab_observer_executable_changed);
-  gdb::observers::new_objfile.attach (symtab_new_objfile_observer);
-  gdb::observers::free_objfile.attach (symtab_free_objfile_observer);
+  gdb::observers::executable_changed.attach (symtab_observer_executable_changed,
+                                            "symtab");
+  gdb::observers::new_objfile.attach (symtab_new_objfile_observer, "symtab");
+  gdb::observers::free_objfile.attach (symtab_free_objfile_observer, "symtab");
 }
index 2d7660acade636b8851ead48d57ac76def7c2426..52519aecf1762fae8d1b37f96206ada82f48d288 100644 (file)
@@ -222,7 +222,7 @@ static void
 attach_or_detach (T &observable, typename T::func_type func, bool attach)
 {
   if (attach)
-    observable.attach (func, tui_observers_token);
+    observable.attach (func, tui_observers_token, "tui-hooks");
   else
     observable.detach (tui_observers_token);
 }
@@ -282,5 +282,5 @@ void
 _initialize_tui_hooks ()
 {
   /* Install the permanent hooks.  */
-  gdb::observers::new_objfile.attach (tui_new_objfile_hook);
+  gdb::observers::new_objfile.attach (tui_new_objfile_hook, "tui-hooks");
 }
index f70e1a7b4c21b9affdb5b3ed18ff1c4a219ddf6b..aaa353c5146de9063671e76b09e3caf365927905 100644 (file)
@@ -343,14 +343,16 @@ _initialize_tui_interp ()
     }
 
   /* If changing this, remember to update cli-interp.c as well.  */
-  gdb::observers::normal_stop.attach (tui_on_normal_stop);
-  gdb::observers::signal_received.attach (tui_on_signal_received);
-  gdb::observers::end_stepping_range.attach (tui_on_end_stepping_range);
-  gdb::observers::signal_exited.attach (tui_on_signal_exited);
-  gdb::observers::exited.attach (tui_on_exited);
-  gdb::observers::no_history.attach (tui_on_no_history);
-  gdb::observers::sync_execution_done.attach (tui_on_sync_execution_done);
-  gdb::observers::command_error.attach (tui_on_command_error);
+  gdb::observers::normal_stop.attach (tui_on_normal_stop, "tui-interp");
+  gdb::observers::signal_received.attach (tui_on_signal_received, "tui-interp");
+  gdb::observers::end_stepping_range.attach (tui_on_end_stepping_range,
+                                            "tui-interp");
+  gdb::observers::signal_exited.attach (tui_on_signal_exited, "tui-interp");
+  gdb::observers::exited.attach (tui_on_exited, "tui-interp");
+  gdb::observers::no_history.attach (tui_on_no_history, "tui-interp");
+  gdb::observers::sync_execution_done.attach (tui_on_sync_execution_done,
+                                             "tui-interp");
+  gdb::observers::command_error.attach (tui_on_command_error, "tui-interp");
   gdb::observers::user_selected_context_changed.attach
-    (tui_on_user_selected_context_changed);
+    (tui_on_user_selected_context_changed, "tui-interp");
 }
index c73d129d1c701d182fd53cf8f0857e726f7b60e8..17682b022a3a6df06292652dfa53d2830238ffcb 100644 (file)
@@ -1120,6 +1120,6 @@ the line numbers and uses less horizontal space."),
                           tui_set_compact_source, tui_show_compact_source,
                           &tui_setlist, &tui_showlist);
 
-  tui_border_style.changed.attach (tui_rehighlight_all);
-  tui_active_border_style.changed.attach (tui_rehighlight_all);
+  tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
+  tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
 }
index 058079e208aa44fdeaa3104d7617b8f712ec378a..908d9015bf149efaf8cd9a9a9642b1f225de4c0b 100644 (file)
@@ -294,7 +294,7 @@ tui_source_window_base::tui_source_window_base ()
 
   gdb::observers::source_styling_changed.attach
     (std::bind (&tui_source_window::style_changed, this),
-     m_observable);
+     m_observable, "tui-winsource");
 }
 
 tui_source_window_base::~tui_source_window_base ()
index e19eaf810249b43dd030f596ee1ba921a23800a0..0e3b53f555b03f0ed154ab9ffc60dccb03403bc4 100644 (file)
@@ -73,7 +73,7 @@ run_tests ()
   const gdb::observers::token token1 {}, token2 {} , token3 {};
 
   /* Now, attach one observer, and send a notification.  */
-  test_notification.attach (&test_second_notification_function, token2);
+  test_notification.attach (&test_second_notification_function, token2, "test");
   notify_check_counters (0, 1, 0);
 
   /* Remove the observer, and send a notification.  */
@@ -81,15 +81,15 @@ run_tests ()
   notify_check_counters (0, 0, 0);
 
   /* With a new observer.  */
-  test_notification.attach (&test_first_notification_function, token1);
+  test_notification.attach (&test_first_notification_function, token1, "test");
   notify_check_counters (1, 0, 0);
 
   /* With 2 observers.  */
-  test_notification.attach (&test_second_notification_function, token2);
+  test_notification.attach (&test_second_notification_function, token2, "test");
   notify_check_counters (1, 1, 0);
 
   /* With 3 observers.  */
-  test_notification.attach (&test_third_notification_function, token3);
+  test_notification.attach (&test_third_notification_function, token3, "test");
   notify_check_counters (1, 1, 1);
 
   /* Remove middle observer.  */
@@ -106,9 +106,9 @@ run_tests ()
 
   /* Go back to 3 observers, and remove them in a different
      order...  */
-  test_notification.attach (&test_first_notification_function, token1);
-  test_notification.attach (&test_second_notification_function, token2);
-  test_notification.attach (&test_third_notification_function, token3);
+  test_notification.attach (&test_first_notification_function, token1, "test");
+  test_notification.attach (&test_second_notification_function, token2, "test");
+  test_notification.attach (&test_third_notification_function, token3, "test");
   notify_check_counters (1, 1, 1);
 
   /* Remove the third observer.  */
index bfbd152ae8c97aefeac62f2d05f9aa1912801584..0f3de6d8caae3c08d32b28ffc4067e9e1544f80b 100644 (file)
@@ -1,3 +1,10 @@
+2021-04-24  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * observable.h (class observable) <struct observer> <observer>:
+       Add name parameter.
+       <name>: New field.
+       <attach>: Add name parameter, update all callers.
+
 2021-04-24  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * observable.h (class observable) <struct observer>: New.
index 1d19429ac4f5a8d89e6021a4a63a56adc4fcc04e..5e7846f3f922f43421980ca932fc2c77dbaa8b4d 100644 (file)
@@ -61,12 +61,13 @@ public:
 private:
   struct observer
   {
-    observer (const struct token *token, func_type func)
-      : token (token), func (func)
+    observer (const struct token *token, func_type func, const char *name)
+      : token (token), func (func), name (name)
     {}
 
     const struct token *token;
     func_type func;
+    const char *name;
   };
 
 public:
@@ -78,17 +79,23 @@ public:
   DISABLE_COPY_AND_ASSIGN (observable);
 
   /* Attach F as an observer to this observable.  F cannot be
-     detached.  */
-  void attach (const func_type &f)
+     detached.
+
+     NAME is the name of the observer, used for debug output purposes.  Its
+     lifetime must be at least as long as the observer is attached.  */
+  void attach (const func_type &f, const char *name)
   {
-    m_observers.emplace_back (nullptr, f);
+    m_observers.emplace_back (nullptr, f, name);
   }
 
   /* Attach F as an observer to this observable.  T is a reference to
-     a token that can be used to later remove F.  */
-  void attach (const func_type &f, const token &t)
+     a token that can be used to later remove F.
+
+     NAME is the name of the observer, used for debug output purposes.  Its
+     lifetime must be at least as long as the observer is attached.  */
+  void attach (const func_type &f, const token &t, const char *name)
   {
-    m_observers.emplace_back (&t, f);
+    m_observers.emplace_back (&t, f, name);
   }
 
   /* Remove observers associated with T from this observable.  T is