From: Eli Zaretskii Date: Tue, 26 Sep 2000 15:53:59 +0000 (+0000) Subject: * gdb.texinfo (Hooks): Document the new post-hook functionality. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c78b4128575c657ab87e3170fdd2d63b09a3072f;p=binutils-gdb.git * gdb.texinfo (Hooks): Document the new post-hook functionality. From Steven Johnson . --- diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index fd9566b1b91..1dc783e5eb6 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2000-09-26 Eli Zaretskii + + * gdb.texinfo (Hooks): Document the new post-hook functionality. + From Steven Johnson . + 2000-08-10 Mark Kettenis * gdbint.texinfo (Overall Structure): Spelling fix. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 1f4e95ec628..2aee191f2f1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -11859,12 +11859,30 @@ messages when used in a user-defined command. @section User-defined command hooks @cindex command hooks @cindex hooks, for commands +@cindex hooks, pre-command -You may define @emph{hooks}, which are a special kind of user-defined +@kindex hook +@kindex hook- +You may define @dfn{hooks}, which are a special kind of user-defined command. Whenever you run the command @samp{foo}, if the user-defined command @samp{hook-foo} exists, it is executed (with no arguments) before that command. +@cindex hooks, post-command +@kindex hookpost +@kindex hookpost- +A hook may also be defined which is run after the command you executed. +Whenever you run the command @samp{foo}, if the user-defined command +@samp{hookpost-foo} exists, it is executed (with no arguments) after +that command. Post-execution hooks may exist simultaneously with +pre-execution hooks, for the same command. + +It is valid for a hook to call the command which it hooks. If this +occurs, the hook is not re-executed, thereby avoiding infinte recursion. + +@c It would be nice if hookpost could be passed a parameter indicating +@c if the command it hooks executed properly or not. FIXME! + @kindex stop@r{, a pseudo-command} In addition, a pseudo-command, @samp{stop} exists. Defining (@samp{hook-stop}) makes the associated commands execute every time @@ -11889,6 +11907,25 @@ handle SIGLARM pass end @end example +As a further example, to hook at the begining and end of the @code{echo} +command, and to add extra text to the beginning and end of the message, +you could define: + +@example +define hook-echo +echo <<<--- +end + +define hookpost-echo +echo --->>>\n +end + +(@value{GDBP}) echo Hello World +<<<---Hello World--->>> +(@value{GDBP}) + +@end example + You can define a hook for any single-word command in @value{GDBN}, but not for command aliases; you should define a hook for the basic command name, e.g. @code{backtrace} rather than @code{bt}.