LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

cscope

source code browsing tool for C, C++, and Java

TLDR

Build database for current directory
$ cscope -b
copy
Start interactive mode
$ cscope
copy
Build database recursively from subdirectories
$ cscope -bR
copy
Build with specific files
$ cscope -b -i [cscope.files]
copy
Search for symbol
$ cscope -L0 [symbol]
copy
Find function definition
$ cscope -L1 [function]
copy
Find functions calling function
$ cscope -L3 [function]
copy

SYNOPSIS

cscope [options] [files]

DESCRIPTION

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.

PARAMETERS

-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.

CONFIGURATION

cscope.files

List of source files to include in the database (one path per line).
cscope.out
Default cross-reference database file produced by cscope.

SEARCH TYPES

0: Find this C symbol1: Find this global definition2: Find functions called by this function3: Find functions calling this function4: Find this text string5: Change this text string6: Find this egrep pattern7: Find this file8: Find files #including this file9: Find assignments to this symbol

CAVEATS

Database needs rebuilding after code changes (unless `-q` incremental mode is used). Works best with C-style languages. Large codebases may have slow initial indexing. Some modern C/C++ features may confuse the parser.

HISTORY

cscope was developed at Bell Labs in the late 1970s by Joe Steffen and was distributed as part of AT&T's Programmer's Workbench. It was released as open source by SCO in 2000 and is now maintained on SourceForge. It remains popular for its speed and tight vim integration.

SEE ALSO

ctags(1), vim(1), grep(1)

Copied to clipboard
Kai