You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
10 KiB
HTML
226 lines
10 KiB
HTML
4 years ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- 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." -->
|
||
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<title>Output (Debugging with GDB)</title>
|
||
|
|
||
|
<meta name="description" content="Output (Debugging with GDB)">
|
||
|
<meta name="keywords" content="Output (Debugging with GDB)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content="makeinfo">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<link href="index.html#Top" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Sequences.html#Sequences" rel="up" title="Sequences">
|
||
|
<link href="Auto_002dloading-sequences.html#Auto_002dloading-sequences" rel="next" title="Auto-loading sequences">
|
||
|
<link href="Command-Files.html#Command-Files" rel="prev" title="Command Files">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.indentedblock {margin-right: 0em}
|
||
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
||
|
blockquote.smallquotation {font-size: smaller}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
div.smalldisplay {margin-left: 3.2em}
|
||
|
div.smallexample {margin-left: 3.2em}
|
||
|
div.smalllisp {margin-left: 3.2em}
|
||
|
kbd {font-style: oblique}
|
||
|
pre.display {font-family: inherit}
|
||
|
pre.format {font-family: inherit}
|
||
|
pre.menu-comment {font-family: serif}
|
||
|
pre.menu-preformatted {font-family: serif}
|
||
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
||
|
pre.smallexample {font-size: smaller}
|
||
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
||
|
pre.smalllisp {font-size: smaller}
|
||
|
span.nolinebreak {white-space: nowrap}
|
||
|
span.roman {font-family: initial; font-weight: normal}
|
||
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<a name="Output"></a>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Auto_002dloading-sequences.html#Auto_002dloading-sequences" accesskey="n" rel="next">Auto-loading sequences</a>, Previous: <a href="Command-Files.html#Command-Files" accesskey="p" rel="prev">Command Files</a>, Up: <a href="Sequences.html#Sequences" accesskey="u" rel="up">Sequences</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<a name="Commands-for-Controlled-Output"></a>
|
||
|
<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
|
||
|
<small>GDB</small> 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.
|
||
|
</p>
|
||
|
<dl compact="compact">
|
||
|
<dd><a name="index-echo"></a>
|
||
|
</dd>
|
||
|
<dt><code>echo <var>text</var></code></dt>
|
||
|
<dd><p>Print <var>text</var>. Nonprinting characters can be included in
|
||
|
<var>text</var> using C escape sequences, such as ‘<samp>\n</samp>’ 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 ‘<samp> <!-- /@w -->and foo = <!-- /@w --></samp>’, use the command
|
||
|
‘<samp>echo \ <!-- /@w -->and foo = \ <!-- /@w --></samp>’.
|
||
|
</p>
|
||
|
<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,
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">echo This is some text\n\
|
||
|
which is continued\n\
|
||
|
onto several lines.\n
|
||
|
</pre></div>
|
||
|
|
||
|
<p>produces the same output as
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">echo This is some text\n
|
||
|
echo which is continued\n
|
||
|
echo onto several lines.\n
|
||
|
</pre></div>
|
||
|
|
||
|
<a name="index-output"></a>
|
||
|
</dd>
|
||
|
<dt><code>output <var>expression</var></code></dt>
|
||
|
<dd><p>Print the value of <var>expression</var> and nothing but that value: no
|
||
|
newlines, no ‘<samp>$<var>nn</var> = </samp>’. The value is not entered in the
|
||
|
value history either. See <a href="Expressions.html#Expressions">Expressions</a>, for more information
|
||
|
on expressions.
|
||
|
</p>
|
||
|
</dd>
|
||
|
<dt><code>output/<var>fmt</var> <var>expression</var></code></dt>
|
||
|
<dd><p>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"></a>
|
||
|
</dd>
|
||
|
<dt><code>printf <var>template</var>, <var>expressions</var>…</code></dt>
|
||
|
<dd><p>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:
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">printf (<var>template</var>, <var>expressions</var>…);
|
||
|
</pre></div>
|
||
|
|
||
|
<p>As in <code>C</code> <code>printf</code>, ordinary characters in <var>template</var>
|
||
|
are printed verbatim, while <em>conversion specification</em> introduced
|
||
|
by the ‘<samp>%</samp>’ 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>
|
||
|
<p>For example, you can print two values in hex like this:
|
||
|
</p>
|
||
|
<div class="smallexample">
|
||
|
<pre class="smallexample">printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
|
||
|
</pre></div>
|
||
|
|
||
|
<p><code>printf</code> supports all the standard <code>C</code> conversion
|
||
|
specifications, including the flags and modifiers between the ‘<samp>%</samp>’
|
||
|
character and the conversion letter, with the following exceptions:
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li> The argument-ordering modifiers, such as ‘<samp>2$</samp>’, are not supported.
|
||
|
|
||
|
</li><li> The modifier ‘<samp>*</samp>’ is not supported for specifying precision or
|
||
|
width.
|
||
|
|
||
|
</li><li> The ‘<samp>'</samp>’ flag (for separation of digits into groups according to
|
||
|
<code>LC_NUMERIC'</code>) is not supported.
|
||
|
|
||
|
</li><li> The type modifiers ‘<samp>hh</samp>’, ‘<samp>j</samp>’, ‘<samp>t</samp>’, and ‘<samp>z</samp>’ are not
|
||
|
supported.
|
||
|
|
||
|
</li><li> The conversion letter ‘<samp>n</samp>’ (as in ‘<samp>%n</samp>’) is not supported.
|
||
|
|
||
|
</li><li> The conversion letters ‘<samp>a</samp>’ and ‘<samp>A</samp>’ are not supported.
|
||
|
</li></ul>
|
||
|
|
||
|
<p>Note that the ‘<samp>ll</samp>’ type modifier is supported only if the
|
||
|
underlying <code>C</code> implementation used to build <small>GDB</small> supports
|
||
|
the <code>long long int</code> type, and the ‘<samp>L</samp>’ type modifier is
|
||
|
supported only if <code>long double</code> type is available.
|
||
|
</p>
|
||
|
<p>As in <code>C</code>, <code>printf</code> supports simple backslash-escape
|
||
|
sequences, such as <code>\n</code>, ‘<samp>\t</samp>’, ‘<samp>\\</samp>’, ‘<samp>\"</samp>’,
|
||
|
‘<samp>\a</samp>’, and ‘<samp>\f</samp>’, that consist of backslash followed by a
|
||
|
single character. Octal and hexadecimal escape sequences are not
|
||
|
supported.
|
||
|
</p>
|
||
|
<p>Additionally, <code>printf</code> supports conversion specifications for DFP
|
||
|
(<em>Decimal Floating Point</em>) types using the following length modifiers
|
||
|
together with a floating point specifier.
|
||
|
letters:
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li> ‘<samp>H</samp>’ for printing <code>Decimal32</code> types.
|
||
|
|
||
|
</li><li> ‘<samp>D</samp>’ for printing <code>Decimal64</code> types.
|
||
|
|
||
|
</li><li> ‘<samp>DD</samp>’ for printing <code>Decimal128</code> types.
|
||
|
</li></ul>
|
||
|
|
||
|
<p>If the underlying <code>C</code> implementation used to build <small>GDB</small> has
|
||
|
support for the three length modifiers for DFP types, other modifiers
|
||
|
such as width and precision will also be available for <small>GDB</small> to use.
|
||
|
</p>
|
||
|
<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>
|
||
|
<p>Here’s an example of printing DFP types using the above conversion letters:
|
||
|
</p><div class="smallexample">
|
||
|
<pre class="smallexample">printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
|
||
|
</pre></div>
|
||
|
|
||
|
<a name="eval"></a><a name="index-eval"></a>
|
||
|
</dd>
|
||
|
<dt><code>eval <var>template</var>, <var>expressions</var>…</code></dt>
|
||
|
<dd><p>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.
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Auto_002dloading-sequences.html#Auto_002dloading-sequences" accesskey="n" rel="next">Auto-loading sequences</a>, Previous: <a href="Command-Files.html#Command-Files" accesskey="p" rel="prev">Command Files</a>, Up: <a href="Sequences.html#Sequences" accesskey="u" rel="up">Sequences</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|