Chinaunix首页 | 论坛 | 博客
  • 博客访问: 377909
  • 博文数量: 17
  • 博客积分: 247
  • 博客等级: 二等列兵
  • 技术积分: 175
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-08 19:04
个人简介

他山之石,可以攻玉。

文章分类

全部博文(17)

文章存档

2022年(1)

2020年(1)

2019年(2)

2018年(1)

2017年(1)

2013年(4)

2012年(7)

我的朋友

分类: IT业界

2013-01-10 18:18:00

一、cscope安装

   1. 软件下载:
   2. 软件安装: 
         1. ./configure
         2. make 
         3. make install

二、cscope配置

   1. 修改vim配置文件~/.vimrc。你也可以修改/etc/vimrc使用所有用户都使用本配置文件。我的整个.vimrc配置文件如下下:
set nu
set ts=4
set hlsearch
set ignorecase
"set autoindent
"set cindent
set fileencodings=utf-8,gbk
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle
""""""""""""""""""""""""""""""""""""""""""""""""""""
"cscope settings
"""""""""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst 
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
endif
set csverb
endif
nmap s :cs find s =expand("")
nmap g :cs find g =expand("")
nmap c :cs find c =expand("")
nmap t :cs find t =expand("")
nmap e :cs find e =expand("")
nmap f :cs find f =expand("")
nmap i :cs find i ^=expand("")$
nmap d :cs find d =expand("")

 注:红色部是cscope的配置。

三、cscope使用

1、使用如下cscope.sh建立索引文件
#!/bin/sh
#filename:cscope.sh


if [ "$1" == "kernel" ]
then
echo "Build cscope engineering information,Please wait!"
find  . ! -type l -regex ".*\.\(c\|cpp\|cc\|h\|hpp\|java\|xml\|S\)" > cscope.files
cscope -b -k -q -i cscope.files
else
echo "Build cscope engineering information,Please wait!"
find  . ! -type l -regex ".*\.\(c\|cpp\|cc\|h\|hpp\|java\|xml\|S\)" > cscope.files
cscope -b -R -q -i cscope.files
fi

 2、 打开任意.c文件或其它代码文件,使用如下命令:
         1. Ctrl+]将跳到光标所在变量或函数的定义处 Ctrl+T返回
         2. :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 ---- 查找包含本文件的文
阅读(700) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~