gdb-tui and the previous-command problemPosted: January 26, 2016
Raise your hand if you have run gdb in tui (graphical) mode, only to find you can’t refer to the previous command when pressing “up”. I can’t see you but I know this is true for pretty much everyone reading this blog. All three of you.
In the gdb-TUI mode, the arrow keys are used by the active window for scrolling. This means they are not available for readline, the component that takes care of the magic invocations needed to bring back the previous command from the land of the dead. Luckily there are alternative readline keybindings: just try C-p, C-n, C-b and C-f. Takes a while getting used to it but you can finally use gdb-TUI and forget about copy-pasting every gdb command.
Bonus tip: if pressing “up” (or C-p) in gdb doesn’t bring back the previous command, it probably means you don’t have the readline package installed. Go ahead an install it. It’ll change your life.