3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"History">History
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Screen-Size.html#Screen%20Size">Screen Size
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Editing.html#Editing">Editing
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Controlling-GDB.html#Controlling%20GDB">Controlling GDB
</a>
19 <h3 class=
"section">Command history
</h3>
21 GDB can keep track of the commands you type during your
22 debugging sessions, so that you can be certain of precisely what
23 happened. Use these commands to manage the GDB command
27 <dt><code>set history filename
</code><var>fname
</var><code></code>
28 <dd>Set the name of the GDB command history file to
<var>fname
</var>.
29 This is the file where GDB reads an initial command history
30 list, and where it writes the command history from this session when it
31 exits. You can access this list through history expansion or through
32 the history command editing characters listed below. This file defaults
33 to the value of the environment variable
<code>GDBHISTFILE
</code>, or to
34 <code>./.gdb_history
</code> (
<code>./_gdb_history
</code> on MS-DOS) if this variable
37 <br><dt><code>set history save
</code>
38 <dd><dt><code>set history save on
</code>
39 <dd>Record command history in a file, whose name may be specified with the
40 <code>set history filename
</code> command. By default, this option is disabled.
42 <br><dt><code>set history save off
</code>
43 <dd>Stop recording command history in a file.
45 <br><dt><code>set history size
</code><var>size
</var><code></code>
46 <dd>Set the number of commands which GDB keeps in its history list.
47 This defaults to the value of the environment variable
48 <code>HISTSIZE
</code>, or to
256 if this variable is not set.
51 <p>History expansion assigns special meaning to the character
<kbd>!
</kbd>.
53 <p>Since
<kbd>!
</kbd> is also the logical not operator in C, history expansion
54 is off by default. If you decide to enable history expansion with the
55 <code>set history expansion on
</code> command, you may sometimes need to
56 follow
<kbd>!
</kbd> (when it is used as logical not, in an expression) with
57 a space or a tab to prevent it from being expanded. The readline
58 history facilities do not attempt substitution on the strings
59 <kbd>!=
</kbd> and
<kbd>!(
</kbd>, even when history expansion is enabled.
61 <p>The commands to control history expansion are:
64 <dt><code>set history expansion on
</code>
65 <dd><dt><code>set history expansion
</code>
66 <dd>Enable history expansion. History expansion is off by default.
68 <br><dt><code>set history expansion off
</code>
69 <dd>Disable history expansion.
71 <p>The readline code comes with more complete documentation of
72 editing and history expansion features. Users unfamiliar with
<small>GNU
</small> Emacs
73 or
<code>vi
</code> may wish to read it.
75 <br><dt><code>show history
</code>
76 <dd><dt><code>show history filename
</code>
77 <dd><dt><code>show history save
</code>
78 <dd><dt><code>show history size
</code>
79 <dd><dt><code>show history expansion
</code>
80 <dd>These commands display the state of the GDB history parameters.
81 <code>show history
</code> by itself displays all four states.
85 <dt><code>show commands
</code>
86 <dd>Display the last ten commands in the command history.
88 <br><dt><code>show commands
</code><var>n
</var><code></code>
89 <dd>Print ten commands centered on command number
<var>n
</var>.
91 <br><dt><code>show commands +
</code>
92 <dd>Print ten commands just after the commands last printed.