April 12, 2007 Archives

2007-04-12

vimgdb

There are many scripts to use gdb with vim. But the best and most useful implementation is the clewn.It implements full gdb support in the vim editor: breakpoints, watch variables, gdb command completion, assembly windows, etc. Clewn uses netbeans interface to connect to vim and runs concurrently.
There is also the patch vimGdb which is developed by the same people. They share the same base source code set to interface with gdb. The main difference is clewn runs as a seperate process but it has some features vimGdb doesn't have:
  • display of gdb expression values in a balloon
  • gdb run commands do input and output on the clewn terminal, while vimgdb users must use the gdb 'tty' or 'attach' commands to control the debuged program input/output
  • support of $cdir in the gdb directory list, allowing vim to access the names of the source files compilation directories as stored with the program debugging information.

There is an ebuild for clewn in the sunrise overlay. You need to emerge gvim with the netbeans USE flag to use it. I wrote an ebuild for the newest version 1.10 and bumped it, hopefully someone will review it and put it to reviewed/ soon.
I also wanted to try the vimGdb patch so I made some changes to the vim.eclass and added gdb USE flags to vim and gvim. The patch applies cleanly among with other vim patches in the gentoo tree.
To use the vimGdb :call gdb("") when you want to do debugging. You might want to put 'set autochdir' in your vimrc so that vim will change to the working directory and find other source files of the program as well. Here is a screenshot:
vimgdb example
The source code is from app-misc/slmon which has some problems smiley. There is a breakpoint on the blueline. vim and gvim ebuilds with gdb USE flag are in my overlay if you want to try. Emerge it and do
:help gdb
from within vim to learn how to use it. Happy vimming!