cscope(CP) 6 January 1993 cscope(CP) Name cscope - interactively examine a C program Syntax 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 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 new- lines) 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 speci- fied with either double quotes or angle brackets.) The incdir direc- tory 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 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> or <Return> 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. + Display next lines. - Display previous lines. a Mark all lines to be changed. ^d Change the marked lines and exit. <Esc> 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(C). HOME Home directory, which is automatically set at login. SHELL Preferred shell, which defaults to sh(C). TERM Terminal type, which must be a screen terminal. VIEWER Preferred file display program (such as pg(C)), which over- rides EDITOR (see above). VPATH An ordered list of directory names, separated by colons. It is used by cscope to search for both source and header files. 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: if VPATH is set, in directories specified in VPATH and if VPATH is not set, in the current directory, in directories specified by the -I option (if they exist), and 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 (args) arg_decs { ... } where: fname is the function name, followed by zero or more spaces or tabs (except a newline character). args is any string that does not contain a double-quotation (") or a newline, followed by zero or more spaces or tabs. argdecs are zero or more argument declarations. argdecs 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.