binutils-gdb/gdb/doc/observer.texi

200 lines
7.8 KiB
Plaintext
Raw Normal View History

@c -*-texinfo-*-
@c This file is part of the GDB manual.
@c
gdb: * tui/tui-hooks.c: Include observer.h. (tui_event_default, tui_old_event_hooks, tui_event_hooks): Remove. (tui_bp_created_observer, tui_bp_deleted_observer, tui_bp_modified_observer): New globals. (tui_install_hooks): Use observers, not events. (tui_remove_hooks): Likewise. * mi/mi-cmd-break.c: Include observer.h, not gdb-events.h. (mi_breakpoint_observers_installed, mi_can_breakpoint_notify): New globals. (breakpoint_notify): Check mi_can_breakpoint_notify. (breakpoint_hooks): Remove. (mi_cmd_break_insert): Attach observers. Don't use events. * tracepoint.c: Include observer.h, not gdb-events.h. (tracepoint_operation, trace_pass_command): Notify observer. * interps.c: Don't include gdb-events.h. (clear_interpreter_hooks): Don't call clear_gdb_event_hooks. * gdbarch.c: Rebuild. * gdbarch.sh: Emit include for observer.h, not gdb-events.h. (deprecated_current_gdbarch_select_hack): Notify observer. * breakpoint.h: Don't include gdb-events.h. * breakpoint.c: Don't include gdb-events.h. (condition_command): Notify observer. (commands_command): Likewise. (commands_from_control_command): Likewise. (mention, delete_breakpoint, set_ignore_count): Likewise. (disable_breakpoint, do_enable_breakpoint): Likewise. * Makefile.in (gdb_events_h): Remove. (breakpoint_h): Update. (COMMON_OBS): Remove gdb-events.o. (gdb-events.o): Remove. (breakpoint.o, gdbarch.o, interps.o, tracepoint.o, gdbtk-bp.o, gdbtk-hooks.o, mi-cmd-break.o, tui-hooks.o): Update. * gdb-events.c: Remove. * gdb-events.h: Remove. * gdb-events.sh: Remove. gdb/doc: * observer.texi (GDB Observers): Document new observers: breakpoint_created, breakpoint_deleted, breakpoint_modified, tracepoint_created, tracepoint_deleted, tracepoint_modified, architecture_changed. gdb/gdbtk: * generic/gdbtk-hooks.c: Include observer.h, not gdb-events.h. (gdbtk_add_hooks): Use observers, not events. (gdbtk_architecture_changed): Add argument, for observer. * generic/gdbtk-bp.c: Include observer.h. (gdb_set_bp): Notify observer. (gdb_set_bp_addr): Likewise.
2008-07-25 18:12:03 +02:00
@c Copyright (C) 2003, 2004, 2005, 2006, 2008
@c Free Software Foundation, Inc.
@c
@c See the file gdbint.texinfo for copying conditions.
@c
@c Also, the @deftypefun lines from this file are processed into a
@c header file during the GDB build process. Permission is granted
@c to redistribute and/or modify those lines under the terms of the
@c GNU General Public License as published by the Free Software
@c Foundation; either version 2 of the License, or (at your option)
@c any later version.
@node GDB Observers
@appendix @value{GDBN} Currently available observers
@section Implementation rationale
@cindex observers implementation rationale
An @dfn{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 @dfn{subject}. To receive
notifications, the observer attaches a callback to the subject.
One subject can have several observers.
@file{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.
@section Debugging
Observer notifications can be traced using the command @samp{set debug
observer 1} (@pxref{Debugging Output, , Optional messages about
internal happenings, gdb, Debugging with @var{GDBN}}).
@section @code{normal_stop} Notifications
@cindex @code{normal_stop} observer
@cindex notification about inferior execution stop
@value{GDBN} notifies all @code{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 @code{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:
@deftypefun extern struct observer *observer_attach_@var{event} (observer_@var{event}_ftype *@var{f})
Using the function @var{f}, create an observer that is notified when
ever @var{event} occurs, return the observer.
@end deftypefun
@deftypefun extern void observer_detach_@var{event} (struct observer *@var{observer});
Remove @var{observer} from the list of observers to be notified when
@var{event} occurs.
@end deftypefun
@deftypefun extern void observer_notify_@var{event} (void);
Send a notification to all @var{event} observers.
@end deftypefun
The following observable events are defined:
@deftypefun void normal_stop (struct bpstats *@var{bs})
The inferior has stopped for real.
@end deftypefun
@deftypefun void target_changed (struct target_ops *@var{target})
The target's register contents have changed.
@end deftypefun
@deftypefun 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).
@end deftypefun
@deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
@value{GDBN} has just connected to an inferior. For @samp{run},
@value{GDBN} calls this observer while the inferior is still stopped
at the entry-point instruction. For @samp{attach} and @samp{core},
@value{GDBN} calls this observer immediately after connecting to the
inferior, and before any information on the inferior has been printed.
@end deftypefun
@deftypefun void solib_loaded (struct so_list *@var{solib})
The shared library specified by @var{solib} has been loaded. Note that
when @value{GDBN} calls this observer, the library's symbols probably
haven't been loaded yet.
@end deftypefun
@deftypefun void solib_unloaded (struct so_list *@var{solib})
The shared library specified by @var{solib} has been unloaded.
@end deftypefun
doc/ChangeLog: * observer.texi (GDB Observers): New observer "new_objfile". ChangeLog: * observer.sh: Add "struct objfile" forward declaration. * target.h (deprecated_target_new_objfile_hook): Remove. * symfile.c (deprecated_target_new_objfile_hook): Remove. (clear_symtab_users): Call observer_notify_new_objfile. (symbol_file_add_with_addrs_or_offsets): Likewise. * rs6000-nat.c: Include "observer.h". (vmap_ldinfo): Call observer_notify_new_objfile. (xcoff_relocate_core): Likewise. * remote.c (remote_new_objfile_chain): Remove. (remote_new_objfile): Do not call remote_new_objfile_chain. (_initialize_remote): Use observer_attach_new_objfile. * tui/tui-hooks.c (tui_target_new_objfile_chain): Remove. (tui_new_objfile_hook): Do not call tui_target_new_objfile_chain. (_initialize_tui_hooks): Use observer_attach_new_objfile. * aix-thread.c: Include "observer.h". (target_new_objfile_chain): Remove. (new_objfile): Do not call target_new_objfile_chain. (_initialize_aix_thread): Use observer_attach_new_objfile. * hpux-thread.c: Include "observer.h" (target_new_objfile_chain): Remove. (hpux_thread_new_objfile): Make static. Do not call target_new_objfile_chain. (_initialize_hpux_thread): Use observer_attach_new_objfile. * linux-thread-db.c: Include "observer.h". (target_new_objfile_chain): Remove. (thread_db_new_objfile): Do not call target_new_objfile_chain. (_initialize_thread_db): Use observer_attach_new_objfile. * sol-thread.c: Include "observer.h". (target_new_objfile_chain): Remove. (sol_thread_new_objfile): Make static. Do not call target_new_objfile_chain. (_initialize_sol_thread): Use observer_attach_new_objfile. * Makefile.in (aix-thread.o, hpux-thread.o, linux-thread-db.o, rs6000-nat.o, sol-thread.o, tui-hooks.o): Add dependency on $(observer_h).
2007-05-11 21:55:20 +02:00
@deftypefun void new_objfile (struct objfile *@var{objfile})
The symbol file specified by @var{objfile} has been loaded.
Called with @var{objfile} equal to @code{NULL} to indicate
previously loaded symbol table data has now been invalidated.
@end deftypefun
@deftypefun void new_thread (struct thread_info *@var{t})
The thread specified by @var{t} has been created.
@end deftypefun
@deftypefun void thread_exit (struct thread_info *@var{t})
The thread specified by @var{t} has exited.
@end deftypefun
@deftypefun void thread_stop_requested (ptid_t @var{ptid})
An explicit stop request was issued to @var{ptid}. If @var{ptid}
equals @var{minus_one_ptid}, the request applied to all threads. If
@code{ptid_is_pid(ptid)} returns true, the request applied to all
threads of the process pointed at by @var{ptid}. Otherwise, the
request applied to the single thread pointed at by @var{ptid}.
@end deftypefun
@deftypefun void target_resumed (ptid_t @var{ptid})
The target was resumed. The @var{ptid} parameter specifies which
thread was resume, and may be RESUME_ALL if all threads are resumed.
@end deftypefun
gdb: * tui/tui-hooks.c: Include observer.h. (tui_event_default, tui_old_event_hooks, tui_event_hooks): Remove. (tui_bp_created_observer, tui_bp_deleted_observer, tui_bp_modified_observer): New globals. (tui_install_hooks): Use observers, not events. (tui_remove_hooks): Likewise. * mi/mi-cmd-break.c: Include observer.h, not gdb-events.h. (mi_breakpoint_observers_installed, mi_can_breakpoint_notify): New globals. (breakpoint_notify): Check mi_can_breakpoint_notify. (breakpoint_hooks): Remove. (mi_cmd_break_insert): Attach observers. Don't use events. * tracepoint.c: Include observer.h, not gdb-events.h. (tracepoint_operation, trace_pass_command): Notify observer. * interps.c: Don't include gdb-events.h. (clear_interpreter_hooks): Don't call clear_gdb_event_hooks. * gdbarch.c: Rebuild. * gdbarch.sh: Emit include for observer.h, not gdb-events.h. (deprecated_current_gdbarch_select_hack): Notify observer. * breakpoint.h: Don't include gdb-events.h. * breakpoint.c: Don't include gdb-events.h. (condition_command): Notify observer. (commands_command): Likewise. (commands_from_control_command): Likewise. (mention, delete_breakpoint, set_ignore_count): Likewise. (disable_breakpoint, do_enable_breakpoint): Likewise. * Makefile.in (gdb_events_h): Remove. (breakpoint_h): Update. (COMMON_OBS): Remove gdb-events.o. (gdb-events.o): Remove. (breakpoint.o, gdbarch.o, interps.o, tracepoint.o, gdbtk-bp.o, gdbtk-hooks.o, mi-cmd-break.o, tui-hooks.o): Update. * gdb-events.c: Remove. * gdb-events.h: Remove. * gdb-events.sh: Remove. gdb/doc: * observer.texi (GDB Observers): Document new observers: breakpoint_created, breakpoint_deleted, breakpoint_modified, tracepoint_created, tracepoint_deleted, tracepoint_modified, architecture_changed. gdb/gdbtk: * generic/gdbtk-hooks.c: Include observer.h, not gdb-events.h. (gdbtk_add_hooks): Use observers, not events. (gdbtk_architecture_changed): Add argument, for observer. * generic/gdbtk-bp.c: Include observer.h. (gdb_set_bp): Notify observer. (gdb_set_bp_addr): Likewise.
2008-07-25 18:12:03 +02:00
@deftypefun void breakpoint_created (int @var{bpnum})
A new breakpoint has been created. The argument @var{bpnum} is the
number of the newly-created breakpoint.
@end deftypefun
@deftypefun void breakpoint_deleted (int @var{bpnum})
A breakpoint has been destroyed. The argument @var{bpnum} is the
number of the newly-destroyed breakpoint.
@end deftypefun
@deftypefun void breakpoint_modified (int @var{bpnum})
A breakpoint has been modified in some way. The argument @var{bpnum}
is the number of the modified breakpoint.
@end deftypefun
@deftypefun void tracepoint_created (int @var{tpnum})
A new tracepoint has been created. The argument @var{tpnum} is the
number of the newly-created tracepoint.
@end deftypefun
@deftypefun void tracepoint_deleted (int @var{tpnum})
A tracepoint has been destroyed. The argument @var{tpnum} is the
number of the newly-destroyed tracepoint.
@end deftypefun
@deftypefun void tracepoint_modified (int @var{tpnum})
A tracepoint has been modified in some way. The argument @var{tpnum}
is the number of the modified tracepoint.
@end deftypefun
@deftypefun void architecture_changed (struct gdbarch *@var{newarch})
The current architecture has changed. The argument @var{newarch} is
a pointer to the new architecture.
@end deftypefun
@deftypefun void thread_ptid_changed (ptid_t @var{old_ptid}, ptid_t @var{new_ptid})
The thread's ptid has changed. The @var{old_ptid} parameter specifies
the old value, and @var{new_ptid} specifies the new value.
@end deftypefun
@deftypefun void new_inferior (int @var{pid})
@value{GDBN} has attached to a new inferior identified by @var{pid}.
@end deftypefun
@deftypefun void inferior_exit (int @var{pid})
Either @value{GDBN} detached from the inferior, or the inferior
exited. The argument @var{pid} identifies the inferior.
@end deftypefun