Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

226 linhas
10KB

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