← 返回命令列表

Linux command

cscope 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Build database

cscope -b

Start interactive mode

cscope

Build database recursively

cscope -bR

Build with specific files

cscope -b -i [cscope.files]

Search for symbol

cscope -L0 [symbol]

Find function definition

cscope -L1 [function]

Find functions calling function

cscope -L3 [function]

说明

cscope is a source code browsing tool for C, C++, and Java. It builds a database of symbols, function definitions, and references, enabling fast navigation through large codebases. The interactive interface allows searching for symbol definitions, function callers and callees, text strings, and file inclusions. It integrates with editors like vim and emacs for seamless code navigation.

参数

-b
Build the cross-reference only; do not enter the interactive interface.
-R
Recurse into subdirectories when searching for source files.
-q
Build an inverted index for quicker symbol searches (produces cscope.in.out and cscope.po.out).
-C
Ignore letter case when searching.
-u
Unconditionally build the cross-reference (assume all files have changed).
-d
Do not update the cross-reference.
-i _file_
Read source file names from _file_ instead of the default cscope.files.
-s _dir_
Look in _dir_ for additional source files.
-I _incdir_
Look in _incdir_ before the standard system include directory for `#include` files.
-f _reffile_
Use _reffile_ as the cross-reference file name instead of the default cscope.out.
-L _n_ _pattern_
Line-oriented search. _n_ is the search type number (0–9). Prints matches and exits.
-p _n_
Display the last _n_ path components in list entries (default 1).
-T
Use only the first eight characters to match against C symbols.
-V
Print the cscope version number.

FAQ

What is the cscope command used for?

cscope is a source code browsing tool for C, C++, and Java. It builds a database of symbols, function definitions, and references, enabling fast navigation through large codebases. The interactive interface allows searching for symbol definitions, function callers and callees, text strings, and file inclusions. It integrates with editors like vim and emacs for seamless code navigation.

How do I run a basic cscope example?

Run `cscope -b` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -b do in cscope?

Build the cross-reference only; do not enter the interactive interface.