티스토리 툴바



* 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>

===========================================================================================
저작자 표시 비영리 변경 금지
Posted by simsiss

TRACKBACK http://simsiss.tistory.com/trackback/20 관련글 쓰기

댓글을 달아 주세요