VIM + cscope 達到類似 source Insight 找尋 calls, symbol功能

====這邊以 android linux kernl為範例====
.安裝 vim
 sudo apt-get install vim
.安裝 cscope
 sudo apt-get install cscope
 mkdir -p ~/.vim/plugin
 cd ~/.vim/plugin
 wget http://cscope.sourceforge.net/cscope_maps.vim  
.切換到你的專案路徑後
 cd /home/mark/export/0412_8996_r01107_PostCS9/np8996_postcs9/kernel/msm-3.18
 執行以下指令產生 cscope database
 cscope -bRqk          
 參數說明:
 -b            Build the cross-reference only.
 -q            Build an inverted index for quick symbol searching.
 -R            Recurse directories for files.
 -k            Kernel Mode - don't use /usr/include for #include files.

 會在此目錄下產生 cscope.out , cscope.in.out ,cscope.po.out 三個檔案
 
.在此 cscope.out 路徑下使用 vim 開始某一個 c file
 vim drivers/input/touchscreen/atmel_maxtouch_ts.c
.進入 vim 編輯介面後
 游標停在 function name,按下 ctrl+ \ 後,接著按下以下按鍵就可達到以下功能:
 
    's': 即 Symbol,以此文字串當識別字,列出專案當中所有參考到此識別字的地方,包含定義和引用
    'g': 即 Global,以此文字串當作 global 變數或函數的名稱,跳到專案中定義此 global 變數或函數的地方 (這個功能有另一個與 ctags 相同的快速鍵 Ctrl-])
    'c': 即 Calls,以此文字串當函數名稱,找出所有呼叫到的此函數的函數
    't': 即 Text,列出專案中所有出現此文字串的地方 (包含註解)
    'e': 即 Egrep,以此文字串當 regular expression,用 egrep 方式來搜尋
    'f': 即 File,以此文字串當檔案名稱,開啟此檔案
    'i': 即 Includes,以此文字串當 header 檔名稱,列出所有 include 此檔案的檔案
    'd': 即 calleD,以此文字串當函數名稱,列出此函數所呼叫到的函數

 

 
 
arrow
arrow
    文章標籤
    vim cscope
    全站熱搜

    CuteParrot 發表在 痞客邦 留言(0) 人氣()