toolchain/share/doc/gdb/Value-History.html

112 lines
5.5 KiB
HTML
Raw Normal View History

2024-01-10 05:24:32 +00:00
<html lang="en">
<head>
<title>Value History - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Data.html#Data" title="Data">
<link rel="prev" href="Pretty-Printing.html#Pretty-Printing" title="Pretty Printing">
<link rel="next" href="Convenience-Vars.html#Convenience-Vars" title="Convenience Vars">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Value-History"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Convenience-Vars.html#Convenience-Vars">Convenience Vars</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Pretty-Printing.html#Pretty-Printing">Pretty Printing</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Data.html#Data">Data</a>
<hr>
</div>
<h3 class="section">10.10 Value History</h3>
<p><a name="index-value-history-717"></a><a name="index-history-of-values-printed-by-_0040value_007bGDBN_007d-718"></a>Values printed by the <code>print</code> command are saved in the <span class="sc">gdb</span>
<dfn>value history</dfn>. This allows you to refer to them in other expressions.
Values are kept until the symbol table is re-read or discarded
(for example with the <code>file</code> or <code>symbol-file</code> commands).
When the symbol table changes, the value history is discarded,
since the values may contain pointers back to the types defined in the
symbol table.
<p><a name="index-g_t_0040code_007b_0024_007d-719"></a><a name="index-g_t_0040code_007b_0024_0024_007d-720"></a><a name="index-history-number-721"></a>The values printed are given <dfn>history numbers</dfn> by which you can
refer to them. These are successive integers starting with one.
<code>print</code> shows you the history number assigned to a value by
printing &lsquo;<samp><span class="samp">$</span><var>num</var><span class="samp"> = </span></samp>&rsquo; before the value; here <var>num</var> is the
history number.
<p>To refer to any previous value, use &lsquo;<samp><span class="samp">$</span></samp>&rsquo; followed by the value's
history number. The way <code>print</code> labels its output is designed to
remind you of this. Just <code>$</code> refers to the most recent value in
the history, and <code>$$</code> refers to the value before that.
<code>$$</code><var>n</var> refers to the <var>n</var>th value from the end; <code>$$2</code>
is the value just prior to <code>$$</code>, <code>$$1</code> is equivalent to
<code>$$</code>, and <code>$$0</code> is equivalent to <code>$</code>.
<p>For example, suppose you have just printed a pointer to a structure and
want to see the contents of the structure. It suffices to type
<pre class="smallexample"> p *$
</pre>
<p>If you have a chain of structures where the component <code>next</code> points
to the next one, you can print the contents of the next one with this:
<pre class="smallexample"> p *$.next
</pre>
<p class="noindent">You can print successive links in the chain by repeating this
command&mdash;which you can do by just typing &lt;RET&gt;.
<p>Note that the history records values, not expressions. If the value of
<code>x</code> is 4 and you type these commands:
<pre class="smallexample"> print x
set x=5
</pre>
<p class="noindent">then the value recorded in the value history by the <code>print</code> command
remains 4 even though the value of <code>x</code> has changed.
<a name="index-show-values-722"></a>
<dl><dt><code>show values</code><dd>Print the last ten values in the value history, with their item numbers.
This is like &lsquo;<samp><span class="samp">p $$9</span></samp>&rsquo; repeated ten times, except that <code>show
values</code> does not change the history.
<br><dt><code>show values </code><var>n</var><dd>Print ten history values centered on history item number <var>n</var>.
<br><dt><code>show values +</code><dd>Print ten history values just after the values last printed. If no more
values are available, <code>show values +</code> produces no display.
</dl>
<p>Pressing &lt;RET&gt; to repeat <code>show values </code><var>n</var> has exactly the
same effect as &lsquo;<samp><span class="samp">show values +</span></samp>&rsquo;.
</body></html>