Lucent cscope - home page

## Lucent cscope home page

CSCOPE is the original C program browser for UNIX.

It provides the ability to answer "scoping" questions, like:

- Where is this symbol used?
- Where is it defined?
- Where did this variable get its value?
- What is this global symbol's definition?
- Where is this function in the source files?
- What functions call this function?
- What functions are called by this function?
- Where does the message "out of space" come from?
- Where is this source file in the directory structure?
- What files include this header file?

CSCOPE answers these questions from a symbol database that it builds the first time it is called on the source files. On a subsequent call, CSCOPE rebuilds the database only if a source file has changed or if the list of source files is different. When the database is built the data for the unchanged files is copied from the old database, which makes rebuilding much faster than the initial build.

After the database is ready CSCOPE will display these input fields:

- Find this C symbol:
- Find this definition:
- Find functions called by this function:
- Find functions calling this function:
- Find assignments to:
- Change this grep pattern:
- Find this egrep pattern:
- Find this file:
- Find files #including this file:

Press the TAB key repeatedly to move to the desired input field, type the pattern to search for, and then press the RETURN key. For the first 5 and last 2 input fields, the pattern can be a regcmp(3X) regular expression. If the search is successful, you can use these command characters:

- 1-9 Edit the file containing the displayed line.
- space Display next lines.
- + Display next lines.
- - Display previous lines.
- ^E Edit all lines.
- > Write all lines to a file.
- >> Append all lines to a file.
- < Read lines from a file.
- ^ Filter all lines through a shell command.
- | Pipe all lines to a shell command.

At any time you can use these command characters:

- ^P Move to the previous input field.
- ^A Search again with the last pattern typed.
- ^B Recall previous input field and search pattern.
- ^F Recall next input field and search pattern.
- ^C Toggle ignore/use letter case when searching.
- ^R Rebuild the symbol database.
- ! Start an interactive shell (type ^D to return to cscope).
- ^L Redraw the screen.
- ? Display this list of commands.
- ^D Exit cscope.

To use CSCOPE on all source files in the current directory just type:

- cscope

Alternatively you can provide a list of source files by typing:

- find . -name -name '*.[chlyCGHL]' -print >cscope.files
- cscope -b
- cscope -d

The separate build and access options are shown above.

To support large databases, which would make symbol searches slower, type:

- cscope -b -q
- cscope -d

This builds a SLIMMER inverted index for fast symbol searching.

To use CSCOPE with compressed databases, type:

- cscope -b
- gzip cscope.out
- cscope -d

This is aimed at large centralised database support, where access is provided to compressed databases. As such, CSCOPE will uncompress the database into a temporary directory and access it. If the database is already uncompressed in the temporary directory, it will just access it directly. This improves access time across multiple users of a large compressed database.

MLCSCOPE parses source files written in multiple languages at the same time, based on the file suffix. You can override the file suffix using the multi-lingual option:

- mlcscope -b -m java

The CSCOPE database provides more information than is accessible from the simple questions used by the normal menu. To emulate the CCALLS tool, an extended menu is available with the following input fields:

- Find this type definition:
- Find this preprocessor definition:
- Find parameters of this function:
- Find functions calling this function:
- Find this global definition:
- Find this local definition:
- Find this structure definition:
- Find this file:
- Find this preprocessor include:

To use these fields, type:

- cscope -d -x c

These is also a CSCALLS script to run the CSCOPE CCALLS.

To use an editor with CSCOPE, it must support the +linenum option, e.g.

- VIEWER=vim
- cscope -d
- Editing files runs "vim +linenum file"

- CSCOPE was written by Joe Steffen.
- MLCSCOPE was written by Mark Skeates.
- Compressed database additions were written by Dave Trollope.
- Ccalls emulation was written by Mark Skeates.

CSCOPE and MLCSCOPE are both available from the WWEXPTOOLS web site.

CSCOPE has some older variants available publicly, which originated within Lucent (or AT&T prior to the divestiture), when CSCOPE was submitted to UNIX, when this was owned by AT&T. This early version was sold of as part of UNIX System Labs, which was bought by Santa Cruz Operation and subsequently released as Open Source. As such, version 11.4 was enhanced as Open Source and renamed as version 15. However, Lucent CSCOPE progressed within AT&T and Lucent over the past 15 years, as version 12 and 13 and has significantly more functionality through its use over many years. MLCSCOPE was created to adapt CSCOPE to a Multi-Lingual approach and providing JAVA support.

The public version of CSCOPE is available from SourceForge.

Implementation notes:

Within Lucent, CSCOPE was modified to be very tolerant of a mixture of source files. However, the LEX scanner is so highly tuned that it is rarely productive to change it now, without having other impacts. This was also part of the motivation towards writing MLCSCOPE which uses a separate FLEX scanner for each language, thus separating the concerns.

The source for CSCOPE is version 13. The MULTILINGUAL preprocessor define is used for MLCSCOPE which is version 14.

CSCOPE can be compiled for DOS or WINDOWS by using the PDCURSES package. See the notes.win32 file.

- Copyright: Lucent Public License.
- Documentation: cscope man page, mlcscope man page, cscalls man page.
- Download: source and binaries.
- News: cscope toolnews.