CSCOPE(1) INTERACTIVE UNIX System CSCOPE(1)
NAME
cscope - interactively examine a C program
SYNOPSIS
cscope [-f reffile] [-i namefile] [[-I incdir]] [-d] [files]
DESCRIPTION
cscope is an interactive screen-oriented tool that helps
programmers browse through C source code.
By default, cscope examines the C, yacc, and lex source
files in the current directory and builds a symbol cross-
reference. It then uses this table to find references to
symbols (including C preprocessor symbols), function
declarations, and function calls.
cscope builds the symbol cross-reference the first time it
is used on the source files for the program being browsed.
On a subsequent invocation, cscope rebuilds the cross-
reference only if a source file has changed or the list of
source files is different. When the cross-reference is
rebuilt, the data for the unchanged files are copied from
the old cross-reference, which makes rebuilding much faster
than the initial build.
The following options can appear in any combination:
-f reffile
Use reffile as the cross-reference file name instead of
the default cscope.out.
-i namefile
Get the list of files (file names separated by spaces,
tabs, or newlines) to browse from namefile. If this
option is specified, cscope ignores any files appearing
on the command line.
-I incdir
Look in incdir (before looking in INCDIR, the standard
place for header files that is normally /usr/include)
for any #include files whose names do not begin with /
and that are not specified on the command line or in
namefile above. (The #include files may be specified
with either double quotes or angle brackets.) The inc-
dir directory is searched in addition to the current
directory (which is searched first) and the standard
list (which is searched last). If more than one
occurrence of -I appears, the directories are searched
in the order they appear on the command line.
-d Do not update the cross-reference.
Requesting the Initial Search
Rev. C Software Development Set Page 1
CSCOPE(1) INTERACTIVE UNIX System CSCOPE(1)
After the cross-reference is ready cscope will display this
menu:
List references to this C symbol:
Edit this function or #define:
List functions called by this function:
List functions calling this function:
List lines containing this text string:
Change this text string:
Press the TAB key repeatedly to move to the desired input
field, type the text to search for, and then press the
RETURN key.
Issuing Subsequent Requests
If the search is successful, any of these single-character
commands can be used:
1-9 Edit the file referenced by the given line
number.
SPACE Display next lines.
+ Display next lines.
- Display previous lines.
^e Edit all lines.
> Append the displayed list of lines to a file.
At any time these single-character commands can also be
used:
TAB Move to next input field.
RETURN Move to next input field.
^m Move to next input field.
^p Move to previous input field.
. Search with the last text typed.
^r Rebuild the cross-reference.
! Start an interactive shell (type ^d to return to
cscope).
^l Redraw the screen.
? Display this list of commands.
^d Exit cscope.
Note: If the first character of the text to be searched for
matches one of the above commands, escape it by typing a \
(backslash) first.
Substituting New Text for Old Text
After the text to be changed has been typed, cscope will
prompt for the new text, and then it will display the lines
containing the old text. Select the lines to be changed
with these single-character commands:
1-9 Mark or unmark the line to be changed.
* Mark or unmark all displayed lines to be changed.
SPACE Display next lines.
Rev. C Software Development Set Page 2
CSCOPE(1) INTERACTIVE UNIX System CSCOPE(1)
+ Display next lines.
- Display previous lines.
a Mark all lines to be changed.
^d Change the marked lines and exit.
ESCAPE Exit without changing the marked lines.
! Start an interactive shell (type ^d to return to
cscope).
^L Redraw the screen.
? Display this list of commands.
ENVIRONMENT VARIABLES
EDITOR Preferred editor, which defaults to vi(1).
HOME Home directory, which is automatically set at
login.
SHELL Preferred shell, which defaults to sh(1).
TERM Terminal type, which must be a screen terminal.
VIEWER Preferred file display program [such as pg(1)],
which overrides EDITOR (see above).
VPATH An ordered list of directory names, separated by
colons. It can be used by cscope to search for
both source and header files, but the two types
of files have different orders of search. If
VPATH is set, cscope searches for source files in
the directories specified; if it is not set,
cscope searches only in the current directory.
cscope searches for header files in the following
order: (1) if VPATH is set, in directories
specified in VPATH and if VPATH is not set, in
the current directory; (2) in directories speci-
fied by the -I option (if they exist); and (3) in
the standard location for header files (normally
/usr/include).
FILES
cscope.out Symbol cross-reference file, which is put in
the home directory if it cannot be created in
the current directory.
ncscope.out Temporary file containing new cross-reference
before it replaces the old cross-reference.
INCDIR Standard directory for #include files (usually
is /usr/include).
WARNINGS
cscope recognizes function definitions of the form:
fname blank ( args ) white arg_decs white {
where:
fname is the function name,
blank is zero or more spaces or tabs, not including
newlines,
Rev. C Software Development Set Page 3
CSCOPE(1) INTERACTIVE UNIX System CSCOPE(1)
args is any string that does not contain a " or a new-
line,
white is zero or more spaces, tabs, or newlines, and
arg_decs are zero or more argument declarations. arg_decs
may include comments and white space.
It is not necessary for a function declaration to start at
the beginning of a line. The return type may precede the
function name; cscope will still recognize the declaration.
Function definitions that deviate from this form will not be
recognized by cscope.
Rev. C Software Development Set Page 4