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

Display the GDB commands used to define

commandname

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-fooexists, 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.

For example, to ignore SIGALRM signals while single-stepping, and treat them normally during normal execution, you could define:

define hook-stop handle SIGALRM nopass end

define hook-run handle SIGALRM pass

288 Canned Sequences of Commands