It might because of your history size is 0.
You can check your gdb history size:
(gdb) show history size
The size of the command history is 0.
(gdb)
If the history maximum size is 0, then up arrow is of course not working because no history could be saved.
The main reason i found is because the bash environment variable HISTSIZE is 0 or empty. It's frustrating because i thought HISTSIZE= (empty value on the right) in ~/.bashrc can make bash history saved unlimited entries, but the side effect is gdb refer to $HISTSIZE and then set gdb history size to 0 on gdb startup.
So you can put HISTSIZE=10000000 on your ~/.bashrc and up arrow should works now (WARN: backup your ~/.bash_history before play around with HISTSIZE):
(gdb) show history size
The size of the command history is 10000000.
(gdb)
If you insist to keep HISTSIZE= empty on ~/.bashrc, then the option is create this function on ~/.bashrc:
gdb() ( HISTSIZE=70000000; /usr/bin/gdb "$@"; )
. ~/.bashrc to reload, now it changed:
(gdb) show history size
The size of the command history is 70000000.
(gdb)
After exit from gdb, the original $HISTSIZE will not get overridden (i.e. remains empty as unlimited) because our gdb function use subshell, i.e. surrounded by parentheses, gdb() (...):
$ echo $HISTSIZE
$
You also have to turn on history on exit, and then think where to store the history file. The following is my ~/.gdbinit file, create it if not exist yet:
$ cat ~/.gdbinit
set environment HISTSIZE 10000000
set history filename ~/.gdb_history
set history save on
set history size 10000000
set history expansion on
show history
$
You might ask why set environment HISTSIZE 10000000 doesn't works ? It's because it only affect program, not gdb itself, as indicated at page http://www.delorie.com/gnu/docs/gdb/gdb_20.html:
Set environment variable varname to value. The value changes for your
program only, not for GDB itself.
Patch is available now, see https://sourceware.org/bugzilla/show_bug.cgi?id=16999 :
2015-06-17 18:14:09 UTC:
...
This patch makes the behavior of invalid GDBHISTSIZE consistent with how
bash handles HISTSIZE. When we encounter a null or out-of-range
GDBHISTSIZE (outside of [0, INT_MAX]) we now set the history size to
unlimited instead of 0. When we encounter a non-numeric GDBHISTSIZE we
do nothing.
2015-06-17 18:30:10 UTC:
The next version of GDB will no longer read HISTSIZE at all because
doing so causes more problems than it solves. Instead GDBHISTSIZE is
read for the same purpose. And for good measure, the behavior of
GDBHISTSIZE will match how bash reads HISTSIZE, so setting GDBHISTSIZE
to -1 will cause GDB's history size to be unlimited.
~/.inputrc
. If that doesn't sound like something you've modified recently, please provide the contents of it.$TERM
?