GDB: How to add a key combination which runs a com

2019-05-28 02:18发布

问题:

I'm using GNU gdb (GDB) 7.10.1 with the -tui mode. I would like to add a key combination for the commands up and down. Something like Ctrl+u for up and Ctrl+d for down.

I've seen only comments about readline but not an example explaining how to integrate the combination in the gdb init file. Any idea?

回答1:

I am not a TUI user, but my understanding is that the TUI has two modes.

In its initial (normal) mode, it uses readline like the ordinary gdb CLI. Readline provides a way to rebind keys via ~/.inputrc. The main thing you need to know here is that gdb is, sensibly enough, called "gdb" for readline's purposes. So a binding might look like:

$if gdb
"\C-u": "up\n"
$endif

The TUI also has a "single key" mode. As far as I know, this mode doesn't use readline and there is no way to rebind keys. However, in this mode, "u" and "d" are already bound the way you'd like.