开发者

gdb front end to use with vim? [duplicate]

This question already has answers here: 开发者_如何学运维 gvim and gdb for C? (8 answers) Closed 7 years ago.

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


Look at pyclewn. As written on 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.

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

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:

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

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

You can use installation manual from site or install it with pathogen. To install with 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'

Add path $HOME/.vim/local/bin (or any other that you use) to your 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

For easy pyclewn running I use next bash file: $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

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.txt and rename this file to ~/.gdbinit. After this you can use commands like:

pstring stl_variable
pvector stl_variable

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

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

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


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

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


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


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜