192
Chapter 22. Canned Sequences of Commands
On some configurations of gdb, the init file is known by a different name (these are typically environ-
ments where a specialized form of gdb may need to coexist with other forms, hence a different name
for the specialized version’s init file). These are the environments with special init file names:
•
VxWorks (Wind River Systems real-time OS):
.vxgdbinit
•
OS68K (Enea Data Systems real-time OS):
.os68gdbinit
•
ES-1800 (Ericsson Telecom AB M68000 emulator):
.esgdbinit
You can also request the execution of a command file with the
source
command:
source
filename
Execute the command file
filename
.
The lines in a command file are executed sequentially. They are not printed as they are executed. An
error in any command terminates execution of the command file and control is returned to the console.
Commands that would ask for confirmation if used interactively proceed without asking when used in
a command file. Many gdb commands that normally print messages to say what they are doing omit
the messages when called from command files.
gdb also accepts command input from standard input. In this mode, normal output goes to standard
output and error output goes to standard error. Errors in a command file supplied on standard input do
not terminate execution of the command file -- execution continues with the next command.
gdb
O
cmds
P
log 2
P
&1
(The syntax above will vary depending on the shell used.) This example will execute commands from
the file
cmds
. All output and errors would be directed to
log
.
22.4. Commands for controlled output
During the execution of a command file or a user-defined command, normal gdb output is suppressed;
the only output that appears is what is explicitly printed by the commands in the definition. This
section describes three commands useful for generating exactly the output you want.
echo
text
text
. Nonprinting characters can be included in
text
using C escape sequences, such as
\n
to print a newline.
No newline is printed unless you specify one.
In addition to the standard C
escape sequences, a backslash followed by a space stands for a space. This is useful for displaying
a string with spaces at the beginning or the end, since leading and trailing spaces are otherwise
trimmed from all arguments. To print
and foo =
, use the command
echo \ and foo = \
.
A backslash at the end of
text
can be used, as in C, to continue the command onto subsequent
lines. For example,
echo This is some text\n\
which is continued\n\
onto several lines.\n
produces the same output as
Содержание 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: ......