- 작성시간 : 2012/09/27 14:07
- 퍼머링크 : mcchae.egloos.com/10941135
- 덧글수 : 4
필요에 따라 이클리스와 같은 GUI IDE 환경이 필요한 경우도 있지만,
어떤 경우에는 그냥 터미널 에서 gdb 디버깅을 잘 할 수 있는 환경이 필요하기도 합니다.
가장 쉽게 생각할 수 있는 것이 VIM에서 플러그인으로 GDB를 이용하는 것이며,
다음과 같이 설치할 수 있습니다.

소스포지에 clewn 이라는 이름으로 올라와 있군요.
$ wget http://downloads.sourceforge.net/project/clewn/clewn/clewn-1.15/clewn-1.15.tar.gz
명령으로 다운받습니다.
아래와 같은 라이브러리가 필요합니다. (우분투인 경우)
$ sudo apt-get install vim-gtk libncurses5-dev libreadline-dev
다운받은 clewn-1.15.tar.gz을 풀어 해당 폴더로 들어가서,
$ ./configure
$ make
$ sudo make install
로 설치를 합니다.
필요한 파일을 복사해줍니다.
$ mkdir -p ~/.vim/plugin ~/.vim/doc ~/.vim/macros ~/.vim/syntax
$ 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/
테스트 파일을 다음과 같이 만들어 봅니다.
$ vi test.c
int main(int argc, char *argv[]) {
int i;
int s;
s = 0;
for (i = 0; i < 10; ++i) {
s = s + 1;
}
}
$ gcc -g -o test test.c
test 라는 실행파일을 만듦니다.
이제 gvim으로 디버깅하기 위하여,
$ clewn -va test.c -ga test

그러면 위와 같은 gvim 창이 나타납니다.
간단히 멈추고 싶은 곳에 커서를 이동하여 Control+B 를 누른다음,
대문자 R을 눌러 프로그램을 수행하면 됩니다.
마우스 포인터를 해당 변수에 가져다 놓으면 값이 툴팁으로 나타납니다.
다음과 같은 명령이 지원됩니다.
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
어느분께는 도움이 되셨기를...
덧글
-_-
문제되면 삭제하겠습니다.
를 더 자주 사용하게 되더군요...
도움이 되셨다니 저의 보람입니다~ ^^