Cscope
Encyclopedia
cscope is a console mode or text-based graphical interface that allows computer programmers or software developers to search C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...

 (there is limited support for other languages). It is often used on very large projects to find source code, functions, declarations, definitions and regular expressions given a text
Text file
A text file is a kind of computer file that is structured as a sequence of lines of electronic text. A text file exists within a computer file system...

 string. cscope is free and available under a BSD License. The original developer of cscope is Joe Steffen.

History

The history of the tool goes back to the days of the PDP-11
PDP-11
The PDP-11 was a series of 16-bit minicomputers sold by Digital Equipment Corporation from 1970 into the 1990s, one of a succession of products in the PDP series. The PDP-11 replaced the PDP-8 in many real-time applications, although both product lines lived in parallel for more than 10 years...

, but it is still used by developers who are accustomed to using the vi
Vi
vi is a screen-oriented text editor originally created for the Unix operating system. The portable subset of the behavior of vi and programs based on it, and the ex editor language supported within these programs, is described by the Single Unix Specification and POSIX.The original code for vi...

 or vim
Vim (text editor)
Vim is a text editor written by Bram Moolenaar and first released publicly in 1991. Based on the vi editor common to Unix-like systems, Vim is designed for use both from a command line interface and as a standalone application in a graphical user interface...

 editor or other text-based editors (instead of GUI
Graphical user interface
In computing, a graphical user interface is a type of user interface that allows users to interact with electronic devices with images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances and...

-based editors). The functionality within Cscope is available to varying degrees in modern graphical source editors.

Mode of use

cscope is used in two phases. First a developer builds the cscope database. The developer can often use find
Find
In Unix-like and some other operating systems, find is a command-line utility that searches through one or more directory trees of a file system, locates files based on some user-specified criteria and applies a user-specified action on each matched file...

or other unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 tools to get the list of filenames that they need to index into a file called cscope.files. The developer then builds a database using the command cscope -b -q -k. Second, the developer can now search those files using the command cscope -d. Often an index needs to be re-built whenever changes are made to files.

In software development it is often very useful to be able to find the callers of a function because this is the way to understand how code works and what other parts of the program expect from a function. cscope can find the callers and callees of functions, but it is not a compiler and it does that by searching the text for keywords. This has the disadvantages that macros and duplicate symbol names can generate an unclear graph. There are other programs that can extract this information by parsing
Parsing
In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a text, made of a sequence of tokens , to determine its grammatical structure with respect to a given formal grammar...

 the source code or looking at the generated object files.

cscope was created to search content within C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 files, but it can also be used (with some limitations) for C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 and Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 files.

GUI

A GUI frontend called Kscope under KDE
KDE
KDE is an international free software community producing an integrated set of cross-platform applications designed to run on Linux, FreeBSD, Microsoft Windows, Solaris and Mac OS X systems...

 is available which in addition to easing the usage integrates the KATE text editor.

A PyQT4 GUI frontend called Seascope is available which in addition to easing the usage integrates the scintilla text editor.

CCTree is a native Vim Plugin that integrates with the Vim editor and offers functionalities similar to Kcsope and Seascope.

See also

  • ctags
    Ctags
    Ctags is a program that generates an index file of names found in source and header files of various programming languages.Depending on the language,functions,variables,class members,macros and so onmay be indexed....

  • X-Ref
    Cross-reference
    A cross-reference is an instance within a document which refers to related or synonymous information elsewhere, usually within the same work. To cross-reference or to cross-refer is to make such connections. The term "cross-reference" is often abbreviated as x-ref, xref, or, in computer science,...

  • LXR Cross Referencer - Web-based source code browsing with Hyperlinks.
  • OpenGrok
    OpenGrok
    OpenGrok is a source code search and cross reference engine. It helps you search, cross-reference and navigate your source tree. It can understand various program file formats and version control histories like Monotone, SCCS, RCS, CVS, Subversion, Mercurial, Git and Bazaar...


External links

  • cscope's page on SourceForge
    SourceForge
    SourceForge Enterprise Edition is a collaborative revision control and software development management system. It provides a front-end to a range of software development lifecycle services and integrates with a number of free software / open source software applications .While originally itself...

    (including a semi-detailed history)
  • Source code navigation tools
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK