| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1988-2015 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 5.2, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <title>Debugging with GDB: Auto Display</title> |
| |
| <meta name="description" content="Debugging with GDB: Auto Display"> |
| <meta name="keywords" content="Debugging with GDB: Auto Display"> |
| <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="Data.html#Data" rel="up" title="Data"> |
| <link href="Print-Settings.html#Print-Settings" rel="next" title="Print Settings"> |
| <link href="Memory.html#Memory" rel="prev" title="Memory"> |
| <style type="text/css"> |
| <!-- |
| a.summary-letter {text-decoration: none} |
| blockquote.smallquotation {font-size: smaller} |
| div.display {margin-left: 3.2em} |
| div.example {margin-left: 3.2em} |
| div.indentedblock {margin-left: 3.2em} |
| div.lisp {margin-left: 3.2em} |
| div.smalldisplay {margin-left: 3.2em} |
| div.smallexample {margin-left: 3.2em} |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| 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.nocodebreak {white-space:nowrap} |
| span.nolinebreak {white-space:nowrap} |
| span.roman {font-family:serif; font-weight:normal} |
| span.sansserif {font-family:sans-serif; font-weight:normal} |
| ul.no-bullet {list-style: none} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> |
| <a name="Auto-Display"></a> |
| <div class="header"> |
| <p> |
| 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> [<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="Automatic-Display"></a> |
| <h3 class="section">10.7 Automatic Display</h3> |
| <a name="index-automatic-display"></a> |
| <a name="index-display-of-expressions"></a> |
| |
| <p>If you find that you want to print the value of an expression frequently |
| (to see how it changes), you might want to add it to the <em>automatic |
| display list</em> so that <small>GDB</small> prints its value each time your program stops. |
| Each expression added to the list is given a number to identify it; |
| to remove an expression from the list, you specify that number. |
| The automatic display looks like this: |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">2: foo = 38 |
| 3: bar[5] = (struct hack *) 0x3804 |
| </pre></div> |
| |
| <p>This display shows item numbers, expressions and their current values. As with |
| displays you request manually using <code>x</code> or <code>print</code>, you can |
| specify the output format you prefer; in fact, <code>display</code> decides |
| whether to use <code>print</code> or <code>x</code> depending your format |
| specification—it uses <code>x</code> if you specify either the ‘<samp>i</samp>’ |
| or ‘<samp>s</samp>’ format, or a unit size; otherwise it uses <code>print</code>. |
| </p> |
| <dl compact="compact"> |
| <dd><a name="index-display"></a> |
| </dd> |
| <dt><code>display <var>expr</var></code></dt> |
| <dd><p>Add the expression <var>expr</var> to the list of expressions to display |
| each time your program stops. See <a href="Expressions.html#Expressions">Expressions</a>. |
| </p> |
| <p><code>display</code> does not repeat if you press <tt class="key">RET</tt> again after using it. |
| </p> |
| </dd> |
| <dt><code>display/<var>fmt</var> <var>expr</var></code></dt> |
| <dd><p>For <var>fmt</var> specifying only a display format and not a size or |
| count, add the expression <var>expr</var> to the auto-display list but |
| arrange to display it each time in the specified format <var>fmt</var>. |
| See <a href="Output-Formats.html#Output-Formats">Output Formats</a>. |
| </p> |
| </dd> |
| <dt><code>display/<var>fmt</var> <var>addr</var></code></dt> |
| <dd><p>For <var>fmt</var> ‘<samp>i</samp>’ or ‘<samp>s</samp>’, or including a unit-size or a |
| number of units, add the expression <var>addr</var> as a memory address to |
| be examined each time your program stops. Examining means in effect |
| doing ‘<samp>x/<var>fmt</var> <var>addr</var></samp>’. See <a href="Memory.html#Memory">Examining Memory</a>. |
| </p></dd> |
| </dl> |
| |
| <p>For example, ‘<samp>display/i $pc</samp>’ can be helpful, to see the machine |
| instruction about to be executed each time execution stops (‘<samp>$pc</samp>’ |
| is a common name for the program counter; see <a href="Registers.html#Registers">Registers</a>). |
| </p> |
| <dl compact="compact"> |
| <dd><a name="index-delete-display"></a> |
| <a name="index-undisplay"></a> |
| </dd> |
| <dt><code>undisplay <var>dnums</var>…</code></dt> |
| <dt><code>delete display <var>dnums</var>…</code></dt> |
| <dd><p>Remove items from the list of expressions to display. Specify the |
| numbers of the displays that you want affected with the command |
| argument <var>dnums</var>. It can be a single display number, one of the |
| numbers shown in the first field of the ‘<samp>info display</samp>’ display; |
| or it could be a range of display numbers, as in <code>2-4</code>. |
| </p> |
| <p><code>undisplay</code> does not repeat if you press <tt class="key">RET</tt> after using it. |
| (Otherwise you would just get the error ‘<samp>No display number …</samp>’.) |
| </p> |
| <a name="index-disable-display"></a> |
| </dd> |
| <dt><code>disable display <var>dnums</var>…</code></dt> |
| <dd><p>Disable the display of item numbers <var>dnums</var>. A disabled display |
| item is not printed automatically, but is not forgotten. It may be |
| enabled again later. Specify the numbers of the displays that you |
| want affected with the command argument <var>dnums</var>. It can be a |
| single display number, one of the numbers shown in the first field of |
| the ‘<samp>info display</samp>’ display; or it could be a range of display |
| numbers, as in <code>2-4</code>. |
| </p> |
| <a name="index-enable-display"></a> |
| </dd> |
| <dt><code>enable display <var>dnums</var>…</code></dt> |
| <dd><p>Enable display of item numbers <var>dnums</var>. It becomes effective once |
| again in auto display of its expression, until you specify otherwise. |
| Specify the numbers of the displays that you want affected with the |
| command argument <var>dnums</var>. It can be a single display number, one |
| of the numbers shown in the first field of the ‘<samp>info display</samp>’ |
| display; or it could be a range of display numbers, as in <code>2-4</code>. |
| </p> |
| </dd> |
| <dt><code>display</code></dt> |
| <dd><p>Display the current values of the expressions on the list, just as is |
| done when your program stops. |
| </p> |
| <a name="index-info-display"></a> |
| </dd> |
| <dt><code>info display</code></dt> |
| <dd><p>Print the list of expressions previously set up to display |
| automatically, each one with its item number, but without showing the |
| values. This includes disabled expressions, which are marked as such. |
| It also includes expressions which would not be displayed right now |
| because they refer to automatic variables not currently available. |
| </p></dd> |
| </dl> |
| |
| <a name="index-display-disabled-out-of-scope"></a> |
| <p>If a display expression refers to local variables, then it does not make |
| sense outside the lexical context for which it was set up. Such an |
| expression is disabled when execution enters a context where one of its |
| variables is not defined. For example, if you give the command |
| <code>display last_char</code> while inside a function with an argument |
| <code>last_char</code>, <small>GDB</small> displays this argument while your program |
| continues to stop inside that function. When it stops elsewhere—where |
| there is no variable <code>last_char</code>—the display is disabled |
| automatically. The next time your program stops where <code>last_char</code> |
| is meaningful, you can enable the display expression once again. |
| </p> |
| <hr> |
| <div class="header"> |
| <p> |
| 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> [<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> |