]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/gdb/gdb/doc/observer.texi
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / gdb / gdb / doc / observer.texi
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
8 An @dfn{observer} is an entity which is interested in being notified
9 when GDB reaches certain states, or certain events occur in GDB.
10 The entity being observed is called the @dfn{subject}.  To receive
11 notifications, the observer attaches a callback to the subject.
12 One subject can have several observers.
13
14 @file{observer.c} implements an internal generic low-level event
15 notification mechanism.  This generic event notification mechanism is
16 then re-used to implement the exported high-level notification
17 management routines for all possible notifications.
18
19 The current implementation of the generic observer provides support
20 for contextual data.  This contextual data is given to the subject
21 when attaching the callback.  In return, the subject will provide
22 this contextual data back to the observer as a parameter of the
23 callback.
24
25 Note that the current support for the contextual data is only partial,
26 as it lacks a mechanism that would deallocate this data when the
27 callback is detached.  This is not a problem so far, as this contextual
28 data is only used internally to hold a function pointer.  Later on, if
29 a certain observer needs to provide support for user-level contextual
30 data, then the generic notification mechanism will need to be
31 enhanced to allow the observer to provide a routine to deallocate the
32 data when attaching the callback.
33
34 The observer implementation is also currently not reentrant.
35 In particular, it is therefore not possible to call the attach
36 or 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
42 @value{GDBN} notifies all @code{normal_stop} observers when the
43 inferior execution has just stopped, the associated messages and
44 annotations have been printed, and the control is about to be returned
45 to the user. 
46
47 Note that the @code{normal_stop} notification is not emitted when
48 the execution stops due to a breakpoint, and this breakpoint has
49 a condition that is not met.  If the breakpoint has any associated
50 commands list, the commands are executed after the notification
51 is emitted.
52
53 The following interface is available to manage @code{normal_stop}
54 observers:
55
56 @deftypefun extern struct observer *observer_attach_normal_stop (observer_normal_stop_ftype *@var{f})
57 Attach the given @code{normal_stop} callback function @var{f} and
58 return the associated observer.
59 @end deftypefun
60
61 @deftypefun extern void observer_detach_normal_stop (struct observer *@var{observer});
62 Remove @var{observer} from the list of observers to be notified when
63 a @code{normal_stop} event occurs.
64 @end deftypefun
65
66 @deftypefun extern void observer_notify_normal_stop (void);
67 Send a notification to all @code{normal_stop} observers.
68 @end deftypefun
69
70