You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Auto-Display.html 9.4KB

3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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>Auto Display (Debugging with GDB)</title>
  17. <meta name="description" content="Auto Display (Debugging with GDB)">
  18. <meta name="keywords" content="Auto Display (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="Data.html#Data" rel="up" title="Data">
  26. <link href="Print-Settings.html#Print-Settings" rel="next" title="Print Settings">
  27. <link href="Memory.html#Memory" rel="prev" title="Memory">
  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="Auto-Display"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Print-Settings.html#Print-Settings" accesskey="n" rel="next">Print Settings</a>, Previous: <a href="Memory.html#Memory" accesskey="p" rel="prev">Memory</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</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="Automatic-Display"></a>
  64. <h3 class="section">10.7 Automatic Display</h3>
  65. <a name="index-automatic-display"></a>
  66. <a name="index-display-of-expressions"></a>
  67. <p>If you find that you want to print the value of an expression frequently
  68. (to see how it changes), you might want to add it to the <em>automatic
  69. display list</em> so that <small>GDB</small> prints its value each time your program stops.
  70. Each expression added to the list is given a number to identify it;
  71. to remove an expression from the list, you specify that number.
  72. The automatic display looks like this:
  73. </p>
  74. <div class="smallexample">
  75. <pre class="smallexample">2: foo = 38
  76. 3: bar[5] = (struct hack *) 0x3804
  77. </pre></div>
  78. <p>This display shows item numbers, expressions and their current values. As with
  79. displays you request manually using <code>x</code> or <code>print</code>, you can
  80. specify the output format you prefer; in fact, <code>display</code> decides
  81. whether to use <code>print</code> or <code>x</code> depending your format
  82. specification&mdash;it uses <code>x</code> if you specify either the &lsquo;<samp>i</samp>&rsquo;
  83. or &lsquo;<samp>s</samp>&rsquo; format, or a unit size; otherwise it uses <code>print</code>.
  84. </p>
  85. <dl compact="compact">
  86. <dd><a name="index-display"></a>
  87. </dd>
  88. <dt><code>display <var>expr</var></code></dt>
  89. <dd><p>Add the expression <var>expr</var> to the list of expressions to display
  90. each time your program stops. See <a href="Expressions.html#Expressions">Expressions</a>.
  91. </p>
  92. <p><code>display</code> does not repeat if you press <tt class="key">RET</tt> again after using it.
  93. </p>
  94. </dd>
  95. <dt><code>display/<var>fmt</var> <var>expr</var></code></dt>
  96. <dd><p>For <var>fmt</var> specifying only a display format and not a size or
  97. count, add the expression <var>expr</var> to the auto-display list but
  98. arrange to display it each time in the specified format <var>fmt</var>.
  99. See <a href="Output-Formats.html#Output-Formats">Output Formats</a>.
  100. </p>
  101. </dd>
  102. <dt><code>display/<var>fmt</var> <var>addr</var></code></dt>
  103. <dd><p>For <var>fmt</var> &lsquo;<samp>i</samp>&rsquo; or &lsquo;<samp>s</samp>&rsquo;, or including a unit-size or a
  104. number of units, add the expression <var>addr</var> as a memory address to
  105. be examined each time your program stops. Examining means in effect
  106. doing &lsquo;<samp>x/<var>fmt</var> <var>addr</var></samp>&rsquo;. See <a href="Memory.html#Memory">Examining Memory</a>.
  107. </p></dd>
  108. </dl>
  109. <p>For example, &lsquo;<samp>display/i $pc</samp>&rsquo; can be helpful, to see the machine
  110. instruction about to be executed each time execution stops (&lsquo;<samp>$pc</samp>&rsquo;
  111. is a common name for the program counter; see <a href="Registers.html#Registers">Registers</a>).
  112. </p>
  113. <dl compact="compact">
  114. <dd><a name="index-delete-display"></a>
  115. <a name="index-undisplay"></a>
  116. </dd>
  117. <dt><code>undisplay <var>dnums</var>&hellip;</code></dt>
  118. <dt><code>delete display <var>dnums</var>&hellip;</code></dt>
  119. <dd><p>Remove items from the list of expressions to display. Specify the
  120. numbers of the displays that you want affected with the command
  121. argument <var>dnums</var>. It can be a single display number, one of the
  122. numbers shown in the first field of the &lsquo;<samp>info display</samp>&rsquo; display;
  123. or it could be a range of display numbers, as in <code>2-4</code>.
  124. </p>
  125. <p><code>undisplay</code> does not repeat if you press <tt class="key">RET</tt> after using it.
  126. (Otherwise you would just get the error &lsquo;<samp>No display number &hellip;</samp>&rsquo;.)
  127. </p>
  128. <a name="index-disable-display"></a>
  129. </dd>
  130. <dt><code>disable display <var>dnums</var>&hellip;</code></dt>
  131. <dd><p>Disable the display of item numbers <var>dnums</var>. A disabled display
  132. item is not printed automatically, but is not forgotten. It may be
  133. enabled again later. Specify the numbers of the displays that you
  134. want affected with the command argument <var>dnums</var>. It can be a
  135. single display number, one of the numbers shown in the first field of
  136. the &lsquo;<samp>info display</samp>&rsquo; display; or it could be a range of display
  137. numbers, as in <code>2-4</code>.
  138. </p>
  139. <a name="index-enable-display"></a>
  140. </dd>
  141. <dt><code>enable display <var>dnums</var>&hellip;</code></dt>
  142. <dd><p>Enable display of item numbers <var>dnums</var>. It becomes effective once
  143. again in auto display of its expression, until you specify otherwise.
  144. Specify the numbers of the displays that you want affected with the
  145. command argument <var>dnums</var>. It can be a single display number, one
  146. of the numbers shown in the first field of the &lsquo;<samp>info display</samp>&rsquo;
  147. display; or it could be a range of display numbers, as in <code>2-4</code>.
  148. </p>
  149. </dd>
  150. <dt><code>display</code></dt>
  151. <dd><p>Display the current values of the expressions on the list, just as is
  152. done when your program stops.
  153. </p>
  154. <a name="index-info-display"></a>
  155. </dd>
  156. <dt><code>info display</code></dt>
  157. <dd><p>Print the list of expressions previously set up to display
  158. automatically, each one with its item number, but without showing the
  159. values. This includes disabled expressions, which are marked as such.
  160. It also includes expressions which would not be displayed right now
  161. because they refer to automatic variables not currently available.
  162. </p></dd>
  163. </dl>
  164. <a name="index-display-disabled-out-of-scope"></a>
  165. <p>If a display expression refers to local variables, then it does not make
  166. sense outside the lexical context for which it was set up. Such an
  167. expression is disabled when execution enters a context where one of its
  168. variables is not defined. For example, if you give the command
  169. <code>display last_char</code> while inside a function with an argument
  170. <code>last_char</code>, <small>GDB</small> displays this argument while your program
  171. continues to stop inside that function. When it stops elsewhere&mdash;where
  172. there is no variable <code>last_char</code>&mdash;the display is disabled
  173. automatically. The next time your program stops where <code>last_char</code>
  174. is meaningful, you can enable the display expression once again.
  175. </p>
  176. <hr>
  177. <div class="header">
  178. <p>
  179. Next: <a href="Print-Settings.html#Print-Settings" accesskey="n" rel="next">Print Settings</a>, Previous: <a href="Memory.html#Memory" accesskey="p" rel="prev">Memory</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</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>
  180. </div>
  181. </body>
  182. </html>