分类:
2010-03-01 12:53:42
To build a C/C++ integrated development environment, u can just like this:
1 Install GVIM
#apt-get install vim-gnome
2 Install clewn
(1)download clewn here:
(2)compile and install clewn
#tar xzvf clewn-1.15.tar.gz
#cd clewn-1.15
#./configure && make &&make install
NOTE: may be some one will be suffered from the dependency problem during their installing. If your machine tell you that you need readline, then install libreadline5-dev
#apt-get install libreadline5-dev
3 Configure
Then, copy following files to ~/.vim:
#cp /usr/local/share/vim/vimfiles/clewn.vim ~/.vim/plugin/
#cp /usr/local/share/vim/vimfiles/doc/clewn.txt ~/.vim/doc/
#cp /usr/local/share/vim/vimfiles/macros/clewn_mappings.vim ~/.vim/macros/
#cp /usr/local/share/vim/vimfiles/syntax/gdbvar.vim ~/.vim/syntax/
NOTE: if ~/.vim/plugin or ~/.vim/macros not exist, mkdir and create it.
4 How to debug
#clewn -va test.c
(gdb)file test
Now, you can debug your program on gvim. For example, you can click the line you want to set break point. And then press CTRL+B, then, break point is set. SHIFT+r(that is capital R)It will run and stop at your break point SHIFT+s(that is capital S)It will step And watch your variable, input following on gvim:split
Then the window will be split, and then click the variable you want to watch, and press C+J, then you can see the variable appears in another window. To do this, you also can input the following on your terminal(gdb)
createvar yourvar
“youvar” represents the variable you want to watch. Following is the default shortcuts
List of default key mappings:
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
cursor position: ~
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
mouse pointer position: ~
CTRL-P print the value of the variable defined by the mouse pointer
position
CTRL-X print the value that is referenced by the address whose
value is that of the variable defined by the mouse pointer
position
CTRL-K set a breakpoint at assembly address shown by mouse position
CTRL-H clear a breakpoint at assembly address shown by mouse position
CTRL-J add the selected variable at mouse position to the watched
variables window
ref doc: