observer.texi
来自「gdb-6.0 linux 下的调试工具」· TEXI 代码 · 共 71 行
TEXI
71 行
@c -*-texinfo-*-@node GDB Observers@appendix @value{GDBN} Currently available observers@section Implementation rationale@cindex observers implementation rationaleAn @dfn{observer} is an entity which is interested in being notifiedwhen GDB reaches certain states, or certain events occur in GDB.The entity being observed is called the @dfn{subject}. To receivenotifications, the observer attaches a callback to the subject.One subject can have several observers.@file{observer.c} implements an internal generic low-level eventnotification mechanism. This generic event notification mechanism isthen re-used to implement the exported high-level notificationmanagement routines for all possible notifications.The current implementation of the generic observer provides supportfor contextual data. This contextual data is given to the subjectwhen attaching the callback. In return, the subject will providethis contextual data back to the observer as a parameter of thecallback.Note that the current support for the contextual data is only partial,as it lacks a mechanism that would deallocate this data when thecallback is detached. This is not a problem so far, as this contextualdata is only used internally to hold a function pointer. Later on, ifa certain observer needs to provide support for user-level contextualdata, then the generic notification mechanism will need to beenhanced to allow the observer to provide a routine to deallocate thedata when attaching the callback.The observer implementation is also currently not reentrant.In particular, it is therefore not possible to call the attachor detach routines during a notification.@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 theinferior execution has just stopped, the associated messages andannotations have been printed, and the control is about to be returnedto the user. Note that the @code{normal_stop} notification is not emitted whenthe execution stops due to a breakpoint, and this breakpoint hasa condition that is not met. If the breakpoint has any associatedcommands list, the commands are executed after the notificationis emitted.The following interface is available to manage @code{normal_stop}observers:@deftypefun extern struct observer *observer_attach_normal_stop (observer_normal_stop_ftype *@var{f})Attach the given @code{normal_stop} callback function @var{f} andreturn the associated observer.@end deftypefun@deftypefun extern void observer_detach_normal_stop (struct observer *@var{observer});Remove @var{observer} from the list of observers to be notified whena @code{normal_stop} event occurs.@end deftypefun@deftypefun extern void observer_notify_normal_stop (void);Send a notification to all @code{normal_stop} observers.@end deftypefun
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?