Tuesday, February 18, 2014

Cscope

Install

  • make sure vim is installed
  • wget http://cscope.sourceforge.net/cscope_maps.vim
  • mv cscope_maps.vim ~/.vim/plugin/
  • download http://sourceforge.net/projects/cscope/files/ & change the current directory into the downloaded directory
    • ./configure
    • make
    • sudo make install

Start

  • cscope -R -b

Usage

  • ctrl-t: side tab
  • ctrl-o: next jump
  • ctrl-i: previous jump
  • ctrl-]: go into

More

Reference from this site:
  • :cs find s ----查找C語言符號,即查找函數名、宏、枚舉值等出現的地方
  • :cs find g ----查找函數、宏、枚舉等定義的位置,類似ctags所提供的功能
  • :cs find d ----查找本函數調用的函數
  • :cs find c ----查找調用本函數的函數
  • :cs find t: ---查找指定的字符串
  • :cs find e ----查找egrep模式,相當於egrep功能,但查找速度快多了
  • :cs find f ----查找並打開文件,類似vim的find功能
  • :cs find i ----查找包含本文件的文

Bug Found

On Mac OS X 10.9, cscope is having error if the working path contains "space". The error is recorded below:
Error detected while processing /Users/heron/.vim/plugin/cscope_maps.vim:
line   42:
cs_read_prompt EOF: Not a directory
E609: Cscope error: cscope: cannot read trailer offset from file cscope.out
Press ENTER or type command to continue

Adds

It's time to trace the linux kernel code!