190
Chapter 22. Canned Sequences of Commands
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. Re-
defining 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.
show max-user-call-depth
set max-user-call-depth
The value of
max-user-call-depth
controls how many recursion levels are allowed in user-
defined commands before GDB suspects an infinite recursion and aborts the command.
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.
22.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.
A hook may also be defined which is run after the command you executed. Whenever you run the
command
foo
, if the user-defined command
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.
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, but treat them normally during normal
execution, you could define:
define hook-stop
handle SIGALRM nopass
end
define hook-run
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......