The compilation, installation and use of the VIM plugin Cscope tool
1. Download: http://download.chinaunix.net/download.php?id=3536&ResourceID=1900
2. Compiling
#./configure
#make
Make has failed:
[Email protected]:~/.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 is 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 is 03, very old, to change a new version cscope-15.8a.tar.gz
Perform:
./configure
Make
Make install
Compilation passed, installation successful
3. Use
Enter the kernel directory:
cd/study/linux-git/linux-3.18.3
Perform
Cscope-rbq
Set tags=/study/linux-git/linux-3.18.3
: CS Add Cscope.out
: CS Find C Writel
In this way, you can see where there is a definition of writel.
Refer to the following: Vi/vim use advanced: Programmer's weapon –cscope
(http://blog.csdn.net/xiangpingli/article/details/44007021)
This command generates three files: Cscope.out, Cscope.in.out, Cscope.po.out. Where Cscope.out is the basic symbol index, the latter two files are generated using the "-q" option, which speeds up the indexing speed of the cscope.
Using Cscope in Vim is very simple, first call the "cscope Add" command to add a cscope database, and then you can call the "cscope find" command to find it. VIM supports 8 types of cscope query functions, as follows:
S: Find the C language symbol, that is, find the function name, macro, enumeration value and other occurrences of the place
G: Find the location defined by functions, macros, enumerations, and similar functions provided by ctags
D: Find functions called by this function
C: Find functions that call this function
T: finds the specified string
E: Find Egrep mode, equivalent to Egrep function, but find much faster
F: Find and open files, like Vim's find function
I: Find files that contain this file
For example, we want to find the function that calls the Do_cscope () function in source code, and we can enter: ": CS Find C Do_cscope",
After the carriage return found that no matching function was found, there may be no function call Do_cscope (). We then enter ": CS find S Do_cscope" to find out where the C symbol appears, and now vim lists all the locations where the symbol appears.
VIMRC about the Cscope interface, use the time to add to the end of the. 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
The compilation, installation and use of the VIM plugin Cscope tool