Subject: Re: bug#59838: 30.0.50; [PATCH] Save history in GDB session

From: Eli Zaretskii <[email-masked]>
Date: Mon, 05 Dec 2022 21:35:25 +0200

> From: Manuel Giraud <[email-masked]>
> Cc: [email-masked]
> Date: Mon, 05 Dec 2022 18:53:33 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> From: Manuel Giraud <[email-masked]>
> >> Date: Mon, 05 Dec 2022 17:53:06 +0100
> >> 
> >> I'm not really an expert in gdb (and comint-mode) but it seems that 'M-x
> >> gdb' does not save its history.  Here is a patch that fix this.
> >
> > GDB has its own history feature, activated by the GDB command "set history
> > save on".  If the GDB history file is detected when "M-x gdb" starts, it
> > will read the history and fill comint-input-ring with what it finds there.
> > See the function 'gdb' in gdb-mi.el.
> >
> > So I think this is already covered, or what did I miss?
> 
> I already have this in my ~/.gdbinit:
> --8<---------------cut here---------------start------------->8---
> set history save on
> set history size 1024
> add-auto-load-safe-path /home/manuel/emacs-repo/src/.gdbinit
> --8<---------------cut here---------------end--------------->8---
> 
> When debugging emacs from 'M-x gdb', gdb does create a file
> "/home/manuel/emacs-repo/src/.gdb_history" but it always stays empty
> even when I "quit" from the *gud-emacs* buffer.

I guess this is because GDB's history works via Readline, and Readline is
not used when Emacs is the front end.

Then I think your patch is correct, thanks.