【问题标题】:Key mapping in GDBGDB 中的键映射
【发布时间】:2012-10-26 16:22:06
【问题描述】:

是否可以在 GDB 中为命令定义任意组合键?我想知道是否有类似 vim map 命令的东西。例如,我想映射到下一个,到一步,等等..

【问题讨论】:

    标签: debugging gcc gdb binutils


    【解决方案1】:

    在 gdb 中映射键(在 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 下工作,示例用法:

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

    按 C-x s .. 进入单键模式

        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-text-based-ui.html 和这里https://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_19.html

    【讨论】:

      【解决方案2】:

      GDB 使用 GNU readline 来读取输入。文档here(或直接输入man readline)。

      特别注意如何绑定F1插入文字Function key 1的例子。

      【讨论】:

        猜你喜欢
        • 2020-11-19
        • 2011-11-18
        • 1970-01-01
        • 2010-10-13
        • 2016-12-13
        • 2010-12-13
        • 2019-07-23
        • 2020-08-23
        • 1970-01-01
        相关资源
        最近更新 更多