0

基于 neovim 终端集成 gdb

 2 years ago
source link: https://hiberabyss.github.io/2018/02/28/neovim-gdb-integration/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

基于 neovim 终端集成 gdb

Feb 28, 2018 | Vim | 阅读 | 399 字 | 1 分钟
0 条评论

相比于 IDE, 当使用 VIM 作为编辑器时, 调试会显得很麻烦. 借助于 neovim 的终端, 我们可以在 VIM 中实现类似 IDE 的编辑调试功能: 在 VIM 编辑窗口中按特定的快捷键即可执行特定的调试命令, 同时在 VIM 窗口中也能显示当前的 断电及程序执行的位置.

Requirement

  • Neovim
  • gdb (C, C++);
  • delve (golang); 可通过 go get -u github.com/derekparker/delve/cmd/dlv 安装

演示

安装 VIM 插件 NeovimGDB

Plug "https://github.com/hiberabyss/NeovimGdb"

然后便可实现如下的效果:

其中的主要操作步骤包括:

  1. 执行 GdbLocal 命令进入 GDB 模式;
  2. 按快捷键 ;b 设置断点 (再次按这个快捷键可以取消断点)
  3. ;r 开始执行程序;
  4. ;n 执行到下一行;
  5. ;p 打印光标下的变量;
  6. ;gk 退出 GDB 模式
  • 对于 C, C++ 类型文件, 可以通过 GdbLocal 启动调试窗口 (或通过默认按键映射 ,rd);
  • 对于 go 类型文件, 可以通过 GoDebug 启动调试窗口;
  • 可以调用命令 GdbDebugStop 来停止调试 (默认按键映射为 ;gk);

我们可以直接在调试窗口中输入调试命令, 也可以通过下列按键映射从代码窗口往调试窗口发送命令:

  • ;r 发送 r
  • ;c 发送 c
  • ;b 发送 b
  • ;n 发送 n
  • ;p 发送 p word_under_cursor
  • ;u 发送 u
来发评论吧~
Powered By Valine
v1.4.18

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK