aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2000-09-26 15:53:59 +0000
committerEli Zaretskii <eliz@gnu.org>2000-09-26 15:53:59 +0000
commitc78b4128575c657ab87e3170fdd2d63b09a3072f (patch)
tree2720497c16a2263b4b07a85d819527696f7b8ca8 /gdb
parent81d4177baa5f2bd91109912b42bd2d8b28ad5df8 (diff)
downloadgdb-c78b4128575c657ab87e3170fdd2d63b09a3072f.zip
gdb-c78b4128575c657ab87e3170fdd2d63b09a3072f.tar.gz
gdb-c78b4128575c657ab87e3170fdd2d63b09a3072f.tar.bz2
* gdb.texinfo (Hooks): Document the new post-hook functionality.
From Steven Johnson <sbjohnson@ozemail.com.au>.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdb.texinfo39
2 files changed, 43 insertions, 1 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index fd9566b..1dc783e 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -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>
* gdbint.texinfo (Overall Structure): Spelling fix.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 1f4e95e..2aee191 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}.