码迷,mamicode.com
首页 > 系统相关 > 详细

vim插件cscope工具的编译、安装与使用

时间:2015-03-01 23:48:38      阅读:708      评论:0      收藏:0      [点我收藏+]

标签:

vim插件cscope工具的编译、安装与使用

1. 下载:http://download.chinaunix.net/download.php?id=3536&ResourceID=1900
2. 编译
# ./configure 
#make
make 失败了:
root@linux:~/.vim/cscope-15.5# make
make  all-recursive
make[1]: Entering directory ‘/root/.vim/cscope-15.5‘
Making all in doc
make[2]: Entering directory ‘/root/.vim/cscope-15.5/doc‘
make[2]: Nothing to be done for ‘all‘.
make[2]: Leaving directory ‘/root/.vim/cscope-15.5/doc‘
Making all in src
make[2]: Entering directory ‘/root/.vim/cscope-15.5/src‘
/bin/bash ../ylwrap `test -f ‘fscanner.l‘ || echo ‘./‘`fscanner.l .c fscanner.c -- :  
Makefile:310: recipe for target ‘fscanner.c‘ failed
make[2]: *** [fscanner.c] Error 1
make[2]: Leaving directory ‘/root/.vim/cscope-15.5/src‘
Makefile:199: recipe for target ‘all-recursive‘ failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory ‘/root/.vim/cscope-15.5‘
Makefile:154: recipe for target ‘all‘ failed
make: *** [all] Error 2


3.cscope-15.5是03年的,非常老,换个新的版本cscope-15.8a.tar.gz
执行:
./configure
make
make install
编译通过,安装成功
3. 使用
进入内核目录:
cd /study/linux-git/linux-3.18.3
执行
cscope -Rbq 
set tags=/study/linux-git/linux-3.18.3
:cs add cscope.out
:cs find c writel
这样,就可以看到是哪里有writel的定义了


如下内容参考自:vi/vim使用进阶: 程序员的利器 – cscope
(http://blog.csdn.net/xiangpingli/article/details/44007021)
这个命令会生成三个文件:cscope.out, cscope.in.out, cscope.po.out。其中cscope.out是基本的符号索引,后两个文件是使用”-q“选项生成的,可以加快cscope的索引速度。
在vim中使用cscope非常简单,首先调用”cscope add“命令添加一个cscope数据库,然后就可以调用”cscope find“命令进行查找了。vim支持8种cscope的查询功能,如下:


s: 查找C语言符号,即查找函数名、宏、枚举值等出现的地方
g: 查找函数、宏、枚举等定义的位置,类似ctags所提供的功能
d: 查找本函数调用的函数
c: 查找调用本函数的函数
t: 查找指定的字符串
e: 查找egrep模式,相当于egrep功能,但查找速度快多了
f: 查找并打开文件,类似vim的find功能
i: 查找包含本文件的文件
例如,我们想在source的源代码中查找调用do_cscope()函数的函数,我们可以输入:”:cs find c do_cscope“,
回车后发现没有找到匹配的功能,可能并没有函数调用do_cscope()。我们再输入”:cs find s do_cscope“,查找这个C符号出现的位置,现在vim列出了这个符号出现的所有位置。
vimrc中关于cscope接口的设置,使用时候加在.vimrc末尾:


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
  set csprg=/usr/local/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




vim插件cscope工具的编译、安装与使用

标签:

原文地址:http://blog.csdn.net/xiangpingli/article/details/44008353

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!