List of key mappings in 'gdb_mappings.vim':

  • <Space> launch the interactive gdb input-line window
  • CTRL-Z send an interrupt to GDB and the program it is running
  • B info breakpoints
  • L info locals
  • A info args
  • S step
  • I stepi
  • CTRL-N next: next source line, skipping all function calls
  • X nexti
  • F finish
  • R run
  • Q quit
  • C continue
  • W where
  • CTRL-U up: go up one frame
  • CTRL-D down: go down one frame
  • CTRL-B set a breakpoint on the line where the cursor is located
  • CTRL-E clear all breakpoints on the line where the cursor is located
  • CTRL-P Normal mode: print value of word under cursor
    • Visual mode: GDB command "createvar" selected expression, see |gdb-variables|
  • CTRL-X print value of data referenced by word under cursor

CTRL-B and CTRL-E operate both on source code and on disassembled code in
assembly buffers.

Using vimgdb:

vimGdb is a vim plugin which integrates gdb tool into vim editor environment.
It allows you to debug your program and trace your source codes simultaneously;
this combination makes vim an even better environment for C/C++ development.
The following is steps to install and configure vimGdb plugin:
(I am using Ubuntu 7.04 (Feisty Fawn) on Intel Pentium 4 3.0 GHz HT platform)
1) Get vim source and gdb patch
2) Untar these two files to the same directory (say, ~/vim_tools) and patch the vim source
    $ cd ~/vim_tools
    $ tar -xvjf vim-7.1.tar.bz2
    $ tar -xvzf vimgdb71-1.12.tar.gz
    $ patch -d vim71 —backup -p0 < vimgdb/vim71.diff

3) Recompile vim
    if you don't have ncurses library installed, get and install it first
    One way to do it is to make manually
    Get ncurses-5.6.tar.gz or here
    $ tar xvzf ncurses-5.6-tar.gz
    $ cd ncurses-5.6
    $ ./configure —prefix=/usr
    $ sudo make
    $ sudo make install
    then compile vim (updated on 20070830 for cscope support)

    $ cd ~/vim_tools/vim71/src
    $ sudo make
    $ sudo make install
    $ cd ~/vim_tools/vim71/src
    $ ./configure —enable-gdb —enable-cscope —enable-multibyte
       —enable-xim —enable-fontset —with-features=huge
    $ make
    $ sudo make install
    replace the old vi with our newly built one
    $ sudo mv /usr/bin/vi /usr/bin/vi.old
    $ sudo ln -s /usr/local/bin/vim /usr/bin/vi

    * add "set title" in .vimrc if titlebar of your terminal
       doesn't get updated dynamically
4) Install vimgdb runtime
    if you don't know what your vim runtime directory is,
    you can use ":set runtimepath?" command in vim to find out
    (usually it's $HOME/.vim)
    untar "vimgdb_runtime.tgz" into the runtime directory
    $ cd ~/vim_tools
    $ tar xzvf vimgdb_runtime.tgz -C ~/.vim
    after this, you should have the following files in ~/.vim

5) Start vimgdb via vim

copy the following lines into your .vimrc file (usually in ~/)

syntax enable " enable syntax highlighting
set previewheight=24 " set gdb window initial height
run macros/gdb_mappings.vim " source key mappings listed in this
" document
set asm=0 " don't show any assembly stuff
set gdbprg=/usr/bin/gdb " set GDB invocation string (default 'gdb')

* the gdb mappings would be invoked by default when vim starts;
you can turn this off by commenting out the last line in
"~/.vim/macros/gdb_mappings.vim", then toggle it on by pressing F7

" call s:Toggle()

6) Setup help document for vimgdb

go to "~/.vim/doc" and start vim and run the ":helptags ."

7) Start vim and hit space key to bring up vimgdb input window and enjoy it

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License