View current gdb frame in vim. Vim will automatically open files and set cursor position according to gdb context.
This is gdb plugin that will synchronize vim with gdb (running in separate terminal) to show you (with vim) the context of what is going on in gdb session. Vim will automatically update cursor position on break, step by step execution, backtrace examination, thread changes and many more.
Vim has the ability to run as server, executing remote commands. VimView is a Python plugin that exploit this feature.
- Gdb with python support compiled in. Test with
python-interactivecommand under gdb. - Vim/gvim with
clientserveroption compiled in. Test it withvim --version- look for+clientserver. Note that vim needs to be run under X11/XWindow to be able to communicate (even the terminal version). You could try to run server:
vim --servername test
and remotely send command to it:
vim --servername test --remote ~/.vimrc
To start, run vim in server mode:
vim --servername gdb
And (in another terminal) under gdb:
source /path/to/vimview.py
set vimview-onstop on
set vimview-onprompt on
You could also add this to your .gdbinit.
Now start debugging and you will see the magic.
Gdb commands available:
vorvim- show current frame in vimvbreak- set breakpoint under current vim cursor positionvbreak [no]- show breakpoint position in vim
Gdb settings available:
set vimview-server [name]- change vim server name to use, default isgdbset vimview-command [name]- change command to execute, default isvimset vimview-onstop [on/off/auto]- show current position in vim whenever debugging stops; if sets toautoit will be activated only whenVIMSERVERvariable is setset vimview-onprompt [on/off/auto]- show position on every prompt print (only when position was updated); if sets toautoit will be activated only whenVIMSERVERvariable is setset vimview-tabs [on/off]- if on, each new file will be opened in another vim tab
Environment variables:
VIMSERVER- sets the server name, it is read only when this plugin is sourced
Convenience variables (to be used with other commands, e.g print $vw()):
$vw()- word under vim cursor$ve()- expression under vim cursor$vf()- absolute vim file path$vl()- vim cursor line number$vfl()- vim file:line, equivalent to$vf():$vl()
Debug options:
pi vimView.debug = True- print vim commands beeing executed