22.3 Command History
gdb uses the gnu History library, a part of the Readline package, to provide the history facility. See Using History Interactively, for the detailed description of the History library.
To issue a command to gdb without affecting certain aspects of the state which is seen by users, prefix it with server (see Server Prefix). This means that this command will not affect the command history, nor will it affect gdb's notion of which command to repeat if <RET> is pressed on a line by itself.
set history filenamefname
- Set the name of the gdb command history file to fname.
This is the file where gdb reads an initial command history
list, and where it writes the command history from this session when it
exits. You can access this list through history expansion or through
the history command editing characters listed below. This file defaults
to the value of the environment variable
GDBHISTFILE, or to ./.gdb_history (./_gdb_history on MS-DOS) if this variable is not set.
set history save
set history save on
- Record command history in a file, whose name may be specified with the
set history filenamecommand. By default, this option is disabled.
set history save off
- Stop recording command history in a file.
set history sizesize
- Set the number of commands which gdb keeps in its history list.
This defaults to the value of the environment variable
HISTSIZE, or to 256 if this variable is not set.
History expansion assigns special meaning to the character !. See Event Designators, for more details.
Since ! is also the logical not operator in C, history expansion
is off by default. If you decide to enable history expansion with the
set history expansion on command, you may sometimes need to
follow ! (when it is used as logical not, in an expression) with
a space or a tab to prevent it from being expanded. The readline
history facilities do not attempt substitution on the strings
!= and !(, even when history expansion is enabled.
The commands to control history expansion are:
set history expansion on
set history expansion
- Enable history expansion. History expansion is off by default.
set history expansion off
- Disable history expansion.
show history filename
show history save
show history size
show history expansion
- These commands display the state of the gdb history parameters.
show historyby itself displays all four states.
- Display the last ten commands in the command history.
- Print ten commands centered on command number n.
show commands +
- Print ten commands just after the commands last printed.