A. GDB Currently available observers
A.1 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 provides support
for contextual data. This contextual data is given to the subject
when attaching the callback. In return, the subject will provide
this contextual data back to the observer as a parameter of the
callback.
Note that the current support for the contextual data is only partial,
as it lacks a mechanism that would deallocate this data when the
callback is detached. This is not a problem so far, as this contextual
data is only used internally to hold a function pointer. Later on, if
a certain observer needs to provide support for user-level contextual
data, then the generic notification mechanism will need to be
enhanced to allow the observer to provide a routine to deallocate the
data when attaching the callback.
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.
A.2 Debugging
Observer notifications can be traced using the command `set debug
observer 1' (see section `Optional messages about internal happenings' in Debugging with GDBN).
A.3 normal_stop Notifications
GDB notifies all normal_stop observers when the
inferior execution has just stopped, the associated messages and
annotations have been printed, and the control is about to be returned
to the user.
Note that the normal_stop notification is not emitted when
the execution stops due to a breakpoint, and this breakpoint has
a condition that is not met. If the breakpoint has any associated
commands list, the commands are executed after the notification
is emitted.
The following interfaces are available to manage observers:
- Function: extern struct observer *observer_attach_event (observer_event_ftype *f)
- Using the function f, create an observer that is notified when
ever event occurs, return the observer.
- Function: extern void observer_detach_event (struct observer *observer);
- Remove observer from the list of observers to be notified when
event occurs.
- Function: extern void observer_notify_event (void);
- Send a notification to all event observers.
The following observable events are defined:
- Function: void normal_stop (struct bpstats *bs)
- The inferior has stopped for real.
- Function: void target_changed (struct target_ops *target)
- The target's register contents have changed.
- Function: void executable_changed (void)
- The executable being debugged by GDB has changed: The user decided
to debug a different program, or the program he was debugging has
been modified since being loaded by the debugger (by being recompiled,
for instance).
- Function: void inferior_created (struct target_ops *objfile, int from_tty)
- GDB has just connected to an inferior. For `run',
GDB calls this observer while the inferior is still stopped
at the entry-point instruction. For `attach' and `core',
GDB calls this observer immediately after connecting to the
inferior, and before any information on the inferior has been printed.
- Function: void solib_loaded (struct so_list *solib)
- The shared library specified by solib has been loaded. Note that
when GDB calls this observer, the library's symbols probably
haven't been loaded yet.
- Function: void solib_unloaded (struct so_list *solib)
- The shared library specified by solib has been unloaded.
- Function: void new_objfile (struct objfile *objfile)
- The symbol file specified by objfile has been loaded.
Called with objfile equal to
NULL to indicate
previously loaded symbol table data has now been invalidated.
- Function: void new_thread (struct thread_info *t)
- The thread specified by t has been created.
- Function: void thread_exit (struct thread_info *t)
- The thread specified by t has exited.
- Function: void target_resumed (ptid_t ptid)
- The target was resumed. The ptid parameter specifies which
thread was resume, and may be RESUME_ALL if all threads are resumed.
- Function: void breakpoint_created (int bpnum)
- A new breakpoint has been created. The argument bpnum is the
number of the newly-created breakpoint.
- Function: void breakpoint_deleted (int bpnum)
- A breakpoint has been destroyed. The argument bpnum is the
number of the newly-destroyed breakpoint.
- Function: void breakpoint_modified (int bpnum)
- A breakpoint has been modified in some way. The argument bpnum
is the number of the modified breakpoint.
- Function: void tracepoint_created (int tpnum)
- A new tracepoint has been created. The argument tpnum is the
number of the newly-created tracepoint.
- Function: void tracepoint_deleted (int tpnum)
- A tracepoint has been destroyed. The argument tpnum is the
number of the newly-destroyed tracepoint.
- Function: void tracepoint_modified (int tpnum)
- A tracepoint has been modified in some way. The argument tpnum
is the number of the modified tracepoint.
- Function: void architecture_changed (struct gdbarch *newarch)
- The current architecture has changed. The argument newarch is
a pointer to the new architecture.
- Function: void thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
- The thread's ptid has changed. The old_ptid parameter specifies
the old value, and new_ptid specifies the new value.
Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also other ways to
contact the FSF.
These pages are maintained by the GDB developers.
Copyright Free Software Foundation, Inc., 59 Temple Place - Suite
330, Boston, MA 02111, USA.
Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.
This document was generated
by GDB Administrator on September, 28 2008
using texi2html