]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/doc/observer.texi
2004-04-15 Andrew Cagney <cagney@redhat.com>
[thirdparty/binutils-gdb.git] / gdb / doc / observer.texi
CommitLineData
bcd7e15f
JB
1@c -*-texinfo-*-
2@node GDB Observers
3@appendix @value{GDBN} Currently available observers
4
5@section Implementation rationale
6@cindex observers implementation rationale
7
8An @dfn{observer} is an entity which is interested in being notified
9when GDB reaches certain states, or certain events occur in GDB.
10The entity being observed is called the @dfn{subject}. To receive
11notifications, the observer attaches a callback to the subject.
12One subject can have several observers.
13
14@file{observer.c} implements an internal generic low-level event
6be67e67 15notification mechanism. This generic event notification mechanism is
bcd7e15f
JB
16then re-used to implement the exported high-level notification
17management routines for all possible notifications.
18
19The current implementation of the generic observer provides support
20for contextual data. This contextual data is given to the subject
21when attaching the callback. In return, the subject will provide
22this contextual data back to the observer as a parameter of the
23callback.
24
25Note that the current support for the contextual data is only partial,
26as it lacks a mechanism that would deallocate this data when the
27callback is detached. This is not a problem so far, as this contextual
28data is only used internally to hold a function pointer. Later on, if
29a certain observer needs to provide support for user-level contextual
6be67e67 30data, then the generic notification mechanism will need to be
bcd7e15f
JB
31enhanced to allow the observer to provide a routine to deallocate the
32data when attaching the callback.
33
34The observer implementation is also currently not reentrant.
35In particular, it is therefore not possible to call the attach
36or detach routines during a notification.
37
38@section @code{normal_stop} Notifications
39@cindex @code{normal_stop} observer
40@cindex notification about inferior execution stop
41
6be67e67
JB
42@value{GDBN} notifies all @code{normal_stop} observers when the
43inferior execution has just stopped, the associated messages and
44annotations have been printed, and the control is about to be returned
45to the user.
46
47Note that the @code{normal_stop} notification is not emitted when
48the execution stops due to a breakpoint, and this breakpoint has
49a condition that is not met. If the breakpoint has any associated
50commands list, the commands are executed after the notification
51is emitted.
bcd7e15f 52
7a464420 53The following interfaces are available to manage observers:
bcd7e15f 54
7a464420
AC
55@deftypefun extern struct observer *observer_attach_@var{event} (observer_@var{event}_ftype *@var{f})
56Using the function @var{f}, create an observer that is notified when
57ever @var{event} occures, return the observer.
bcd7e15f
JB
58@end deftypefun
59
7a464420 60@deftypefun extern void observer_detach_@var{event} (struct observer *@var{observer});
bcd7e15f 61Remove @var{observer} from the list of observers to be notified when
7a464420 62@var{event} occurs.
bcd7e15f
JB
63@end deftypefun
64
7a464420
AC
65@deftypefun extern void observer_notify_@var{event} (void);
66Send a notification to all @var{event} observers.
bcd7e15f
JB
67@end deftypefun
68
7a464420 69The following observable events are defined:
bcd7e15f 70
7a464420
AC
71@c note: all events must take at least one parameter.
72
73@deftypefun void normal_stop (struct bpstats *@var{bs})
74The inferior has stopped for real.
75@end deftypefun