Chapter 5.
gdb Commands
You can abbreviate a gdb command to the first few letters of the command name, if that abbreviation
is unambiguous; and you can repeat certain gdb commands by typing just [RET]. You can also use
the [TAB] key to get gdb to fill out the rest of a word in a command (or to show you the alternatives
available, if there is more than one possibility).
5.1. Command syntax
A gdb command is a single line of input. There is no limit on how long it can be. It starts with a
command name, which is followed by arguments whose meaning depends on the command name.
For example, the command
step
accepts an argument which is the number of times to step, as in
step 5
. You can also use the
step
command with no arguments. Some commands do not allow any
arguments.
gdb command names may always be truncated if that abbreviation is unambiguous. Other possible
command abbreviations are listed in the documentation for individual commands. In some cases,
even ambiguous abbreviations are allowed; for example,
s
is specially defined as equivalent to
step
even though there are other commands whose names start with
s
. You can test abbreviations by using
them as arguments to the
help
command.
A blank line as input to gdb (typing just [RET]) means to repeat the previous command. Certain
commands (for example,
run
) will not repeat this way; these are commands whose unintentional
repetition might cause trouble and which you are unlikely to want to repeat.
The
list
and
x
commands, when you repeat them with [RET], construct new arguments rather than
repeating exactly as typed. This permits easy scanning of source or memory.
gdb can also use [RET] in another way: to partition lengthy output, in a way similar to the common
utility
more
(refer to Section 21.4
Screen size
). Since it is easy to press one [RET] too many in this
situation, gdb disables command repetition after any command that generates this sort of display.
Any text from a
#
to the end of the line is a comment; it does nothing. This is useful mainly in
command files (refer to Section 22.3
Command files
).
The
C-o
binding is useful for repeating a complex sequence of commands. This command accepts
the current line, like
RET
, and then fetches the next line relative to the current line from the history
for editing.
5.2. Command completion
gdb can fill in the rest of a word in a command for you, if there is only one possibility; it can also
show you what the valid possibilities are for the next word in a command, at any time. This works for
gdb commands, gdb subcommands, and the names of symbols in your program.
Press the [TAB] key whenever you want gdb to fill out the rest of a word. If there is only one possibility,
gdb fills in the word, and waits for you to finish the command (or press [RET] to enter it). For example,
if you type
(gdb) info bre [TAB]
gdb fills in the rest of the word
breakpoints
, since that is the only
info
subcommand beginning
with
bre
:
Содержание ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Страница 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Страница 12: ...2 Chapter 1 Debugging with gdb ...
Страница 28: ...18 Chapter 4 Getting In and Out of gdb ...
Страница 34: ...24 Chapter 5 gdb Commands ...
Страница 44: ...34 Chapter 6 Running Programs Under gdb ...
Страница 68: ...58 Chapter 8 Examining the Stack ...
Страница 98: ...88 Chapter 10 Examining Data ...
Страница 112: ...102 Chapter 12 Tracepoints ...
Страница 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Страница 138: ...128 Chapter 14 Using gdb with Different Languages ...
Страница 144: ...134 Chapter 15 Examining the Symbol Table ...
Страница 170: ...160 Chapter 19 Debugging remote programs ...
Страница 198: ...188 Chapter 21 Controlling gdb ...
Страница 204: ...194 Chapter 22 Canned Sequences of Commands ...
Страница 206: ...196 Chapter 23 Command Interpreters ...
Страница 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Страница 296: ...286 Chapter 27 gdb Annotations ...
Страница 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Страница 322: ...312 Chapter 30 Using History Interactively ...
Страница 362: ...352 Appendix D gdb Remote Serial Protocol ...
Страница 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Страница 386: ...376 Appendix G GNU Free Documentation License ...
Страница 410: ......