Fwd: [PATCH] Fix for PR gdb/15224 should "set history save on" by default
Jan Kratochvil
jan.kratochvil@redhat.com
Tue Apr 2 17:10:00 GMT 2013
On Mon, 01 Apr 2013 16:15:11 +0200, Pedro Alves wrote:
> On 04/01/2013 01:29 PM, Jan Kratochvil wrote:
> >> > The history's filename is also tweakable with the GDBHISTFILE
> >> > environment variable (there's HISTSIZE too; 'GDBHISTFILE= gdb' effectively
> >> > disables history load/save). Doesn't feel quite right to tie this to .gdbinit.
> > It matters how are the existing environments set up. And by default neither
> > HISTSIZE nor GDBHISTFILE environment variables are set.
>
> Not clear to me which environments you're referring to here,
How >90% of GDB users run it.
> if you're referring to any specific environments. (HISTSIZE won't be as rare,
> because that's also the variable used by bash. We should probably
> have a GDBHISTSIZE too.)
I meant >90% of GDB users do not have GDBHISTFILE environment variables set.
> I think however, that whether to write history to file should also
> check whether we're in interactive debugging mode:
>
> /* Save the history information if it is appropriate to do so. */
> if (write_history_p && history_filename)
> write_history (history_filename);
>
> That is, e.g., this touches history:
>
> $ ls -als ~/.gdbhist
> 4 -rw-------. 1 pedro pedro 27 Apr 1 14:10 /home/pedro/.gdbhist
> $ date
> Mon Apr 1 14:37:01 WEST 2013
> $ gdb -ex "set history filename ~/.gdbhist" < /dev/null
> (gdb) quit
> $ ls -als ~/.gdbhist
> 4 -rw-------. 1 pedro pedro 27 Apr 1 14:37 /home/pedro/.gdbhist
>
> That, I'd call a bug.
I agree.
>
> Probably, it'd be best to use input_from_terminal_p, which also
> checks for --batch mode, among other things.
>
> I think that all covers cases like abrt and other crash catchers that
> spawn gdb?
Hopefully they usually use redirection from file so ISATTY should catch that
which I did not realize before.
OK, that seems as a good plan - with patching the GDB testsuite to disable
history saving. I expect it will still affect some 3rd party testsuite using
GDB but you have convinced me such cases will not be significant enough.
I tested now that "ddd" will store the history commands like "step".
But as it runs GBD with "gdb -q -fullname PROGNAME" it already happens if one
has "set history save on" in ~/.gdbinit so I would not call that a regression.
http://pkgs.fedoraproject.org/cgit/gdb.git/plain/gdb-6.5-BEA-testsuite.patch
is using:
cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > $LOG
which should get handled by existing ISATTY in GDB.
> > I see there should be also changed the default to:
> > set history filename ~/.gdb_history
> >
> > Otherwise it is a similar pain to ./.gdbinit, it is also non-standard to any
> > other normal application which use history files in $HOME, I do not find using
> > ./.gdb_history by default as acceptable.
>
> That'd be fine with me. However, we'd need a way to be able to specify
> "./.gdbinit" back. We have precedent for "$cwd", so perhaps that would
> best be addressed by making "set history filename $cwd/.gdb_history" work.
This command works for me:
unset GDBHISTFILE; gdb -ex "set history filename .gdb_history"
I do not understand why you mention $cwd, what $cwd should do differently?
I was expecting that by default
cd /tmp; (unset GDBHISTFILE; gdb -nx)
will change from
(gdb) show history filename
The filename in which to record the command history is "/tmp/.gdb_history".
to
(gdb) show history filename
The filename in which to record the command history is "/home/user/.gdb_history".
.
Jan
More information about the Gdb-patches
mailing list