cscope 사용하기

* ctags 만으로는 지역변수나 전역변수 함수가 사용된 곳은 찾기 힘들때 사용.

1. cscope 다운받기 ( ex : apt-get install cscope )

2. mkcscope.sh 파일 작성
=======================================================================================
#!/bin/sh
rm -rf cscope.files cscope.files

find . \( -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.s' -o -name '*.S' \) -print > cscope.files

cscope -i cscope.files
=========================================================================================
 
chmod 755 mkcscope.sh

mv mkcscope.sh /usr/local/bin

명령어를 입력한 후 소스, 헤더 파일이 있는곳으로 가서 (include or linux-2.4) mkcscope.sh 를 실행

cscope.out 파일이 생성됨.

.vimrc 에 추가할 내용
=========================================================================================

"===============  cscope 설정 =========================
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb

if filereadable("./cscope.out")
        cs add cscope.out
else
        cs add /usr/include/cscope.out
endif
set csverb

* .vimrc 에 cscope 단축키 관련 추가

"============== cscope 함수와 단축키 설정 ============

" find this C symbol
func! Css()
        let css = expand("<cword>")
        new
        exe "cs find s ".css
        if getline(1) == " "
                exe "q!"
        endif
endfunc
nmap ,css :call Css()<cr>

"find finctions calling this function
func! Csc()
        let csc = expand("<cword>")
        new
        exe "cs find c ".csc
        if getline(1) == " "
                exe "q!"
        endif
endfunc
nmap ,csc :call Csc()<cr>

"find functions called by this function
func! Csd()
        let csd = expand("<cword>")
        new
        exe "cs find d ".csd
        if getline(1) == " "
                exe "q!"
        endif
endfunc
nmap ,csd :call Csd()<cr>

"find this definition
func! Csg()
        let csg = expand("<cword>")
        new
        exe "cs find g ".csg
        if getline(1) == " "=======================================================================================
                exe "q!"
        endif
endfunc
nmap ,csg :call Csg()<cr>

===========================================================================================

이 글과 관련있는 글을 자동검색한 결과입니다 [?]

by simsiss | 2008/09/02 11:34 | Linux | 트랙백(1) | 덧글(0)

트랙백 주소 : http://simsiss.egloos.com/tb/778814
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from 소심남 블로그 하다. at 2009/06/27 00:02

제목 : cscope 사용하기
* ctags 만으로는 지역변수나 전역변수 함수가 사용된 곳은 찾기 힘들때 사용. 1. cscope 다운받기 ( ex : apt-get install cscope ) 2. mkcscope.sh 파일 작성 ======================================================================================= #!/bin/sh rm -rf cscope.files cscope.files find ......more

:         :

:

비공개 덧글