Fwd: [PATCH] Fix for PR gdb/15224 should "set history save on" by default

Pedro Alves palves@redhat.com
Wed Apr 3 17:14:00 GMT 2013


On 04/02/2013 04:26 PM, Jan Kratochvil wrote:
> 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.

Ack.  It just sounded from the wording you were thinking of some specific
case.

> 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.

Yeah.  The history size is 256 by default, so IMO it's no big issue.  It'd be
worse if the history file could grow unbounded by default, IMO.

I didn't realize ddd used annotations...  I've updated the wiki's frontend
hall of shame^Wfame: http://sourceware.org/gdb/wiki/GDB%20Front%20Ends

> 
> 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.

Good.


> This command works for me:
> 	unset GDBHISTFILE; gdb -ex "set history filename .gdb_history"

Indeed it works.  I actually didn't think to try it.  I read:

  tmpenv = getenv ("GDBHISTFILE");
  if (tmpenv)
    history_filename = xstrdup (tmpenv);
  else if (!history_filename)
    {
      /* We include the current directory so that if the user changes
         directories the file written will be the same as the one
         that was read.  */
#ifdef __MSDOS__
      /* No leading dots in file names are allowed on MSDOS.  */
      history_filename = concat (current_directory, "/_gdb_history",
				 (char *)NULL);
#else
      history_filename = concat (current_directory, "/.gdb_history",
				 (char *)NULL);
#endif
    }
  read_history (history_filename);

noticed the explicit current directory handling and assumed it didn't.

But, it doesn't work the same.  Vis.:

 $ gdb
 (gdb) show history filename
 The filename in which to record the command history is "/tmp/.gdb_history".
 (gdb) q

Notice, absolute path above.

 $ cd /tmp
 $ mkdir a
 $ gdb -ex "set history filename .gdbhist"
 (gdb) show history filename
 The filename in which to record the command history is ".gdbhist".
 (gdb) cd a
 Working directory /tmp/a.
 (gdb) q
 $ cat a/.gdbhist
 show history filename
 cd a
 q
 $ ls .gdbhist a/.gdbhist
 ls: cannot access .gdbhist: No such file or directory
 a/.gdbhist
 $

So, the current default resolves the relative .gdb_history path
early on, meaning, the history file written is the same that was
read, while "set history filename .gdb_history" resolves to
different files at read and at write times, as seen in the example
above.  I'd call that a bug too.

> 
> I do not understand why you mention $cwd, what $cwd should do differently?

Not necessary it seems then.  The above issue should be addressed though.
Probably by making "set history filename"'s set hook resolve the path.
Whether to make "show history filename" show just the resolved path, or
both, I'm undecided.

> 
> 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".

Right.

-- 
Pedro Alves



More information about the Gdb-patches mailing list