17f2ac410Schristos /* Observers 27f2ac410Schristos 3*6881a400Schristos Copyright (C) 2016-2023 Free Software Foundation, Inc. 47f2ac410Schristos 57f2ac410Schristos This file is part of GDB. 67f2ac410Schristos 77f2ac410Schristos This program is free software; you can redistribute it and/or modify 87f2ac410Schristos it under the terms of the GNU General Public License as published by 97f2ac410Schristos the Free Software Foundation; either version 3 of the License, or 107f2ac410Schristos (at your option) any later version. 117f2ac410Schristos 127f2ac410Schristos This program is distributed in the hope that it will be useful, 137f2ac410Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 147f2ac410Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 157f2ac410Schristos GNU General Public License for more details. 167f2ac410Schristos 177f2ac410Schristos You should have received a copy of the GNU General Public License 187f2ac410Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 197f2ac410Schristos 207f2ac410Schristos #ifndef OBSERVABLE_H 217f2ac410Schristos #define OBSERVABLE_H 227f2ac410Schristos 237d62b00eSchristos #include "gdbsupport/observable.h" 247f2ac410Schristos 25*6881a400Schristos struct bpstat; 267f2ac410Schristos struct so_list; 277f2ac410Schristos struct objfile; 287f2ac410Schristos struct thread_info; 297f2ac410Schristos struct inferior; 307d62b00eSchristos struct process_stratum_target; 31*6881a400Schristos struct target_ops; 327f2ac410Schristos struct trace_state_variable; 337f2ac410Schristos 347f2ac410Schristos namespace gdb 357f2ac410Schristos { 367f2ac410Schristos 377f2ac410Schristos namespace observers 387f2ac410Schristos { 397f2ac410Schristos 407d62b00eSchristos /* The inferior has stopped for real. The BS argument describes the 417f2ac410Schristos breakpoints were are stopped at, if any. Second argument 427d62b00eSchristos PRINT_FRAME non-zero means display the location where the 437f2ac410Schristos inferior has stopped. 447f2ac410Schristos 457f2ac410Schristos gdb notifies all normal_stop observers when the inferior execution 467f2ac410Schristos has just stopped, the associated messages and annotations have been 477f2ac410Schristos printed, and the control is about to be returned to the user. 487f2ac410Schristos 497f2ac410Schristos Note that the normal_stop notification is not emitted when the 507f2ac410Schristos execution stops due to a breakpoint, and this breakpoint has a 517f2ac410Schristos condition that is not met. If the breakpoint has any associated 527f2ac410Schristos commands list, the commands are executed after the notification is 537f2ac410Schristos emitted. */ 54*6881a400Schristos extern observable<struct bpstat */* bs */, int /* print_frame */> normal_stop; 557f2ac410Schristos 567f2ac410Schristos /* The inferior was stopped by a signal. */ 577d62b00eSchristos extern observable<enum gdb_signal /* siggnal */> signal_received; 587f2ac410Schristos 597f2ac410Schristos /* We are done with a step/next/si/ni command. */ 607f2ac410Schristos extern observable<> end_stepping_range; 617f2ac410Schristos 627f2ac410Schristos /* The inferior was terminated by a signal. */ 637d62b00eSchristos extern observable<enum gdb_signal /* siggnal */> signal_exited; 647f2ac410Schristos 657f2ac410Schristos /* The inferior program is finished. */ 667d62b00eSchristos extern observable<int /* exitstatus */> exited; 677f2ac410Schristos 687f2ac410Schristos /* Reverse execution: target ran out of history info. */ 697f2ac410Schristos extern observable<> no_history; 707f2ac410Schristos 717f2ac410Schristos /* A synchronous command finished. */ 727f2ac410Schristos extern observable<> sync_execution_done; 737f2ac410Schristos 747f2ac410Schristos /* An error was caught while executing a command. */ 757f2ac410Schristos extern observable<> command_error; 767f2ac410Schristos 777f2ac410Schristos /* The target's register contents have changed. */ 787d62b00eSchristos extern observable<struct target_ops */* target */> target_changed; 797f2ac410Schristos 807f2ac410Schristos /* The executable being debugged by GDB has changed: The user 817f2ac410Schristos decided to debug a different program, or the program he was 827f2ac410Schristos debugging has been modified since being loaded by the debugger 837f2ac410Schristos (by being recompiled, for instance). */ 847f2ac410Schristos extern observable<> executable_changed; 857f2ac410Schristos 867f2ac410Schristos /* gdb has just connected to an inferior. For 'run', gdb calls this 877f2ac410Schristos observer while the inferior is still stopped at the entry-point 887f2ac410Schristos instruction. For 'attach' and 'core', gdb calls this observer 897f2ac410Schristos immediately after connecting to the inferior, and before any 907f2ac410Schristos information on the inferior has been printed. */ 91*6881a400Schristos extern observable<inferior */* inferior */> inferior_created; 92*6881a400Schristos 93*6881a400Schristos /* The inferior INF has exec'ed a new executable file. */ 94*6881a400Schristos extern observable<struct inferior */* inf */> inferior_execd; 957f2ac410Schristos 967f2ac410Schristos /* The status of process record for inferior inferior in gdb has 977d62b00eSchristos changed. The process record is started if STARTED is true, and 987d62b00eSchristos the process record is stopped if STARTED is false. 997f2ac410Schristos 1007d62b00eSchristos When STARTED is true, METHOD indicates the short name of the 1017f2ac410Schristos method used for recording. If the method supports multiple 1027d62b00eSchristos formats, FORMAT indicates which one is being used, otherwise it 1037d62b00eSchristos is NULL. When STARTED is false, they are both NULL. */ 1047d62b00eSchristos extern observable<struct inferior */* inferior */, int /* started */, 1057d62b00eSchristos const char */* method */, const char */* format */> 1067f2ac410Schristos record_changed; 1077f2ac410Schristos 1087d62b00eSchristos /* The shared library specified by SOLIB has been loaded. Note that 1097f2ac410Schristos when gdb calls this observer, the library's symbols probably 1107f2ac410Schristos haven't been loaded yet. */ 1117d62b00eSchristos extern observable<struct so_list */* solib */> solib_loaded; 1127f2ac410Schristos 1137d62b00eSchristos /* The shared library specified by SOLIB has been unloaded. Note 1147f2ac410Schristos that when gdb calls this observer, the library's symbols have not 1157f2ac410Schristos been unloaded yet, and thus are still available. */ 1167d62b00eSchristos extern observable<struct so_list */* solib */> solib_unloaded; 1177f2ac410Schristos 1187d62b00eSchristos /* The symbol file specified by OBJFILE has been loaded. Called 1197d62b00eSchristos with OBJFILE equal to NULL to indicate previously loaded symbol 1207f2ac410Schristos table data has now been invalidated. */ 1217d62b00eSchristos extern observable<struct objfile */* objfile */> new_objfile; 1227f2ac410Schristos 1237d62b00eSchristos /* The object file specified by OBJFILE is about to be freed. */ 1247d62b00eSchristos extern observable<struct objfile */* objfile */> free_objfile; 1257f2ac410Schristos 1267d62b00eSchristos /* The thread specified by T has been created. */ 1277d62b00eSchristos extern observable<struct thread_info */* t */> new_thread; 1287f2ac410Schristos 1297d62b00eSchristos /* The thread specified by T has exited. The SILENT argument 1307f2ac410Schristos indicates that gdb is removing the thread from its tables without 1317f2ac410Schristos wanting to notify the user about it. */ 1327d62b00eSchristos extern observable<struct thread_info */* t */, int /* silent */> thread_exit; 1337f2ac410Schristos 1347d62b00eSchristos /* An explicit stop request was issued to PTID. If PTID equals 1357f2ac410Schristos minus_one_ptid, the request applied to all threads. If 1367d62b00eSchristos ptid_is_pid(PTID) returns true, the request applied to all 1377d62b00eSchristos threads of the process pointed at by PTID. Otherwise, the 1387d62b00eSchristos request applied to the single thread pointed at by PTID. */ 1397d62b00eSchristos extern observable<ptid_t /* ptid */> thread_stop_requested; 1407f2ac410Schristos 1417d62b00eSchristos /* The target was resumed. The PTID parameter specifies which 1427f2ac410Schristos thread was resume, and may be RESUME_ALL if all threads are 1437f2ac410Schristos resumed. */ 1447d62b00eSchristos extern observable<ptid_t /* ptid */> target_resumed; 1457f2ac410Schristos 1467f2ac410Schristos /* The target is about to be proceeded. */ 1477f2ac410Schristos extern observable<> about_to_proceed; 1487f2ac410Schristos 1497d62b00eSchristos /* A new breakpoint B has been created. */ 1507d62b00eSchristos extern observable<struct breakpoint */* b */> breakpoint_created; 1517f2ac410Schristos 1527d62b00eSchristos /* A breakpoint has been destroyed. The argument B is the 1537f2ac410Schristos pointer to the destroyed breakpoint. */ 1547d62b00eSchristos extern observable<struct breakpoint */* b */> breakpoint_deleted; 1557f2ac410Schristos 1567d62b00eSchristos /* A breakpoint has been modified in some way. The argument B 1577f2ac410Schristos is the modified breakpoint. */ 1587d62b00eSchristos extern observable<struct breakpoint */* b */> breakpoint_modified; 1597f2ac410Schristos 1607d62b00eSchristos /* The trace frame is changed to TFNUM (e.g., by using the 'tfind' 1617d62b00eSchristos command). If TFNUM is negative, it means gdb resumes live 1627f2ac410Schristos debugging. The number of the tracepoint associated with this 1637d62b00eSchristos traceframe is TPNUM. */ 1647d62b00eSchristos extern observable<int /* tfnum */, int /* tpnum */> traceframe_changed; 1657f2ac410Schristos 1667d62b00eSchristos /* The current architecture has changed. The argument NEWARCH is a 1677f2ac410Schristos pointer to the new architecture. */ 1687d62b00eSchristos extern observable<struct gdbarch */* newarch */> architecture_changed; 1697f2ac410Schristos 1707d62b00eSchristos /* The thread's ptid has changed. The OLD_PTID parameter specifies 1717d62b00eSchristos the old value, and NEW_PTID specifies the new value. */ 1727d62b00eSchristos extern observable<process_stratum_target * /* target */, 1737d62b00eSchristos ptid_t /* old_ptid */, ptid_t /* new_ptid */> 1747d62b00eSchristos thread_ptid_changed; 1757f2ac410Schristos 1767d62b00eSchristos /* The inferior INF has been added to the list of inferiors. At 1777f2ac410Schristos this point, it might not be associated with any process. */ 1787d62b00eSchristos extern observable<struct inferior */* inf */> inferior_added; 1797f2ac410Schristos 1807d62b00eSchristos /* The inferior identified by INF has been attached to a 1817f2ac410Schristos process. */ 1827d62b00eSchristos extern observable<struct inferior */* inf */> inferior_appeared; 1837f2ac410Schristos 1847d62b00eSchristos /* Either the inferior associated with INF has been detached from 1857f2ac410Schristos the process, or the process has exited. */ 1867d62b00eSchristos extern observable<struct inferior */* inf */> inferior_exit; 1877f2ac410Schristos 1887d62b00eSchristos /* The inferior INF has been removed from the list of inferiors. 1897d62b00eSchristos This method is called immediately before freeing INF. */ 1907d62b00eSchristos extern observable<struct inferior */* inf */> inferior_removed; 1917f2ac410Schristos 1927d62b00eSchristos /* Bytes from DATA to DATA + LEN have been written to the inferior 1937d62b00eSchristos at ADDR. */ 1947d62b00eSchristos extern observable<struct inferior */* inferior */, CORE_ADDR /* addr */, 1957d62b00eSchristos ssize_t /* len */, const bfd_byte */* data */> 1967f2ac410Schristos memory_changed; 1977f2ac410Schristos 1987d62b00eSchristos /* Called before a top-level prompt is displayed. CURRENT_PROMPT is 1997f2ac410Schristos the current top-level prompt. */ 2007d62b00eSchristos extern observable<const char */* current_prompt */> before_prompt; 2017f2ac410Schristos 2027f2ac410Schristos /* Variable gdb_datadir has been set. The value may not necessarily 2037f2ac410Schristos change. */ 2047f2ac410Schristos extern observable<> gdb_datadir_changed; 2057f2ac410Schristos 2067f2ac410Schristos /* The parameter of some 'set' commands in console are changed. 2077d62b00eSchristos This method is called after a command 'set param value'. PARAM 2087d62b00eSchristos is the parameter of 'set' command, and VALUE is the value of 2097f2ac410Schristos changed parameter. */ 2107d62b00eSchristos extern observable<const char */* param */, const char */* value */> 2117d62b00eSchristos command_param_changed; 2127f2ac410Schristos 2137d62b00eSchristos /* The new trace state variable TSV is created. */ 2147d62b00eSchristos extern observable<const struct trace_state_variable */* tsv */> tsv_created; 2157f2ac410Schristos 2167d62b00eSchristos /* The trace state variable TSV is deleted. If TSV is NULL, all 2177f2ac410Schristos trace state variables are deleted. */ 2187d62b00eSchristos extern observable<const struct trace_state_variable */* tsv */> tsv_deleted; 2197f2ac410Schristos 2207d62b00eSchristos /* The trace state value TSV is modified. */ 2217d62b00eSchristos extern observable<const struct trace_state_variable */* tsv */> tsv_modified; 2227f2ac410Schristos 2237d62b00eSchristos /* An inferior function at ADDRESS is about to be called in thread 2247d62b00eSchristos THREAD. */ 2257d62b00eSchristos extern observable<ptid_t /* thread */, CORE_ADDR /* address */> 2267d62b00eSchristos inferior_call_pre; 2277f2ac410Schristos 2287d62b00eSchristos /* The inferior function at ADDRESS has just been called. This 2297f2ac410Schristos observer is called even if the inferior exits during the call. 2307d62b00eSchristos THREAD is the thread in which the function was called, which may 2317f2ac410Schristos be different from the current thread. */ 2327d62b00eSchristos extern observable<ptid_t /* thread */, CORE_ADDR /* address */> 2337d62b00eSchristos inferior_call_post; 2347f2ac410Schristos 2357f2ac410Schristos /* A register in the inferior has been modified by the gdb user. */ 236*6881a400Schristos extern observable<frame_info_ptr /* frame */, int /* regnum */> 2377d62b00eSchristos register_changed; 2387f2ac410Schristos 2397f2ac410Schristos /* The user-selected inferior, thread and/or frame has changed. The 2407f2ac410Schristos user_select_what flag specifies if the inferior, thread and/or 2417f2ac410Schristos frame has changed. */ 2427d62b00eSchristos extern observable<user_selected_what /* selection */> 2437d62b00eSchristos user_selected_context_changed; 2447f2ac410Schristos 245*6881a400Schristos /* This is notified when a styling setting has changed, content may need 246*6881a400Schristos to be updated based on the new settings. */ 247*6881a400Schristos extern observable<> styling_changed; 2487f2ac410Schristos 2497d62b00eSchristos /* The CLI's notion of the current source has changed. This differs 2507d62b00eSchristos from user_selected_context_changed in that it is also set by the 2517d62b00eSchristos "list" command. */ 2527d62b00eSchristos extern observable<> current_source_symtab_and_line_changed; 2537d62b00eSchristos 254*6881a400Schristos /* Called when GDB is about to exit. */ 255*6881a400Schristos extern observable<int> gdb_exiting; 256*6881a400Schristos 257*6881a400Schristos /* When a connection is removed. */ 258*6881a400Schristos extern observable<process_stratum_target */* target */> connection_removed; 259*6881a400Schristos 260*6881a400Schristos /* About to enter target_wait (). */ 261*6881a400Schristos extern observable <ptid_t /* ptid */> target_pre_wait; 262*6881a400Schristos 263*6881a400Schristos /* About to leave target_wait (). */ 264*6881a400Schristos extern observable <ptid_t /* event_ptid */> target_post_wait; 265*6881a400Schristos 2667f2ac410Schristos } /* namespace observers */ 2677f2ac410Schristos 2687f2ac410Schristos } /* namespace gdb */ 2697f2ac410Schristos 2707f2ac410Schristos #endif /* OBSERVABLE_H */ 271