An observer is an entity which is interested in being notified when GDB reaches certain states, or certain events occur in GDB. The entity being observed is called the subject. To receive notifications, the observer attaches a callback to the subject. One subject can have several observers.
observer.c implements an internal generic low-level event notification mechanism. This generic event notification mechanism is then re-used to implement the exported high-level notification management routines for all possible notifications.
The current implementation of the generic observer does not provide support for contextual data. Normally, callbacks in GDB allow the user to supply a closure argument, holding arbitrary data. However, this was never implemented for observers.
The observer implementation is also currently not reentrant. In particular, it is therefore not possible to call the attach or detach routines during a notification.
Observer notifications can be traced using the command ‘set debug observer 1’ (see Optional messages about internal happenings).
Observer are defined in the otherwise defunct Texinfo file gdb/doc/observer.texi. You can read this to find the current set of observers and their arguments.
The specific observer functions are created at build time by a script, gdb/observer.sh, which reads the Texinfo file and generates C code.