toolchain/share/doc/gdb/Output.html

174 lines
9.5 KiB
HTML
Raw Permalink Normal View History

2024-01-10 05:24:32 +00:00
<html lang="en">
<head>
<title>Output - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Sequences.html#Sequences" title="Sequences">
<link rel="prev" href="Command-Files.html#Command-Files" title="Command Files">
<link rel="next" href="Auto_002dloading-sequences.html#Auto_002dloading-sequences" title="Auto-loading sequences">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Output"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Auto_002dloading-sequences.html#Auto_002dloading-sequences">Auto-loading sequences</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Command-Files.html#Command-Files">Command Files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Sequences.html#Sequences">Sequences</a>
<hr>
</div>
<h4 class="subsection">23.1.4 Commands for Controlled Output</h4>
<p>During the execution of a command file or a user-defined command, normal
<span class="sc">gdb</span> 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.
<a name="index-echo-1827"></a>
<dl><dt><code>echo </code><var>text</var><dd><!-- I do not consider backslash-space a standard C escape sequence -->
<!-- because it is not in ANSI. -->
Print <var>text</var>. Nonprinting characters can be included in
<var>text</var> using C escape sequences, such as &lsquo;<samp><span class="samp">\n</span></samp>&rsquo; to print a
newline. <strong>No newline is printed unless you specify one.</strong>
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 &lsquo;<samp><span class="samp">&nbsp;<!-- /@w -->and foo =&nbsp;<!-- /@w --></span></samp>&rsquo;, use the command
&lsquo;<samp><span class="samp">echo \&nbsp;<!-- /@w -->and foo = \&nbsp;<!-- /@w --></span></samp>&rsquo;.
<p>A backslash at the end of <var>text</var> can be used, as in C, to continue
the command onto subsequent lines. For example,
<pre class="smallexample"> echo This is some text\n\
which is continued\n\
onto several lines.\n
</pre>
<p>produces the same output as
<pre class="smallexample"> echo This is some text\n
echo which is continued\n
echo onto several lines.\n
</pre>
<p><a name="index-output-1828"></a><br><dt><code>output </code><var>expression</var><dd>Print the value of <var>expression</var> and nothing but that value: no
newlines, no &lsquo;<samp><span class="samp">$</span><var>nn</var><span class="samp"> = </span></samp>&rsquo;. The value is not entered in the
value history either. See <a href="Expressions.html#Expressions">Expressions</a>, for more information
on expressions.
<br><dt><code>output/</code><var>fmt</var> <var>expression</var><dd>Print the value of <var>expression</var> in format <var>fmt</var>. You can use
the same formats as for <code>print</code>. See <a href="Output-Formats.html#Output-Formats">Output Formats</a>, for more information.
<p><a name="index-printf-1829"></a><br><dt><code>printf </code><var>template</var><code>, </code><var>expressions</var><code>...</code><dd>Print the values of one or more <var>expressions</var> under the control of
the string <var>template</var>. To print several values, make
<var>expressions</var> be a comma-separated list of individual expressions,
which may be either numbers or pointers. Their values are printed as
specified by <var>template</var>, exactly as a C program would do by
executing the code below:
<pre class="smallexample"> printf (<var>template</var>, <var>expressions</var>...);
</pre>
<p>As in <code>C</code> <code>printf</code>, ordinary characters in <var>template</var>
are printed verbatim, while <dfn>conversion specification</dfn> introduced
by the &lsquo;<samp><span class="samp">%</span></samp>&rsquo; character cause subsequent <var>expressions</var> to be
evaluated, their values converted and formatted according to type and
style information encoded in the conversion specifications, and then
printed.
<p>For example, you can print two values in hex like this:
<pre class="smallexample"> printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
</pre>
<p><code>printf</code> supports all the standard <code>C</code> conversion
specifications, including the flags and modifiers between the &lsquo;<samp><span class="samp">%</span></samp>&rsquo;
character and the conversion letter, with the following exceptions:
<ul>
<li>The argument-ordering modifiers, such as &lsquo;<samp><span class="samp">2$</span></samp>&rsquo;, are not supported.
<li>The modifier &lsquo;<samp><span class="samp">*</span></samp>&rsquo; is not supported for specifying precision or
width.
<li>The &lsquo;<samp><span class="samp">'</span></samp>&rsquo; flag (for separation of digits into groups according to
<code>LC_NUMERIC'</code>) is not supported.
<li>The type modifiers &lsquo;<samp><span class="samp">hh</span></samp>&rsquo;, &lsquo;<samp><span class="samp">j</span></samp>&rsquo;, &lsquo;<samp><span class="samp">t</span></samp>&rsquo;, and &lsquo;<samp><span class="samp">z</span></samp>&rsquo; are not
supported.
<li>The conversion letter &lsquo;<samp><span class="samp">n</span></samp>&rsquo; (as in &lsquo;<samp><span class="samp">%n</span></samp>&rsquo;) is not supported.
<li>The conversion letters &lsquo;<samp><span class="samp">a</span></samp>&rsquo; and &lsquo;<samp><span class="samp">A</span></samp>&rsquo; are not supported.
</ul>
<p class="noindent">Note that the &lsquo;<samp><span class="samp">ll</span></samp>&rsquo; type modifier is supported only if the
underlying <code>C</code> implementation used to build <span class="sc">gdb</span> supports
the <code>long long int</code> type, and the &lsquo;<samp><span class="samp">L</span></samp>&rsquo; type modifier is
supported only if <code>long double</code> type is available.
<p>As in <code>C</code>, <code>printf</code> supports simple backslash-escape
sequences, such as <code>\n</code>, &lsquo;<samp><span class="samp">\t</span></samp>&rsquo;, &lsquo;<samp><span class="samp">\\</span></samp>&rsquo;, &lsquo;<samp><span class="samp">\"</span></samp>&rsquo;,
&lsquo;<samp><span class="samp">\a</span></samp>&rsquo;, and &lsquo;<samp><span class="samp">\f</span></samp>&rsquo;, that consist of backslash followed by a
single character. Octal and hexadecimal escape sequences are not
supported.
<p>Additionally, <code>printf</code> supports conversion specifications for DFP
(<dfn>Decimal Floating Point</dfn>) types using the following length modifiers
together with a floating point specifier.
letters:
<ul>
<li>&lsquo;<samp><span class="samp">H</span></samp>&rsquo; for printing <code>Decimal32</code> types.
<li>&lsquo;<samp><span class="samp">D</span></samp>&rsquo; for printing <code>Decimal64</code> types.
<li>&lsquo;<samp><span class="samp">DD</span></samp>&rsquo; for printing <code>Decimal128</code> types.
</ul>
<p>If the underlying <code>C</code> implementation used to build <span class="sc">gdb</span> has
support for the three length modifiers for DFP types, other modifiers
such as width and precision will also be available for <span class="sc">gdb</span> to use.
<p>In case there is no such <code>C</code> support, no additional modifiers will be
available and the value will be printed in the standard way.
<p>Here's an example of printing DFP types using the above conversion letters:
<pre class="smallexample"> printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
</pre>
<p><a name="eval"></a><a name="index-eval-1830"></a><br><dt><code>eval </code><var>template</var><code>, </code><var>expressions</var><code>...</code><dd>Convert the values of one or more <var>expressions</var> under the control of
the string <var>template</var> to a command line, and call it.
</dl>
</body></html>