]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/doc/observer.texi
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / gdb / doc / observer.texi
CommitLineData
bcd7e15f 1@c -*-texinfo-*-
16d1a084
DJ
2
3@c This file is part of the GDB manual.
4@c
32d0add0 5@c Copyright (C) 2003-2015 Free Software Foundation, Inc.
16d1a084
DJ
6@c
7@c See the file gdbint.texinfo for copying conditions.
8@c
9@c Also, the @deftypefun lines from this file are processed into a
10@c header file during the GDB build process. Permission is granted
11@c to redistribute and/or modify those lines under the terms of the
12@c GNU General Public License as published by the Free Software
a1715244 13@c Foundation; either version 3 of the License, or (at your option)
16d1a084
DJ
14@c any later version.
15
bcd7e15f
JB
16@node GDB Observers
17@appendix @value{GDBN} Currently available observers
18
19@section Implementation rationale
20@cindex observers implementation rationale
21
22An @dfn{observer} is an entity which is interested in being notified
23when GDB reaches certain states, or certain events occur in GDB.
24The entity being observed is called the @dfn{subject}. To receive
25notifications, the observer attaches a callback to the subject.
26One subject can have several observers.
27
28@file{observer.c} implements an internal generic low-level event
6be67e67 29notification mechanism. This generic event notification mechanism is
bcd7e15f
JB
30then re-used to implement the exported high-level notification
31management routines for all possible notifications.
32
33The current implementation of the generic observer provides support
34for contextual data. This contextual data is given to the subject
35when attaching the callback. In return, the subject will provide
36this contextual data back to the observer as a parameter of the
37callback.
38
39Note that the current support for the contextual data is only partial,
40as it lacks a mechanism that would deallocate this data when the
41callback is detached. This is not a problem so far, as this contextual
42data is only used internally to hold a function pointer. Later on, if
43a certain observer needs to provide support for user-level contextual
6be67e67 44data, then the generic notification mechanism will need to be
bcd7e15f
JB
45enhanced to allow the observer to provide a routine to deallocate the
46data when attaching the callback.
47
48The observer implementation is also currently not reentrant.
49In particular, it is therefore not possible to call the attach
50or detach routines during a notification.
51
2b4855ab
AC
52@section Debugging
53Observer notifications can be traced using the command @samp{set debug
54observer 1} (@pxref{Debugging Output, , Optional messages about
55internal happenings, gdb, Debugging with @var{GDBN}}).
56
bcd7e15f
JB
57@section @code{normal_stop} Notifications
58@cindex @code{normal_stop} observer
59@cindex notification about inferior execution stop
60
6be67e67
JB
61@value{GDBN} notifies all @code{normal_stop} observers when the
62inferior execution has just stopped, the associated messages and
63annotations have been printed, and the control is about to be returned
16d1a084 64to the user.
6be67e67
JB
65
66Note that the @code{normal_stop} notification is not emitted when
67the execution stops due to a breakpoint, and this breakpoint has
68a condition that is not met. If the breakpoint has any associated
69commands list, the commands are executed after the notification
70is emitted.
bcd7e15f 71
7a464420 72The following interfaces are available to manage observers:
bcd7e15f 73
7a464420
AC
74@deftypefun extern struct observer *observer_attach_@var{event} (observer_@var{event}_ftype *@var{f})
75Using the function @var{f}, create an observer that is notified when
d3e8051b 76ever @var{event} occurs, return the observer.
bcd7e15f
JB
77@end deftypefun
78
7a464420 79@deftypefun extern void observer_detach_@var{event} (struct observer *@var{observer});
bcd7e15f 80Remove @var{observer} from the list of observers to be notified when
7a464420 81@var{event} occurs.
bcd7e15f
JB
82@end deftypefun
83
7a464420
AC
84@deftypefun extern void observer_notify_@var{event} (void);
85Send a notification to all @var{event} observers.
bcd7e15f
JB
86@end deftypefun
87
7a464420 88The following observable events are defined:
bcd7e15f 89
1d33d6ba
VP
90@deftypefun void normal_stop (struct bpstats *@var{bs}, int @var{print_frame})
91The inferior has stopped for real. The @var{bs} argument describes
92the breakpoints were are stopped at, if any. Second argument
93@var{print_frame} non-zero means display the location where the
94inferior has stopped.
7a464420 95@end deftypefun
79346bcb 96
fd664c91
PA
97@deftypefun void signal_received (enum gdb_signal @var{siggnal})
98The inferior was stopped by a signal.
99@end deftypefun
100
101@deftypefun void end_stepping_range (void)
102We are done with a step/next/si/ni command.
103@end deftypefun
104
105@deftypefun void signal_exited (enum gdb_signal @var{siggnal})
106The inferior was terminated by a signal.
107@end deftypefun
108
109@deftypefun void exited (int @var{exitstatus})
110The inferior program is finished.
111@end deftypefun
112
113@deftypefun void no_history (void)
114Reverse execution: target ran out of history info.
115@end deftypefun
116
92bcb5f9
PA
117@deftypefun void sync_execution_done (void)
118A synchronous command finished.
119@end deftypefun
120
121@deftypefun void command_error (void)
122An error was caught while executing a command.
123@end deftypefun
124
79346bcb 125@deftypefun void target_changed (struct target_ops *@var{target})
67ab9a76 126The target's register contents have changed.
79346bcb 127@end deftypefun
59caf092 128
781b42b0 129@deftypefun void executable_changed (void)
ea53e89f
JB
130The executable being debugged by GDB has changed: The user decided
131to debug a different program, or the program he was debugging has
132been modified since being loaded by the debugger (by being recompiled,
133for instance).
134@end deftypefun
135
59caf092
AC
136@deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
137@value{GDBN} has just connected to an inferior. For @samp{run},
138@value{GDBN} calls this observer while the inferior is still stopped
139at the entry-point instruction. For @samp{attach} and @samp{core},
140@value{GDBN} calls this observer immediately after connecting to the
141inferior, and before any information on the inferior has been printed.
142@end deftypefun
f3bb6704 143
82a90ccf
YQ
144@deftypefun void record_changed (struct inferior *@var{inferior}, int @var{started})
145The status of process record for inferior @var{inferior} in
146@value{GDBN} has changed. The process record is started if
147@var{started} is true, and the process record is stopped if
148@var{started} is false.
149@end deftypefun
150
fbd1b305
MK
151@deftypefun void solib_loaded (struct so_list *@var{solib})
152The shared library specified by @var{solib} has been loaded. Note that
153when @value{GDBN} calls this observer, the library's symbols probably
154haven't been loaded yet.
f3bb6704
JJ
155@end deftypefun
156
fbd1b305
MK
157@deftypefun void solib_unloaded (struct so_list *@var{solib})
158The shared library specified by @var{solib} has been unloaded.
30a4a70c
JB
159Note that when @value{GDBN} calls this observer, the library's
160symbols have not been unloaded yet, and thus are still available.
fbd1b305 161@end deftypefun
06d3b283
UW
162
163@deftypefun void new_objfile (struct objfile *@var{objfile})
164The symbol file specified by @var{objfile} has been loaded.
165Called with @var{objfile} equal to @code{NULL} to indicate
166previously loaded symbol table data has now been invalidated.
167@end deftypefun
168
63644780
NB
169@deftypefun void free_objfile (struct objfile *@var{objfile})
170The object file specified by @var{objfile} is about to be freed.
171@end deftypefun
172
683f2885
VP
173@deftypefun void new_thread (struct thread_info *@var{t})
174The thread specified by @var{t} has been created.
175@end deftypefun
176
a07daef3
PA
177@deftypefun void thread_exit (struct thread_info *@var{t}, int @var{silent})
178The thread specified by @var{t} has exited. The @var{silent} argument
179indicates that @value{GDBN} is removing the thread from its tables
180without wanting to notify the user about it.
063bfe2e
VP
181@end deftypefun
182
252fbfc8
PA
183@deftypefun void thread_stop_requested (ptid_t @var{ptid})
184An explicit stop request was issued to @var{ptid}. If @var{ptid}
185equals @var{minus_one_ptid}, the request applied to all threads. If
186@code{ptid_is_pid(ptid)} returns true, the request applied to all
187threads of the process pointed at by @var{ptid}. Otherwise, the
188request applied to the single thread pointed at by @var{ptid}.
189@end deftypefun
190
e1ac3328
VP
191@deftypefun void target_resumed (ptid_t @var{ptid})
192The target was resumed. The @var{ptid} parameter specifies which
193thread was resume, and may be RESUME_ALL if all threads are resumed.
194@end deftypefun
383f836e 195
f3b1572e
PA
196@deftypefun void about_to_proceed (void)
197The target is about to be proceeded.
198@end deftypefun
199
8d3788bd
VP
200@deftypefun void breakpoint_created (struct breakpoint *@var{b})
201A new breakpoint @var{b} has been created.
383f836e
TT
202@end deftypefun
203
8d3788bd
VP
204@deftypefun void breakpoint_deleted (struct breakpoint *@var{b})
205A breakpoint has been destroyed. The argument @var{b} is the
206pointer to the destroyed breakpoint.
383f836e
TT
207@end deftypefun
208
8d3788bd
VP
209@deftypefun void breakpoint_modified (struct breakpoint *@var{b})
210A breakpoint has been modified in some way. The argument @var{b}
211is the modified breakpoint.
383f836e
TT
212@end deftypefun
213
201b4506
YQ
214@deftypefun void traceframe_changed (int @var{tfnum}, int @var{tpnum})
215The trace frame is changed to @var{tfnum} (e.g., by using the
216@code{tfind} command). If @var{tfnum} is negative, it means
217@value{GDBN} resumes live debugging. The number of the tracepoint
218associated with this traceframe is @var{tpnum}.
219@end deftypefun
220
383f836e
TT
221@deftypefun void architecture_changed (struct gdbarch *@var{newarch})
222The current architecture has changed. The argument @var{newarch} is
223a pointer to the new architecture.
224@end deftypefun
225
5231c1fd
PA
226@deftypefun void thread_ptid_changed (ptid_t @var{old_ptid}, ptid_t @var{new_ptid})
227The thread's ptid has changed. The @var{old_ptid} parameter specifies
228the old value, and @var{new_ptid} specifies the new value.
229@end deftypefun
4a92f99b 230
a79b8f6e
VP
231@deftypefun void inferior_added (struct inferior *@var{inf})
232The inferior @var{inf} has been added to the list of inferiors. At
233this point, it might not be associated with any process.
4a92f99b
VP
234@end deftypefun
235
a79b8f6e
VP
236@deftypefun void inferior_appeared (struct inferior *@var{inf})
237The inferior identified by @var{inf} has been attached to a process.
238@end deftypefun
239
240@deftypefun void inferior_exit (struct inferior *@var{inf})
241Either the inferior associated with @var{inf} has been detached from the
242process, or the process has exited.
243@end deftypefun
244
245@deftypefun void inferior_removed (struct inferior *@var{inf})
246The inferior @var{inf} has been removed from the list of inferiors.
247This method is called immediately before freeing @var{inf}.
8cebebb9
PP
248@end deftypefun
249
8de0566d 250@deftypefun void memory_changed (struct inferior *@var{inferior}, CORE_ADDR @var{addr}, ssize_t @var{len}, const bfd_byte *@var{data})
8cebebb9 251Bytes from @var{data} to @var{data} + @var{len} have been written
8de0566d 252to the @var{inferior} at @var{addr}.
4a92f99b
VP
253@end deftypefun
254
d17b6f81
PM
255@deftypefun void before_prompt (const char *@var{current_prompt})
256Called before a top-level prompt is displayed. @var{current_prompt} is
257the current top-level prompt.
258@end deftypefun
259
6dea1fbd
JK
260@deftypefun void gdb_datadir_changed (void)
261Variable gdb_datadir has been set. The value may not necessarily change.
262@end deftypefun
263
5b9afe8a
YQ
264@deftypefun void command_param_changed (const char *@var{param}, const char *@var{value})
265The parameter of some @code{set} commands in console are changed. This
266method is called after a command @code{set @var{param} @var{value}}.
267@var{param} is the parameter of @code{set} command, and @var{value}
268is the value of changed parameter.
bb25a15c
YQ
269@end deftypefun
270
134a2066
YQ
271@deftypefun void tsv_created (const struct trace_state_variable *@var{tsv})
272The new trace state variable @var{tsv} is created.
bb25a15c 273@end deftypefun
5b9afe8a 274
134a2066
YQ
275@deftypefun void tsv_deleted (const struct trace_state_variable *@var{tsv})
276The trace state variable @var{tsv} is deleted. If @var{tsv} is
bb25a15c 277@code{NULL}, all trace state variables are deleted.
5b9afe8a
YQ
278@end deftypefun
279
134a2066
YQ
280@deftypefun void tsv_modified (const struct trace_state_variable *@var{tsv})
281The trace state value @var{tsv} is modified.
282@end deftypefun
283
162078c8
NB
284@deftypefun void inferior_call_pre (ptid_t @var{thread}, CORE_ADDR @var{address})
285An inferior function at @var{address} is about to be called in thread
286@var{thread}.
287@end deftypefun
288
289@deftypefun void inferior_call_post (ptid_t @var{thread}, CORE_ADDR @var{address})
290The inferior function at @var{address} has just been called. This observer
291is called even if the inferior exits during the call. @var{thread} is the
292thread in which the function was called, which may be different from the
293current thread.
294@end deftypefun
295
296@deftypefun void register_changed (struct frame_info *@var{frame}, int @var{regnum})
297A register in the inferior has been modified by the @value{GDBN} user.
298@end deftypefun
299
a79b8f6e 300@deftypefun void test_notification (int @var{somearg})
3ea85240
VP
301This observer is used for internal testing. Do not use.
302See testsuite/gdb.gdb/observer.exp.
a79b8f6e 303@end deftypefun
3ea85240 304