2

I'm new to GDB and can't get the command history (auto complete/up arrow to old commands working).

At my root I have a .gbd_init file (and I also have an identical file in my working directory):

set history save

set history filename ~/.gbd_history

set history on

set history expansion on

I also have an empty .gbd_history file at my root.

In GBD 'show history' gives:

(gdb) show history

expansion:  History expansion on command input is on.

filename:  The filename in which to record the command history is      
"/home/jenny/C_Programs/CS575_Algorithms/HW3/Problem1/.gdb_history".

save:  Saving of the history record on exit is on.

size:  The size of the command history is unlimited.

(gdb) 

But the GBD command 'show commands' yields nothing and the up-arrows and tab don't do anything.

The .gbd_history file exists but is empty.

 jenny@jennys-virtual-machine ~/C_Programs/CS575_Algorithms/HW3/Problem1 $ ls -ls .gbd*

 0 -rwxrwxrwx 1 jenny jenny  0 Oct  1 22:16 .gbd_history

 4 -rwxrwxrwx 1 jenny jenny 94 Oct  1 22:01 .gbdinit

What am I missing?

Thanks for any help. Typing in each command is getting old fast.

Jenny

2 Answers2

1

At my root I have a .gbd_init file (and I also have an identical file in my working directory):

You have misspelled gdb init file name. It should be named .gdbinit. .gbd_init is not get executed by gdb and history saving is not turned on.

ks1322
  • 33,961
  • 14
  • 109
  • 164
0

Your .gdbinit script obviously is not executed, as you can see from your gdb_history filename, which has it's default value (gdb_history in current directory).

Try executing this init script in your current directory with gdb -x .gdbinit, as it may be disabled by default. At least my gdb wants me to set some kind of auto-load safe-path before it will allow loading of init scripts residing outside of home directory. See details here.

If you are looking to use history only to not have to repeat commands, you should probably just write a script with all those commands, and execute it with gdb -x script etc.

And surely check this SO thread on how to enable command history easily.

Community
  • 1
  • 1
dbrank0
  • 9,026
  • 2
  • 37
  • 55
  • Thanks so much. It's working now. I updated my .gdbinit file to begin with "set auto-load safe-path /" and then invoked gdb with "gdb -q -iex "set auto-load safe-path /home/jenny" program -tui" and now the command history/up arrow is working. – Excelsior1024 Oct 04 '14 at 02:06