Home | History | Annotate | Line # | Download | only in gdb
      1 /* GDB Notifications to Observers.
      2 
      3    Copyright (C) 2003-2024 Free Software Foundation, Inc.
      4 
      5    This file is part of GDB.
      6 
      7    This program is free software; you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation; either version 3 of the License, or
     10    (at your option) any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19 
     20 #include "observable.h"
     21 #include "command.h"
     22 #include "cli/cli-cmds.h"
     23 
     24 namespace gdb
     25 {
     26 
     27 namespace observers
     28 {
     29 
     30 bool observer_debug = false;
     31 
     32 #define DEFINE_OBSERVABLE(name) decltype (name) name (# name)
     33 
     34 DEFINE_OBSERVABLE (normal_stop);
     35 DEFINE_OBSERVABLE (signal_received);
     36 DEFINE_OBSERVABLE (target_changed);
     37 DEFINE_OBSERVABLE (executable_changed);
     38 DEFINE_OBSERVABLE (inferior_created);
     39 DEFINE_OBSERVABLE (inferior_execd);
     40 DEFINE_OBSERVABLE (inferior_forked);
     41 DEFINE_OBSERVABLE (solib_loaded);
     42 DEFINE_OBSERVABLE (solib_unloaded);
     43 DEFINE_OBSERVABLE (new_objfile);
     44 DEFINE_OBSERVABLE (all_objfiles_removed);
     45 DEFINE_OBSERVABLE (free_objfile);
     46 DEFINE_OBSERVABLE (new_thread);
     47 DEFINE_OBSERVABLE (thread_exit);
     48 DEFINE_OBSERVABLE (thread_deleted);
     49 DEFINE_OBSERVABLE (thread_stop_requested);
     50 DEFINE_OBSERVABLE (target_resumed);
     51 DEFINE_OBSERVABLE (about_to_proceed);
     52 DEFINE_OBSERVABLE (breakpoint_created);
     53 DEFINE_OBSERVABLE (breakpoint_deleted);
     54 DEFINE_OBSERVABLE (breakpoint_modified);
     55 DEFINE_OBSERVABLE (new_architecture);
     56 DEFINE_OBSERVABLE (thread_ptid_changed);
     57 DEFINE_OBSERVABLE (inferior_added);
     58 DEFINE_OBSERVABLE (inferior_appeared);
     59 DEFINE_OBSERVABLE (inferior_pre_detach);
     60 DEFINE_OBSERVABLE (inferior_exit);
     61 DEFINE_OBSERVABLE (inferior_removed);
     62 DEFINE_OBSERVABLE (inferior_cloned);
     63 DEFINE_OBSERVABLE (memory_changed);
     64 DEFINE_OBSERVABLE (before_prompt);
     65 DEFINE_OBSERVABLE (gdb_datadir_changed);
     66 DEFINE_OBSERVABLE (inferior_call_pre);
     67 DEFINE_OBSERVABLE (inferior_call_post);
     68 DEFINE_OBSERVABLE (register_changed);
     69 DEFINE_OBSERVABLE (user_selected_context_changed);
     70 DEFINE_OBSERVABLE (styling_changed);
     71 DEFINE_OBSERVABLE (current_source_symtab_and_line_changed);
     72 DEFINE_OBSERVABLE (gdb_exiting);
     73 DEFINE_OBSERVABLE (connection_removed);
     74 DEFINE_OBSERVABLE (target_pre_wait);
     75 DEFINE_OBSERVABLE (target_post_wait);
     76 DEFINE_OBSERVABLE (new_program_space);
     77 DEFINE_OBSERVABLE (free_program_space);
     78 
     79 } /* namespace observers */
     80 } /* namespace gdb */
     81 
     82 static void
     83 show_observer_debug (struct ui_file *file, int from_tty,
     84 		     struct cmd_list_element *c, const char *value)
     85 {
     86   gdb_printf (file, _("Observer debugging is %s.\n"), value);
     87 }
     88 
     89 void _initialize_observer ();
     90 void
     91 _initialize_observer ()
     92 {
     93   add_setshow_boolean_cmd ("observer", class_maintenance,
     94 			   &gdb::observers::observer_debug, _("\
     95 Set observer debugging."), _("\
     96 Show observer debugging."), _("\
     97 When non-zero, observer debugging is enabled."),
     98 			   NULL,
     99 			   show_observer_debug,
    100 			   &setdebuglist, &showdebuglist);
    101 }
    102