Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
while The syntax is similar to if: the command takes
a single argument, which is an expression to
evaluate, and must be followed by the commands
to execute, one per line, terminated by an end.
The commands are executed repeatedly as long
as the expression evaluates to true.
document commandname Document the user-defined command
commandname, so that it can be accessed by
help. The command commandname must already
be defined. This command reads lines of
documentation just as define reads the lines of the
command definition, ending with end. After the
document command is finished, help on command
commandname displays the documentation you
have written.
You may use the document command again to
change the documentation of a command.
Redefining the command with define does not
change the documentation.
help user-defined List all user-defined commands, with the first line
of the documentation (if any) for each.
show user, show user commandname Display the GDB commands used to define
commandname (but not its documentation). If no
commandname is given, display the definitions
for all user- defined commands.
When user-defined commands are executed, the commands of the definition are not
printed. An error in any command stops execution of the user-defined command.
If used interactively, commands that would ask for confirmation proceed without asking
when used inside a user-defined command. Many GDB commands that normally print
messages to say what they are doing omit the messages when used in a user-defined
command.
18.2 User-defined command hooks
You may define hooks, which are a special kind of user-defined command. Whenever
you run the command foo, if the user-defined command hook-foo exists, it is executed
(with no arguments) before that command.
In addition, a pseudo-command, stop exists. Defining (hook-stop) makes the associated
commands execute every time execution stops in your program: before breakpoint
commands are run, displays are printed, or the stack frame is printed.
290 Canned Sequences of Commands