GDB中的键映射 [英] Key mapping in GDB

查看:105
本文介绍了GDB中的键映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在GDB中为命令定义任意组合键?我想知道是否有VIM map命令之类的东西。例如,我想映射到next,step等。.

Is it possible to define an arbitrary key combination to a command in GDB? I would like to know if there is something like the VIM map command. For example, I would like to map to next, to step, and so on..

推荐答案

映射gdb中的键(在gdb / cygwin / win7上测试)

To map keys in gdb (tested on gdb/cygwin/win7)

1. Start gdb
2. Find the key generated by F7, Press C-v F7
   (gdb) ^[[18~
3. vi ~/.inputrc
   # Map F7 to next
   "\e[18~": "n\n" 
4. Restart gdb, and now F7 will be mapped to "next\n" 

此处的更多信息> https://sourceware.org/gdb/onlinedocs/gdb/Readline-Init-File-Syntax.html

# Sample ~/.inputrc
$if Gdb
"\e[23~": "next\n # [F7] next.\n"  
"\e[A":  "# Up key\n"
"\e[B":  "next\n # [Down]  next line.\n"
"\e[C":  "step\n # [Right] step into func.\n"
"\e[D":  "finish\n # [Left] to finish.\n"
$endif

gdb内置了基于文本的gui,称为TUI模式,甚至可以在cygwin / win7中使用,示例用法:

gdb has builtin text based gui called TUI mode, even works in cygwin/win7, Sample usage:

> g++ -Wall -g -lm -std=c++14 hello.cpp
> gdb -tui a.exe

按Cx s ..进入单键模式

Press C-x s .. for Single key mode

    q - quit, exit SingleKey mode.  
    c - continue
    d - down
    f - finish
    n - next
    r - run 
    s - step 
    u - up 
    v - info locals 
    w - where  

更多信息 https://volse.anduin.net/rabalder/2015/06/01/gdb-tricks-基于文本的ui.html 和此处 https ://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_19.html

这篇关于GDB中的键映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆