2015年12月3日 星期四

cscope

sudo apt-get install cscope
cat > ~/.vimrc << eof
if has('cscope')
  set cscopetag cscopeverbose

"  if has('quickfix')
"    set cscopequickfix=s-,c-,d-,i-,t-,e-
"  endif

  cnoreabbrev csa cs add
  cnoreabbrev csf cs find
  cnoreabbrev csk cs kill
  cnoreabbrev csr cs reset
  cnoreabbrev css cs show
  cnoreabbrev csh cs help

  command -nargs=0 Cscope cs add \$VIMSRC/src/cscope.out \$VIMSRC/src
endif
eof
cd ~/.vim/plugin/; wget http://cscope.sourceforge.net/cscope_maps.vim

I have the  cscope_maps.vim file(check turtoial [1]), and the .vimrc thing from Vim Tips Wiki [2], but removed the quick fix part, as suggested by the [3]. After removed the quick fix part, all duplicated symbol will ask for selection, even for tags!!!

cscope -Rbk -s XXXX
-R     Recurse subdirectories during search for source files.
-b     Build the cross-reference only.-q     Enable  fast  symbol  lookup  via an inverted index.
-k     ``Kernel Mode'', turns off the use of the  default  include  dir (usually  /usr/include) when building the database, since kernel source trees generally do not use it.
-sdir  Look in dir for additional source files. This option is  ignore if source files are given on the command line.
-q     Enable  fast  symbol  lookup  via an inverted index.

-C     Ignore letter case when searching.
-d     Do not update the cross-reference.
Cscope interactive
^d: Exit cscope.
: Alternate between the menu and the list of matching lines

Contrl-\+
       c: Find functions calling this function (caller)
       d: Find functions called by this function (callee)
       e: Find this egrep pattern
       f: Find this file
       g: Find this definition
       i: Find files #including this file
       s: Find this C symbol
       t: Find this text string




[1] Vim/Cscope tutorial
http://cscope.sourceforge.net/cscope_vim_tutorial.html

Vi with Cscope
http://web.missouri.edu/~hantx/Tools/vi/TonyViNotes/node11.html
  1. Building database for Cscope:
    $ cscope -Rb
    This command makes the Cscope parse all the subdirectories (-R option) and exit without entering awkward Cscope interface.
  2. List all the uses of the symbol under the cursor:
    Ctrl+\s
    That is Control-backslash and then 's'. Select one of items in the list and hit enter, you will jump to the that use. Ctrl+t jump back.
  3. Find functions that under the cursor
    Ctrl+\d
    That is Control-backslash and then 'd'.
  4. Open the file with filename under cursor
    Ctrl+\f
    That is Control-backslash and then 'f'.
  5. Jump back from most recent jumping-off point:
    Ctrl+t
[2] Cscope - Vim Tips Wiki - Wikia
http://vim.wikia.com/wiki/Cscope
A Collection of Vi Tips
http://users.nccs.gov/~fwang2/tools/vinotes.html
Cscope Tutorial
https://courses.cs.washington.edu/courses/cse451/12sp/tutorials/tutorial_cscope.html

[3] Vi + Cscope: using "cscope find c function" in vim, finds multiple results, how to go next - Stack Overflow
http://stackoverflow.com/questions/4399519/vi-cscope-using-cscope-find-c-function-in-vim-finds-multiple-results-how

linux - How to set vim as default cscope editor? - Stack Overflow
http://stackoverflow.com/questions/28121485/how-to-set-vim-as-default-cscope-editor

Using Cscope on large projects (example: the Linux kernel)
http://cscope.sourceforge.net/large_projects.html

沒有留言: