Linux gdb前端与vim一起使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6695410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 05:05:39  来源:igfitidea点击:

gdb front end to use with vim?

c++clinuxvimgdb

提问by Letholdrus

What gdb frontends can I use with vim for debugging C and C++ code? Currently I use cgdband am satisfied with it. Was just wondering what else is out there?

哪些 gdb 前端可以与 vim 一起使用来调试 C 和 C++ 代码?目前我使用cgdb并且对它很满意。只是想知道那里还有什么?

采纳答案by user606723

Google is your friend. http://clewn.sourceforge.net/

谷歌是你的朋友。 http://clewn.sourceforge.net/

Honestly, I think that you're better off sticking with cgdb.

老实说,我认为你最好坚持使用cgdb

回答by KOlegA

Look at pyclewn. As written on vim.org:

看看pyclewn。正如 vim.org 上所写:

Pyclewn - an extension for Vim that supports full use of gdb from Vim. With breakpoints, watch variables, gdb command completion, etc. Uses the NetBeans interface.

Pyclewn - Vim 的扩展,支持完全使用 Vim 中的 gdb。带有断点、观察变量、gdb 命令完成等。使用 NetBeans 接口。

Maybe it's not so easy to start use it as cgdb, but it's easy to use it.

也许像cgdb一样开始使用它不是那么容易,但是它很容易使用。

First you need to compile vim with +netbeans_intg feature and +python/dyn or +python3/dyn For example you use python3. Configure vim like this:

首先,您需要使用 +netbeans_intg 功能和 +python/dyn 或 +python3/dyn 编译 vim 例如,您使用 python3。像这样配置vim:

./configure --with-features=huge --enable-python3interp

Don't forget to install python header files (package python3-dev). Then downloadpyclewn-1.7.py3.tar.gz and install.

不要忘记安装 python 头文件(包 python3-dev)。然后下载pyclewn-1.7.py3.tar.gz并安装。

You can use installation manual from siteor install it with pathogen. To install with pathogen:

您可以使用来自站点的安装手册或使用pathogen安装它。与病原体一起安装:

tar zxvf pyclewn-1.7.py3.tar.gz
vimdir=$HOME/.vim/bundle/pyclewn python3 setup.py install --force --home=$HOME/.vim/local

Change line $HOME/.vim/local/lib/python/clewn/vim.py:343 from 'runtime plugin/pyclewn.vim' to 'runtime bundle/pyclewn/plugin/pyclewn.vim'

将行 $HOME/.vim/local/lib/python/clewn/vim.py:343 从 'runtime plugin/pyclewn.vim' 更改为 'runtime bundle/pyclewn/plugin/pyclewn.vim'

Add path $HOME/.vim/local/bin (or any other that you use) to your PATH.

将路径 $HOME/.vim/local/bin (或您使用的任何其他路径)添加到您的 PATH。

Add variable

添加变量

export CLEWNDIR=$HOME/.vim/bundle/pyclewn/macros

You can change key mapping in file $HOME/.vim/bundle/pyclewn/macros/.pyclewn_keys.gdb

您可以在文件 $HOME/.vim/bundle/pyclewn/macros/.pyclewn_keys.gdb 中更改键映射

For easy pyclewn running I use next bash file: $HOME/.vim/local/bin/pclewn

为了便于 pyclewn 运行,我使用下一个 bash 文件:$HOME/.vim/local/bin/pclewn

#!/bin/bash
pyclewn --gdb="async" --args="--args $@" --cargs='-c "runtime misc/pclewn.vim" -c "call PyClewnPre()"'

and vim script $HOME/.vim/misc/pclewn.vim

和 vim 脚本 $HOME/.vim/misc/pclewn.vim

function! PyClewnInit()
    C tbreak main
    Cmapkeys
    unmap <CR>
endfunction

function! PyClewnPre()
    map <CR> :call PyClewnInit()<CR>
    0put ='Press <Enter> to start'
    setlocal buftype=nofile
endfunction

So, to start debugging I use command:

因此,要开始调试,我使用命令:

pclewn my_program arg1 arg2 argN

UPD: Your C++ program probably uses STL containers. To display them nicely download dbinit_stl_views-1.03.txtand rename this file to ~/.gdbinit. After this you can use commands like:

UPD:您的 C++ 程序可能使用 STL 容器。要很好地显示它们,请下载dbinit_stl_views-1.03.txt并将此文件重命名为 ~/.gdbinit。在此之后,您可以使用以下命令:

pstring stl_variable
pvector stl_variable

Help available from gdb, for example by command 'help pmap'. Read more here

可以从 gdb 获得帮助,例如通过命令“help pmap”。在这里阅读更多

And of course you can map key to print string under cursor like this:

当然,您可以将键映射到光标下的打印字符串,如下所示:

nmap <F1> :exe "C pstring " . expand("<cword>")<CR>

回答by Arun

IMO, gdb TUI is the easiest. You can look at the list of key bindings here: http://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html#TUI-Keys

IMO,gdb TUI 是最简单的。您可以在此处查看键绑定列表:http: //sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html#TUI-Keys

Especially, s (step-in) and f (finish the function and return) are most useful key bindings.

特别是,s(step-in)和f(完成函数并返回)是最有用的键绑定。

回答by Druesukker

Conque GDB is very similar to cgdb. It is a terminal emulator which turns a vim buffer into a gdb command line interface. See http://www.vim.org/scripts/script.php?script_id=4582

Conque GDB 与 cgdb 非常相似。它是一个终端模拟器,可将 vim 缓冲区转换为 gdb 命令行界面。见http://www.vim.org/scripts/script.php?script_id=4582