syntax highlight

Tuesday 26 January 2016

gdb-tui and the previous-command problem

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.

11 comments:

  1. Thanks. A second option is to focus the command window, then arrows work. To cycle focus: C-x o.

    ReplyDelete
  2. 4 now. Thank you.

    ReplyDelete
  3. There are dozens of us! dozens!

    ReplyDelete
  4. Seems so... and I'm still surprised by that!
    Thanks Anon

    ReplyDelete
  5. More than dozens!!

    ReplyDelete
  6. There is a whole company of us here!

    ReplyDelete
  7. there is me too

    ReplyDelete
  8. Thank you very much, I am learning GDB and this saves me so many grey hairs.

    ReplyDelete