3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Output">Output
</a>,
13 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Command-Files.html#Command%20Files">Command Files
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"Sequences.html#Sequences">Sequences
</a>
18 <h3 class=
"section">Commands for controlled output
</h3>
20 <p>During the execution of a command file or a user-defined command, normal
21 GDB output is suppressed; the only output that appears is what is
22 explicitly printed by the commands in the definition. This section
23 describes three commands useful for generating exactly the output you
27 <dt><code>echo
</code><var>text
</var><code></code>
28 <dd>Print
<var>text
</var>. Nonprinting characters can be included in
29 <var>text
</var> using C escape sequences, such as
<code>\n
</code> to print a
30 newline.
<strong>No newline is printed unless you specify one.
</strong>
31 In addition to the standard C escape sequences, a backslash followed
32 by a space stands for a space. This is useful for displaying a
33 string with spaces at the beginning or the end, since leading and
34 trailing spaces are otherwise trimmed from all arguments.
35 To print
<code> and foo =
</code>, use the command
36 <code>echo \
and foo = \
</code>.
38 <p>A backslash at the end of
<var>text
</var> can be used, as in C, to continue
39 the command onto subsequent lines. For example,
41 <pre class=
"example"> echo This is some text\n\
46 <p>produces the same output as
48 <pre class=
"example"> echo This is some text\n
49 echo which is continued\n
50 echo onto several lines.\n
53 <br><dt><code>output
</code><var>expression
</var><code></code>
54 <dd>Print the value of
<var>expression
</var> and nothing but that value: no
55 newlines, no
<code>$
</code><var>nn
</var><code> =
</code>. The value is not entered in the
56 value history either. See
<a href=
"Expressions.html#Expressions">Expressions
</a>, for more information
59 <br><dt><code>output/
</code><var>fmt
</var><code> </code><var>expression
</var><code></code>
60 <dd>Print the value of
<var>expression
</var> in format
<var>fmt
</var>. You can use
61 the same formats as for
<code>print
</code>. See
<a href=
"Output-Formats.html#Output%20Formats">Output formats
</a>, for more information.
63 <br><dt><code>printf
</code><var>string
</var><code>,
</code><var>expressions
</var><code>...
</code>
64 <dd>Print the values of the
<var>expressions
</var> under the control of
65 <var>string
</var>. The
<var>expressions
</var> are separated by commas and may be
66 either numbers or pointers. Their values are printed as specified by
67 <var>string
</var>, exactly as if your program were to execute the C
70 <pre class=
"example"> printf (
<var>string
</var>,
<var>expressions
</var>...);
73 <p>For example, you can print two values in hex like this:
75 <pre class=
"smallexample"> printf
"foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
78 <p>The only backslash-escape sequences that you can use in the format
79 string are the simple ones that consist of backslash followed by a