GDB (xrefs)
Loading...
Searching...
No Matches
observable.h
Go to the documentation of this file.
1/* Observers
2
3 Copyright (C) 2016-2023 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#ifndef OBSERVABLE_H
21#define OBSERVABLE_H
22
23#include "gdbsupport/observable.h"
24#include "target/waitstatus.h"
25
26struct bpstat;
27struct so_list;
28struct objfile;
29struct thread_info;
30struct inferior;
32struct target_ops;
34struct program_space;
35
36namespace gdb
37{
38
39namespace observers
40{
41
42/* The inferior has stopped for real. The BS argument describes the
43 breakpoints were are stopped at, if any. Second argument
44 PRINT_FRAME non-zero means display the location where the
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. */
56extern observable<struct bpstat */* bs */, int /* print_frame */> normal_stop;
57
58/* The inferior was stopped by a signal. */
59extern observable<enum gdb_signal /* siggnal */> signal_received;
60
61/* The target's register contents have changed. */
62extern observable<struct target_ops */* target */> target_changed;
63
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. */
74extern observable<struct program_space */* pspace */,
75 bool /*reload */> executable_changed;
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. */
82extern observable<inferior */* inferior */> inferior_created;
83
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". */
88extern observable<inferior */* exec_inf */, inferior */* follow_inf */>
90
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. */
96extern observable<inferior */* parent_inf */, inferior */* child_inf */,
97 target_waitkind /* fork_kind */> inferior_forked;
98
99/* The shared library specified by SOLIB has been loaded. Note that
100 when gdb calls this observer, the library's symbols probably
101 haven't been loaded yet. */
102extern observable<struct so_list */* solib */> solib_loaded;
103
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
106 been unloaded yet, and thus are still available. */
107extern observable<struct program_space */* pspace */, struct so_list */* solib */>
109
110/* The symbol file specified by OBJFILE has been loaded. */
111extern observable<struct objfile */* objfile */> new_objfile;
112
113/* All objfiles from PSPACE were removed. */
114extern observable<program_space */* pspace */> all_objfiles_removed;
115
116/* The object file specified by OBJFILE is about to be freed. */
117extern observable<struct objfile */* objfile */> free_objfile;
118
119/* The thread specified by T has been created. */
120extern observable<struct thread_info */* t */> new_thread;
121
122/* The thread specified by T has exited. EXIT_CODE is the thread's
123 exit code, if available. The SILENT argument indicates that GDB is
124 removing the thread from its tables without wanting to notify the
125 CLI about it. */
126extern observable<thread_info */* t */,
127 gdb::optional<ULONGEST> /* exit_code */,
128 bool /* silent */> thread_exit;
129
130/* An explicit stop request was issued to PTID. If PTID equals
131 minus_one_ptid, the request applied to all threads. If
132 ptid_is_pid(PTID) returns true, the request applied to all
133 threads of the process pointed at by PTID. Otherwise, the
134 request applied to the single thread pointed at by PTID. */
135extern observable<ptid_t /* ptid */> thread_stop_requested;
136
137/* The target was resumed. The PTID parameter specifies which
138 thread was resume, and may be RESUME_ALL if all threads are
139 resumed. */
140extern observable<ptid_t /* ptid */> target_resumed;
141
142/* The target is about to be proceeded. */
143extern observable<> about_to_proceed;
144
145/* A new breakpoint B has been created. */
146extern observable<struct breakpoint */* b */> breakpoint_created;
147
148/* A breakpoint has been destroyed. The argument B is the
149 pointer to the destroyed breakpoint. */
150extern observable<struct breakpoint */* b */> breakpoint_deleted;
151
152/* A breakpoint has been modified in some way. The argument B
153 is the modified breakpoint. */
154extern observable<struct breakpoint */* b */> breakpoint_modified;
155
156/* The current architecture has changed. The argument NEWARCH is a
157 pointer to the new architecture. */
158extern observable<struct gdbarch */* newarch */> architecture_changed;
159
160/* The thread's ptid has changed. The OLD_PTID parameter specifies
161 the old value, and NEW_PTID specifies the new value. */
162extern observable<process_stratum_target * /* target */,
163 ptid_t /* old_ptid */, ptid_t /* new_ptid */>
165
166/* The inferior INF has been added to the list of inferiors. At
167 this point, it might not be associated with any process. */
168extern observable<struct inferior */* inf */> inferior_added;
169
170/* The inferior identified by INF has been attached to a
171 process. */
172extern observable<struct inferior */* inf */> inferior_appeared;
173
174/* Inferior INF is about to be detached. */
175extern observable<struct inferior */* inf */> inferior_pre_detach;
176
177/* Either the inferior associated with INF has been detached from
178 the process, or the process has exited. */
179extern observable<struct inferior */* inf */> inferior_exit;
180
181/* The inferior INF has been removed from the list of inferiors.
182 This method is called immediately before freeing INF. */
183extern observable<struct inferior */* inf */> inferior_removed;
184
185/* The inferior CLONE has been created by cloning INF. */
186extern observable<struct inferior */* inf */, struct inferior */* clone */>
188
189/* Bytes from DATA to DATA + LEN have been written to the inferior
190 at ADDR. */
191extern observable<struct inferior */* inferior */, CORE_ADDR /* addr */,
192 ssize_t /* len */, const bfd_byte */* data */>
194
195/* Called before a top-level prompt is displayed. CURRENT_PROMPT is
196 the current top-level prompt. */
197extern observable<const char */* current_prompt */> before_prompt;
198
199/* Variable gdb_datadir has been set. The value may not necessarily
200 change. */
201extern observable<> gdb_datadir_changed;
202
203/* An inferior function at ADDRESS is about to be called in thread
204 THREAD. */
205extern observable<ptid_t /* thread */, CORE_ADDR /* address */>
207
208/* The inferior function at ADDRESS has just been called. This
209 observer is called even if the inferior exits during the call.
210 THREAD is the thread in which the function was called, which may
211 be different from the current thread. */
212extern observable<ptid_t /* thread */, CORE_ADDR /* address */>
214
215/* A register in the inferior has been modified by the gdb user. */
216extern observable<frame_info_ptr /* frame */, int /* regnum */>
218
219/* The user-selected inferior, thread and/or frame has changed. The
220 user_select_what flag specifies if the inferior, thread and/or
221 frame has changed. */
222extern observable<user_selected_what /* selection */>
224
225/* This is notified when a styling setting has changed, content may need
226 to be updated based on the new settings. */
227extern observable<> styling_changed;
228
229/* The CLI's notion of the current source has changed. This differs
230 from user_selected_context_changed in that it is also set by the
231 "list" command. */
233
234/* Called when GDB is about to exit. */
235extern observable<int> gdb_exiting;
236
237/* When a connection is removed. */
238extern observable<process_stratum_target */* target */> connection_removed;
239
240/* About to enter target_wait (). */
241extern observable <ptid_t /* ptid */> target_pre_wait;
242
243/* About to leave target_wait (). */
244extern observable <ptid_t /* event_ptid */> target_post_wait;
245
246/* New program space PSPACE was created. */
247extern observable <program_space */* pspace */> new_program_space;
248
249/* The program space PSPACE is about to be deleted. */
250extern observable <program_space */* pspace */> free_program_space;
251
252} /* namespace observers */
253
254} /* namespace gdb */
255
256#endif /* OBSERVABLE_H */
observable< ptid_t, CORE_ADDR > inferior_call_pre
observable< struct inferior *, CORE_ADDR, ssize_t, const bfd_byte * > memory_changed
observable< struct so_list * > solib_loaded
observable current_source_symtab_and_line_changed
observable< ptid_t > thread_stop_requested
observable< struct inferior * > inferior_added
observable< struct inferior * > inferior_exit
observable< struct breakpoint * > breakpoint_created
observable< struct objfile * > free_objfile
observable< struct breakpoint * > breakpoint_modified
observable< struct breakpoint * > breakpoint_deleted
observable< ptid_t > target_post_wait
observable< struct objfile * > new_objfile
observable< inferior *, inferior * > inferior_execd
observable< struct thread_info * > new_thread
observable< struct inferior * > inferior_removed
observable< ptid_t, CORE_ADDR > inferior_call_post
observable< inferior *, inferior *, target_waitkind > inferior_forked
observable gdb_datadir_changed
observable< const char * > before_prompt
observable< inferior * > inferior_created
observable< struct target_ops * > target_changed
observable< int > gdb_exiting
observable< user_selected_what > user_selected_context_changed
observable< process_stratum_target *, ptid_t, ptid_t > thread_ptid_changed
observable< ptid_t > target_pre_wait
observable< program_space * > new_program_space
observable< ptid_t > target_resumed
observable< struct program_space *, bool > executable_changed
observable< struct gdbarch * > architecture_changed
observable about_to_proceed
observable< program_space * > all_objfiles_removed
observable< struct inferior * > inferior_appeared
observable< struct bpstat *, int > normal_stop
observable< frame_info_ptr, int > register_changed
observable< process_stratum_target * > connection_removed
observable< struct inferior * > inferior_pre_detach
observable< thread_info *, gdb::optional< ULONGEST >, bool > thread_exit
observable< struct program_space *, struct so_list * > solib_unloaded
observable< enum gdb_signal > signal_received
observable< program_space * > free_program_space
observable styling_changed
observable< struct inferior *, struct inferior * > inferior_cloned
target_waitkind
Definition waitstatus.h:30