diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-01-22 18:21:58 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-03-02 18:59:38 +0000 |
commit | 63e163f24fe80fe1509527e6ccfcfb9622f5e99e (patch) | |
tree | 36d85fd9d5a52b110ecfcd4dd5f70fdf4d36304d /gdb/doc/gdb.texinfo | |
parent | 81b86b9702b5be9d022e9b0c96c1ee2ce339b5b9 (diff) | |
download | gdb-63e163f24fe80fe1509527e6ccfcfb9622f5e99e.zip gdb-63e163f24fe80fe1509527e6ccfcfb9622f5e99e.tar.gz gdb-63e163f24fe80fe1509527e6ccfcfb9622f5e99e.tar.bz2 |
gdb: Allow GDB to _not_ load a previous command history
This commit aims to give a cleaner mechanism by which the user can
prevent GDB from trying to load any previous command history.
Currently the user can change the path to the history file, either
using a command line flag, or by setting the GDBHISTFILE environment
variable, and if the path is set to a non-existent file, then
obviously GDB wont load any command history. However, this feels like
a bit of a bodge, I'd like to add an official mechanism by which we
can disable command history loading.
Why would we want to prevent command history loading? The specific
use case I have is GDB starting with a CWD that is a network mounted
directory, and there is no command history present. Still GDB will
access the network in order to check for the file. In my particular
use case I'm actually starting a large number of GDB instances in
parallel, all in the same network mounted directory, the large number
of network accesses looking for this file introduces a noticeable
delay at GDB startup.
The approach I'm proposing here is a slight adjustment to the current
rules for setting up the history filename. Currently, if a user does
this, they see an error:
(gdb) set history filename
Argument required (filename to set it to.).
However, if a user does this:
$ GDBHISTFILE= gdb --quiet
(gdb) set history save on
(gdb) q
warning: Could not rename -gdb18416~ to : No such file or directory
So, we already have a bug in this area. My plan is to allow the empty
filename to be accepted, and for this to mean, neither load, nor save
the command history.
This does mean that we now have two mechanisms to prevent saving the
command history:
(gdb) set history filename
or
(gdb) set history save off
But the only way to prevent loading the command history is to set the
filename to the empty string _before_ you get to a GDB prompt, either
using a command line option, or the environment variable.
I've updated some of the show commands, for example this session:
(gdb) set history filename
(gdb) show history filename
There is no filename currently set for recording the command history in.
(gdb) show history save
Saving of the history record on exit is off.
(gdb) set history save on
(gdb) show history save
Saving of the history is disabled due to the value of 'history filename'.
(gdb) set history filename /tmp/hist
(gdb) show history save
Saving of the history record on exit is on.
I've updated the manual, and added some tests.
gdb/ChangeLog:
* NEWS: Mention new behaviour of the history filename.
* top.c (write_history_p): Add comment.
(show_write_history_p): Add header comment, give a different
message when history writing is on, but the history filename is
empty.
(history_filename): Add comment.
(history_filename_empty): New function.
(show_history_filename): Add header comment, give a different
message when the filename is empty.
(init_history): Compare history_filename against nullptr, and only
read history if the filename is not empty.
(set_history_filename): Add header comment, and only make
non-empty filenames absolute.
(init_main): Make the filename argument to 'set history filename'
optional.
gdb/doc/ChangeLog:
* gdb.texinfo (Command History): Extend description for
GDBHISTFILE and GDBHISTSIZE, add detail about the filename for
'set history filename' being optional. Describe the effect of an
empty history filename on 'set history save on'.
gdb/testsuite/ChangeLog:
* gdb.base/default.exp: Remove test of 'set history filename'.
* gdb.base/gdbinit-history.exp: Add tests for setting the history
filename to the empty string.
* lib/gdb.exp (gdb_init): Unset environment variables GDBHISTFILE
and GDBHISTSIZE.
Change-Id: Ia586e4311182fac99113b60f11ef8a11fbd5450b
Diffstat (limited to 'gdb/doc/gdb.texinfo')
-rw-r--r-- | gdb/doc/gdb.texinfo | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b947c5d..32e419e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -25306,7 +25306,7 @@ history. @cindex history file @kindex set history filename @cindex @env{GDBHISTFILE}, environment variable -@item set history filename @var{fname} +@item set history filename @r{[}@var{fname}@r{]} Set the name of the @value{GDBN} command history file to @var{fname}. This is the file where @value{GDBN} reads an initial command history list, and where it writes the command history from this session when it @@ -25316,15 +25316,29 @@ to the value of the environment variable @code{GDBHISTFILE}, or to @file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable is not set. +The @code{GDBHISTFILE} environment variable is read after processing +any @value{GDBN} initialization files (@pxref{Startup}) and after +processing any commands passed using command line options (for +example, @code{-ex}). + +If the @var{fname} argument is not given, or if the @code{GDBHISTFILE} +is the empty string then @value{GDBN} will neither try to load an +existing history file, nor will it try to save the history on exit. + @cindex save command history @kindex set history save @item set history save @itemx set history save on Record command history in a file, whose name may be specified with the -@code{set history filename} command. By default, this option is disabled. +@code{set history filename} command. By default, this option is +disabled. The command history will be recorded when @value{GDBN} +exits. If @code{set history filename} is set to the empty string then +history saving is disabled, even when @code{set history save} is +@code{on}. @item set history save off -Stop recording command history in a file. +Don't record the command history into the file specified by @code{set +history filename} when @value{GDBN} exits. @cindex history size @kindex set history size @@ -25338,6 +25352,11 @@ are ignored. If @var{size} is @code{unlimited} or if @env{GDBHISTSIZE} is either a negative number or the empty string, then the number of commands @value{GDBN} keeps in the history list is unlimited. +The @code{GDBHISTSIZE} environment variable is read after processing +any @value{GDBN} initialization files (@pxref{Startup}) and after +processing any commands passed using command line options (for +example, @code{-ex}). + @cindex remove duplicate history @kindex set history remove-duplicates @item set history remove-duplicates @var{count} |