summaryrefslogtreecommitdiff
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
commit9e854ff02439a84420db4d2a885e12989d96a601 (patch)
tree10ff44f1d224cf1f56c132a8df91e58eeba46e00
parentf9168e874fb7fb0911518a492ccc02eb799f2123 (diff)
downloadgdb-9e854ff02439a84420db4d2a885e12989d96a601.tar.gz
* gdb.texinfo (Hooks): Document the new post-hook functionality.
From Steven Johnson <sbjohnson@ozemail.com.au>.
-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 fd9566b1b91..1dc783e5eb6 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 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}.