* gdb.texinfo (Hooks): Document the new post-hook functionality.
From Steven Johnson <sbjohnson@ozemail.com.au>.
This commit is contained in:
parent
81d4177baa
commit
c78b412857
2 changed files with 43 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2000-09-26 Eli Zaretskii <eliz@is.elta.co.il>
|
||||||
|
|
||||||
|
* gdb.texinfo (Hooks): Document the new post-hook functionality.
|
||||||
|
From Steven Johnson <sbjohnson@ozemail.com.au>.
|
||||||
|
|
||||||
2000-08-10 Mark Kettenis <kettenis@gnu.org>
|
2000-08-10 Mark Kettenis <kettenis@gnu.org>
|
||||||
|
|
||||||
* gdbint.texinfo (Overall Structure): Spelling fix.
|
* gdbint.texinfo (Overall Structure): Spelling fix.
|
||||||
|
|
|
@ -11859,12 +11859,30 @@ messages when used in a user-defined command.
|
||||||
@section User-defined command hooks
|
@section User-defined command hooks
|
||||||
@cindex command hooks
|
@cindex command hooks
|
||||||
@cindex hooks, for commands
|
@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. Whenever you run the command @samp{foo}, if the user-defined
|
||||||
command @samp{hook-foo} exists, it is executed (with no arguments)
|
command @samp{hook-foo} exists, it is executed (with no arguments)
|
||||||
before that command.
|
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}
|
@kindex stop@r{, a pseudo-command}
|
||||||
In addition, a pseudo-command, @samp{stop} exists. Defining
|
In addition, a pseudo-command, @samp{stop} exists. Defining
|
||||||
(@samp{hook-stop}) makes the associated commands execute every time
|
(@samp{hook-stop}) makes the associated commands execute every time
|
||||||
|
@ -11889,6 +11907,25 @@ handle SIGLARM pass
|
||||||
end
|
end
|
||||||
@end example
|
@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
|
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
|
not for command aliases; you should define a hook for the basic command
|
||||||
name, e.g. @code{backtrace} rather than @code{bt}.
|
name, e.g. @code{backtrace} rather than @code{bt}.
|
||||||
|
|
Loading…
Add table
Reference in a new issue