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.


3 Comments on “gdb-tui and the previous-command problem”

  1. UncleNinja says:

    thank you dude

  2. Anonymous says:

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s