I usually debug in console gdb and now I'm trying to move to Emacs. In my ~/.gdbinit I have the following lines setting up history:

# save history of unlimited size, write always to ~/.gdb_history
set history save on
set history size unlimited
set history filename ~/.gdb_history

And in console gdb history works perfectly. show history result there:

(gdb) show history
+show history
expansion:  History expansion on command input is off.
filename:  The filename in which to record the command history is "/home/ars/.
gdb_history".
save:  Saving of the history record on exit is on.
size:  The size of the command history is 10000000.

If you wonder, history size is 10000000 instead of unlimited because I have $HISTSIZE=10000000.

In Emacs, I successfully search for old commands from ~/.gdb_history with comint-history-isearch-backward-regexp. However, the problem is that commands entered while debugging from Emacs are not appended to ~/.gdb_history. I can still search through them in the current session, i.e. they are saved somewhere in memory, but they will not be written to the file and as a consequence I don't see them in the following sessions.

While GDB starts inside Emacs, I see that the config is read:

...
+set history save on
+set history size unlimited
+set history filename ~/.gdb_history
...

And show history output there is exactly the same like in console GDB:

show history
+show history 
expansion:  History expansion on command input is off.
filename:  The filename in which to record the command history is "/home/ars/.gdb_history".
save:  Saving of the history record on exit is on.
size:  The size of the command history is 10000000.
(gdb) +info break

I start gdb with command like (gdb "gdb -i=mi $PROGTODEBUG") and finish debugging with quit, typed manually or via C-d. Then I kill the buffer with kill-this-buffer and exit Emacs. GNU Emacs version is 25.1.

  • Thanks for the edit. It looks like this is an interaction between server command and history, and may be a bug. – icarus Nov 25 '16 at 1:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.