]>
Commit | Line | Data |
---|---|---|
76727919 TT |
1 | /* Observers |
2 | ||
1d506c26 | 3 | Copyright (C) 2016-2024 Free Software Foundation, Inc. |
76727919 TT |
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 | ||
1a5c2598 TT |
20 | #ifndef OBSERVABLE_H |
21 | #define OBSERVABLE_H | |
76727919 | 22 | |
268a13a5 | 23 | #include "gdbsupport/observable.h" |
f5694400 | 24 | #include "target/waitstatus.h" |
76727919 | 25 | |
313f3b21 | 26 | struct bpstat; |
7b323785 | 27 | struct solib; |
76727919 TT |
28 | struct objfile; |
29 | struct thread_info; | |
30 | struct inferior; | |
b161a60d | 31 | struct process_stratum_target; |
57ebc990 | 32 | struct target_ops; |
76727919 | 33 | struct trace_state_variable; |
063453b1 | 34 | struct program_space; |
76727919 TT |
35 | |
36 | namespace gdb | |
37 | { | |
38 | ||
39 | namespace observers | |
40 | { | |
41 | ||
012fc909 | 42 | /* The inferior has stopped for real. The BS argument describes the |
76727919 | 43 | breakpoints were are stopped at, if any. Second argument |
012fc909 | 44 | PRINT_FRAME non-zero means display the location where the |
76727919 TT |
45 | inferior has stopped. |
46 | ||
47 | gdb notifies all normal_stop observers when the inferior execution | |
48 | has just stopped, the associated messages and annotations have been | |
49 | printed, and the control is about to be returned to the user. | |
50 | ||
51 | Note that the normal_stop notification is not emitted when the | |
52 | execution stops due to a breakpoint, and this breakpoint has a | |
53 | condition that is not met. If the breakpoint has any associated | |
54 | commands list, the commands are executed after the notification is | |
55 | emitted. */ | |
313f3b21 | 56 | extern observable<struct bpstat */* bs */, int /* print_frame */> normal_stop; |
76727919 TT |
57 | |
58 | /* The inferior was stopped by a signal. */ | |
012fc909 | 59 | extern observable<enum gdb_signal /* siggnal */> signal_received; |
76727919 | 60 | |
76727919 | 61 | /* The target's register contents have changed. */ |
012fc909 | 62 | extern observable<struct target_ops */* target */> target_changed; |
76727919 | 63 | |
063453b1 AB |
64 | /* The executable being debugged by GDB in PSPACE has changed: The user |
65 | decided to debug a different program, or the program he was debugging | |
66 | has been modified since being loaded by the debugger (by being | |
67 | recompiled, for instance). The path to the new executable can be found | |
68 | by examining PSPACE->exec_filename. | |
69 | ||
70 | When RELOAD is true the path to the executable hasn't changed, but the | |
71 | file does appear to have changed, so GDB reloaded it, e.g. if the user | |
72 | recompiled the executable. when RELOAD is false then the path to the | |
73 | executable has not changed. */ | |
74 | extern observable<struct program_space */* pspace */, | |
75 | bool /*reload */> executable_changed; | |
76727919 TT |
76 | |
77 | /* gdb has just connected to an inferior. For 'run', gdb calls this | |
78 | observer while the inferior is still stopped at the entry-point | |
79 | instruction. For 'attach' and 'core', gdb calls this observer | |
80 | immediately after connecting to the inferior, and before any | |
81 | information on the inferior has been printed. */ | |
a0ff652f | 82 | extern observable<inferior */* inferior */> inferior_created; |
76727919 | 83 | |
4a1283c8 SM |
84 | /* The inferior EXEC_INF has exec'ed a new executable file. |
85 | ||
86 | Execution continues in FOLLOW_INF, which may or may not be the same as | |
87 | EXEC_INF, depending on "set follow-exec-mode". */ | |
88 | extern observable<inferior */* exec_inf */, inferior */* follow_inf */> | |
89 | inferior_execd; | |
42a4fec5 | 90 | |
f5694400 SM |
91 | /* The inferior PARENT_INF has forked. If we are setting up an inferior for |
92 | the child (because we follow only the child or we follow both), CHILD_INF | |
93 | is the child inferior. Otherwise, CHILD_INF is nullptr. | |
94 | ||
95 | FORK_KIND is TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED. */ | |
96 | extern observable<inferior */* parent_inf */, inferior */* child_inf */, | |
97 | target_waitkind /* fork_kind */> inferior_forked; | |
98 | ||
012fc909 | 99 | /* The shared library specified by SOLIB has been loaded. Note that |
76727919 TT |
100 | when gdb calls this observer, the library's symbols probably |
101 | haven't been loaded yet. */ | |
7b323785 | 102 | extern observable<solib &/* solib */> solib_loaded; |
76727919 | 103 | |
bd93891c SM |
104 | /* The shared library SOLIB has been unloaded from program space PSPACE. |
105 | Note when gdb calls this observer, the library's symbols have not | |
76727919 | 106 | been unloaded yet, and thus are still available. */ |
7b323785 | 107 | extern observable<program_space *, const solib &/* solib */> solib_unloaded; |
76727919 | 108 | |
74daa597 | 109 | /* The symbol file specified by OBJFILE has been loaded. */ |
012fc909 | 110 | extern observable<struct objfile */* objfile */> new_objfile; |
76727919 | 111 | |
74daa597 SM |
112 | /* All objfiles from PSPACE were removed. */ |
113 | extern observable<program_space */* pspace */> all_objfiles_removed; | |
114 | ||
012fc909 TT |
115 | /* The object file specified by OBJFILE is about to be freed. */ |
116 | extern observable<struct objfile */* objfile */> free_objfile; | |
76727919 | 117 | |
012fc909 TT |
118 | /* The thread specified by T has been created. */ |
119 | extern observable<struct thread_info */* t */> new_thread; | |
76727919 | 120 | |
9d7d58e7 PA |
121 | /* The thread specified by T has exited. EXIT_CODE is the thread's |
122 | exit code, if available. The SILENT argument indicates that GDB is | |
123 | removing the thread from its tables without wanting to notify the | |
124 | CLI about it. */ | |
125 | extern observable<thread_info */* t */, | |
6b09f134 | 126 | std::optional<ULONGEST> /* exit_code */, |
9d7d58e7 | 127 | bool /* silent */> thread_exit; |
76727919 | 128 | |
7d1fd671 PA |
129 | /* The thread specified by T has been deleted, with delete_thread. |
130 | This is called just before the thread_info object is destroyed with | |
131 | operator delete. */ | |
132 | extern observable<thread_info */* t */> thread_deleted; | |
133 | ||
012fc909 | 134 | /* An explicit stop request was issued to PTID. If PTID equals |
76727919 | 135 | minus_one_ptid, the request applied to all threads. If |
012fc909 TT |
136 | ptid_is_pid(PTID) returns true, the request applied to all |
137 | threads of the process pointed at by PTID. Otherwise, the | |
138 | request applied to the single thread pointed at by PTID. */ | |
139 | extern observable<ptid_t /* ptid */> thread_stop_requested; | |
76727919 | 140 | |
012fc909 | 141 | /* The target was resumed. The PTID parameter specifies which |
76727919 TT |
142 | thread was resume, and may be RESUME_ALL if all threads are |
143 | resumed. */ | |
012fc909 | 144 | extern observable<ptid_t /* ptid */> target_resumed; |
76727919 TT |
145 | |
146 | /* The target is about to be proceeded. */ | |
147 | extern observable<> about_to_proceed; | |
148 | ||
012fc909 TT |
149 | /* A new breakpoint B has been created. */ |
150 | extern observable<struct breakpoint */* b */> breakpoint_created; | |
76727919 | 151 | |
012fc909 | 152 | /* A breakpoint has been destroyed. The argument B is the |
76727919 | 153 | pointer to the destroyed breakpoint. */ |
012fc909 | 154 | extern observable<struct breakpoint */* b */> breakpoint_deleted; |
76727919 | 155 | |
012fc909 | 156 | /* A breakpoint has been modified in some way. The argument B |
76727919 | 157 | is the modified breakpoint. */ |
012fc909 | 158 | extern observable<struct breakpoint */* b */> breakpoint_modified; |
76727919 | 159 | |
4b2f71e6 AB |
160 | /* GDB has instantiated a new architecture, NEWARCH is a pointer to the new |
161 | architecture. */ | |
162 | extern observable<struct gdbarch */* newarch */> new_architecture; | |
76727919 | 163 | |
012fc909 TT |
164 | /* The thread's ptid has changed. The OLD_PTID parameter specifies |
165 | the old value, and NEW_PTID specifies the new value. */ | |
b161a60d SM |
166 | extern observable<process_stratum_target * /* target */, |
167 | ptid_t /* old_ptid */, ptid_t /* new_ptid */> | |
168 | thread_ptid_changed; | |
76727919 | 169 | |
012fc909 | 170 | /* The inferior INF has been added to the list of inferiors. At |
76727919 | 171 | this point, it might not be associated with any process. */ |
012fc909 | 172 | extern observable<struct inferior */* inf */> inferior_added; |
76727919 | 173 | |
012fc909 | 174 | /* The inferior identified by INF has been attached to a |
76727919 | 175 | process. */ |
012fc909 | 176 | extern observable<struct inferior */* inf */> inferior_appeared; |
76727919 | 177 | |
9056c917 SM |
178 | /* Inferior INF is about to be detached. */ |
179 | extern observable<struct inferior */* inf */> inferior_pre_detach; | |
180 | ||
012fc909 | 181 | /* Either the inferior associated with INF has been detached from |
76727919 | 182 | the process, or the process has exited. */ |
012fc909 | 183 | extern observable<struct inferior */* inf */> inferior_exit; |
76727919 | 184 | |
012fc909 TT |
185 | /* The inferior INF has been removed from the list of inferiors. |
186 | This method is called immediately before freeing INF. */ | |
187 | extern observable<struct inferior */* inf */> inferior_removed; | |
76727919 | 188 | |
c6ae6045 SM |
189 | /* The inferior CLONE has been created by cloning INF. */ |
190 | extern observable<struct inferior */* inf */, struct inferior */* clone */> | |
191 | inferior_cloned; | |
192 | ||
012fc909 TT |
193 | /* Bytes from DATA to DATA + LEN have been written to the inferior |
194 | at ADDR. */ | |
195 | extern observable<struct inferior */* inferior */, CORE_ADDR /* addr */, | |
196 | ssize_t /* len */, const bfd_byte */* data */> | |
76727919 TT |
197 | memory_changed; |
198 | ||
012fc909 | 199 | /* Called before a top-level prompt is displayed. CURRENT_PROMPT is |
76727919 | 200 | the current top-level prompt. */ |
012fc909 | 201 | extern observable<const char */* current_prompt */> before_prompt; |
76727919 TT |
202 | |
203 | /* Variable gdb_datadir has been set. The value may not necessarily | |
204 | change. */ | |
205 | extern observable<> gdb_datadir_changed; | |
206 | ||
012fc909 TT |
207 | /* An inferior function at ADDRESS is about to be called in thread |
208 | THREAD. */ | |
209 | extern observable<ptid_t /* thread */, CORE_ADDR /* address */> | |
210 | inferior_call_pre; | |
76727919 | 211 | |
012fc909 | 212 | /* The inferior function at ADDRESS has just been called. This |
76727919 | 213 | observer is called even if the inferior exits during the call. |
012fc909 | 214 | THREAD is the thread in which the function was called, which may |
76727919 | 215 | be different from the current thread. */ |
012fc909 TT |
216 | extern observable<ptid_t /* thread */, CORE_ADDR /* address */> |
217 | inferior_call_post; | |
76727919 TT |
218 | |
219 | /* A register in the inferior has been modified by the gdb user. */ | |
8480a37e | 220 | extern observable<const frame_info_ptr &/* frame */, int /* regnum */> |
012fc909 | 221 | register_changed; |
76727919 TT |
222 | |
223 | /* The user-selected inferior, thread and/or frame has changed. The | |
224 | user_select_what flag specifies if the inferior, thread and/or | |
225 | frame has changed. */ | |
012fc909 TT |
226 | extern observable<user_selected_what /* selection */> |
227 | user_selected_context_changed; | |
76727919 | 228 | |
43077a23 AB |
229 | /* This is notified when a styling setting has changed, content may need |
230 | to be updated based on the new settings. */ | |
231 | extern observable<> styling_changed; | |
6f11e682 | 232 | |
a75cd9a2 TT |
233 | /* The CLI's notion of the current source has changed. This differs |
234 | from user_selected_context_changed in that it is also set by the | |
235 | "list" command. */ | |
a75cd9a2 TT |
236 | extern observable<> current_source_symtab_and_line_changed; |
237 | ||
b1f0f284 AB |
238 | /* Called when GDB is about to exit. */ |
239 | extern observable<int> gdb_exiting; | |
240 | ||
0e3b7c25 AB |
241 | /* When a connection is removed. */ |
242 | extern observable<process_stratum_target */* target */> connection_removed; | |
243 | ||
fb85cece PM |
244 | /* About to enter target_wait (). */ |
245 | extern observable <ptid_t /* ptid */> target_pre_wait; | |
246 | ||
247 | /* About to leave target_wait (). */ | |
248 | extern observable <ptid_t /* event_ptid */> target_post_wait; | |
249 | ||
59912fb2 AB |
250 | /* New program space PSPACE was created. */ |
251 | extern observable <program_space */* pspace */> new_program_space; | |
252 | ||
253 | /* The program space PSPACE is about to be deleted. */ | |
254 | extern observable <program_space */* pspace */> free_program_space; | |
255 | ||
76727919 TT |
256 | } /* namespace observers */ |
257 | ||
258 | } /* namespace gdb */ | |
259 | ||
1a5c2598 | 260 | #endif /* OBSERVABLE_H */ |