$ sudo apt-get install cscope $ cscope --help $ Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir] [-p number] [-P path] [-[0-8] pattern] [source files] -b Build the cross-reference only. -C Ignore letter case when searching. -c Use only ASCII characters in the cross-ref file (don't compress). -d Do not update the cross-reference. -e Suppress the <Ctrl>-e command prompt between files. -F symfile Read symbol reference lines from symfile. -f reffile Use reffile as cross-ref file name instead of cscope.out. -h This help screen. -I incdir Look in incdir for any #include files. -i namefile Browse through files listed in namefile, instead of cscope.files -k Kernel Mode - don't use /usr/include for #include files. -L Do a single search with line-oriented output. -l Line-oriented interface. -num pattern Go to input field num (counting from 0) and find pattern. -P path Prepend path to relative file names in pre-built cross-ref file. -p n Display the last n file path components. -q Build an inverted index for quick symbol searching. -R Recurse directories for files. -s dir Look in dir for additional source files. -T Use only the first eight characters to match against C symbols. -U Check file time stamps. -u Unconditionally build the cross-reference file. -v Be more verbose in line mode. -V Print the version number. Please see the manpage for more information. cscope 常用选项; -R: 在生成索引文件时,搜索子目录树中的代码; -b: 只生成索引文件,不进入cscope的界面; -q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度; -k: 在生成索引文件时,不搜索/usr/include目录; -i: 指定源文件来源位置; -Idir: 在-I选项指出的目录中查找头文件; -u: 扫描所有文件,重新生成交叉索引文件; -C: 在搜索时忽略大小写; -P path: 在以相对路径表示的文件前加上的path; :cs find 选项: s: 查找C语言符号,即查找函数名、宏、枚举值等出现的地方; g: 查找函数、宏、枚举等定义的位置,类似ctags所提供的功能; d: 查找本函数调用的函数; c: 查找调用本函数的函数; t: 查找指定的字符串; e: 查找egrep模式,相当于egrep功能,但查找速度快多了; f: 查找并打开文件,类似vim的find功能; i: 查找包含本文件的文件; ~/.gvimrc中的配置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " cscope setting """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has("cscope") set csprg=/usr/bin/cscope set csto=1 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out endif set csverb endif nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR> 操作指令: # 在源代码根目录下输入 $ find . -name "*.[ch]" -o -name "*.cpp" -o -name "*.hpp" > cscope.file $ cscope -Rbkq $ gvim <file> #打开一个文件; $ :cs add cscope.out $ :cs find g <pattern> #搜索一个宏变量的定义位置;