GDB Observers

Implementation rationale

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).

More reading

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/, which reads the Texinfo file and generates C code.

None: Internals GDB-Observers (last edited 2016-03-11 14:25:10 by TomTromey)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.