Output.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Output</title>
  16. <meta name="description" content="Debugging with GDB: Output">
  17. <meta name="keywords" content="Debugging with GDB: Output">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Sequences.html#Sequences" rel="up" title="Sequences">
  26. <link href="Auto_002dloading-sequences.html#Auto_002dloading-sequences" rel="next" title="Auto-loading sequences">
  27. <link href="Command-Files.html#Command-Files" rel="previous" title="Command Files">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Output"></a>
  59. <div class="header">
  60. <p>
  61. 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="previous">Command Files</a>, Up: <a href="Sequences.html#Sequences" accesskey="u" rel="up">Sequences</a> &nbsp; [<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>
  62. </div>
  63. <hr>
  64. <a name="Commands-for-Controlled-Output"></a>
  65. <h4 class="subsection">23.1.4 Commands for Controlled Output</h4>
  66. <p>During the execution of a command file or a user-defined command, normal
  67. <small>GDB</small> output is suppressed; the only output that appears is what is
  68. explicitly printed by the commands in the definition. This section
  69. describes three commands useful for generating exactly the output you
  70. want.
  71. </p>
  72. <dl compact="compact">
  73. <dd><a name="index-echo"></a>
  74. </dd>
  75. <dt><code>echo <var>text</var></code></dt>
  76. <dd><p>Print <var>text</var>. Nonprinting characters can be included in
  77. <var>text</var> using C escape sequences, such as &lsquo;<samp>\n</samp>&rsquo; to print a
  78. newline. <strong>No newline is printed unless you specify one.</strong>
  79. In addition to the standard C escape sequences, a backslash followed
  80. by a space stands for a space. This is useful for displaying a
  81. string with spaces at the beginning or the end, since leading and
  82. trailing spaces are otherwise trimmed from all arguments.
  83. To print &lsquo;<samp>&nbsp;<!-- /@w -->and foo =&nbsp;<!-- /@w --></samp>&rsquo;, use the command
  84. &lsquo;<samp>echo \&nbsp;<!-- /@w -->and foo = \&nbsp;<!-- /@w --></samp>&rsquo;.
  85. </p>
  86. <p>A backslash at the end of <var>text</var> can be used, as in C, to continue
  87. the command onto subsequent lines. For example,
  88. </p>
  89. <div class="smallexample">
  90. <pre class="smallexample">echo This is some text\n\
  91. which is continued\n\
  92. onto several lines.\n
  93. </pre></div>
  94. <p>produces the same output as
  95. </p>
  96. <div class="smallexample">
  97. <pre class="smallexample">echo This is some text\n
  98. echo which is continued\n
  99. echo onto several lines.\n
  100. </pre></div>
  101. <a name="index-output"></a>
  102. </dd>
  103. <dt><code>output <var>expression</var></code></dt>
  104. <dd><p>Print the value of <var>expression</var> and nothing but that value: no
  105. newlines, no &lsquo;<samp>$<var>nn</var> = </samp>&rsquo;. The value is not entered in the
  106. value history either. See <a href="Expressions.html#Expressions">Expressions</a>, for more information
  107. on expressions.
  108. </p>
  109. </dd>
  110. <dt><code>output/<var>fmt</var> <var>expression</var></code></dt>
  111. <dd><p>Print the value of <var>expression</var> in format <var>fmt</var>. You can use
  112. the same formats as for <code>print</code>. See <a href="Output-Formats.html#Output-Formats">Output
  113. Formats</a>, for more information.
  114. </p>
  115. <a name="index-printf"></a>
  116. </dd>
  117. <dt><code>printf <var>template</var>, <var>expressions</var>&hellip;</code></dt>
  118. <dd><p>Print the values of one or more <var>expressions</var> under the control of
  119. the string <var>template</var>. To print several values, make
  120. <var>expressions</var> be a comma-separated list of individual expressions,
  121. which may be either numbers or pointers. Their values are printed as
  122. specified by <var>template</var>, exactly as a C program would do by
  123. executing the code below:
  124. </p>
  125. <div class="smallexample">
  126. <pre class="smallexample">printf (<var>template</var>, <var>expressions</var>&hellip;);
  127. </pre></div>
  128. <p>As in <code>C</code> <code>printf</code>, ordinary characters in <var>template</var>
  129. are printed verbatim, while <em>conversion specification</em> introduced
  130. by the &lsquo;<samp>%</samp>&rsquo; character cause subsequent <var>expressions</var> to be
  131. evaluated, their values converted and formatted according to type and
  132. style information encoded in the conversion specifications, and then
  133. printed.
  134. </p>
  135. <p>For example, you can print two values in hex like this:
  136. </p>
  137. <div class="smallexample">
  138. <pre class="smallexample">printf &quot;foo, bar-foo = 0x%x, 0x%x\n&quot;, foo, bar-foo
  139. </pre></div>
  140. <p><code>printf</code> supports all the standard <code>C</code> conversion
  141. specifications, including the flags and modifiers between the &lsquo;<samp>%</samp>&rsquo;
  142. character and the conversion letter, with the following exceptions:
  143. </p>
  144. <ul>
  145. <li> The argument-ordering modifiers, such as &lsquo;<samp>2$</samp>&rsquo;, are not supported.
  146. </li><li> The modifier &lsquo;<samp>*</samp>&rsquo; is not supported for specifying precision or
  147. width.
  148. </li><li> The &lsquo;<samp>'</samp>&rsquo; flag (for separation of digits into groups according to
  149. <code>LC_NUMERIC'</code>) is not supported.
  150. </li><li> The type modifiers &lsquo;<samp>hh</samp>&rsquo;, &lsquo;<samp>j</samp>&rsquo;, &lsquo;<samp>t</samp>&rsquo;, and &lsquo;<samp>z</samp>&rsquo; are not
  151. supported.
  152. </li><li> The conversion letter &lsquo;<samp>n</samp>&rsquo; (as in &lsquo;<samp>%n</samp>&rsquo;) is not supported.
  153. </li><li> The conversion letters &lsquo;<samp>a</samp>&rsquo; and &lsquo;<samp>A</samp>&rsquo; are not supported.
  154. </li></ul>
  155. <p>Note that the &lsquo;<samp>ll</samp>&rsquo; type modifier is supported only if the
  156. underlying <code>C</code> implementation used to build <small>GDB</small> supports
  157. the <code>long long int</code> type, and the &lsquo;<samp>L</samp>&rsquo; type modifier is
  158. supported only if <code>long double</code> type is available.
  159. </p>
  160. <p>As in <code>C</code>, <code>printf</code> supports simple backslash-escape
  161. sequences, such as <code>\n</code>, &lsquo;<samp>\t</samp>&rsquo;, &lsquo;<samp>\\</samp>&rsquo;, &lsquo;<samp>\&quot;</samp>&rsquo;,
  162. &lsquo;<samp>\a</samp>&rsquo;, and &lsquo;<samp>\f</samp>&rsquo;, that consist of backslash followed by a
  163. single character. Octal and hexadecimal escape sequences are not
  164. supported.
  165. </p>
  166. <p>Additionally, <code>printf</code> supports conversion specifications for DFP
  167. (<em>Decimal Floating Point</em>) types using the following length modifiers
  168. together with a floating point specifier.
  169. letters:
  170. </p>
  171. <ul>
  172. <li> &lsquo;<samp>H</samp>&rsquo; for printing <code>Decimal32</code> types.
  173. </li><li> &lsquo;<samp>D</samp>&rsquo; for printing <code>Decimal64</code> types.
  174. </li><li> &lsquo;<samp>DD</samp>&rsquo; for printing <code>Decimal128</code> types.
  175. </li></ul>
  176. <p>If the underlying <code>C</code> implementation used to build <small>GDB</small> has
  177. support for the three length modifiers for DFP types, other modifiers
  178. such as width and precision will also be available for <small>GDB</small> to use.
  179. </p>
  180. <p>In case there is no such <code>C</code> support, no additional modifiers will be
  181. available and the value will be printed in the standard way.
  182. </p>
  183. <p>Here&rsquo;s an example of printing DFP types using the above conversion letters:
  184. </p><div class="smallexample">
  185. <pre class="smallexample">printf &quot;D32: %Hf - D64: %Df - D128: %DDf\n&quot;,1.2345df,1.2E10dd,1.2E1dl
  186. </pre></div>
  187. <a name="eval"></a><a name="index-eval"></a>
  188. </dd>
  189. <dt><code>eval <var>template</var>, <var>expressions</var>&hellip;</code></dt>
  190. <dd><p>Convert the values of one or more <var>expressions</var> under the control of
  191. the string <var>template</var> to a command line, and call it.
  192. </p>
  193. </dd>
  194. </dl>
  195. <hr>
  196. <div class="header">
  197. <p>
  198. 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="previous">Command Files</a>, Up: <a href="Sequences.html#Sequences" accesskey="u" rel="up">Sequences</a> &nbsp; [<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>
  199. </div>
  200. </body>
  201. </html>