Cscope

Last updated
cscope
Stable release
15.9 / July 24, 2018;7 years ago (2018-07-24) [1]
Written inC
Operating system Unix, Linux, DOS
Type Programming tool,
for C
License BSD
Website cscope.sourceforge.net   OOjs UI icon edit-ltr-progressive.svg

Cscope is a programming tool developed in the 1980s which uses a text-based user interface that allows computer programmers or software developers to search source code of the programming language C. It is often used on very large projects to aid code comprehension to find source code, functions, declarations, definitions, and regular expressions. As of 2000, cscope is free and released under a BSD license. The original developer of cscope is Joe Steffen.

Contents

History

Joe Steffen began writing cscope in the early 1980s, as an aid to his programming work on a PDP-11. The tool became very popular within Bell Labs, as fellow employees requested more features and improvements, and was used on some large projects with as many as a million lines of source code. [2]

The tool was later made part of the AT&T Unix distribution. That distribution then went through several ownership changes: to Unix System Laboratories, then Novell, then The Santa Cruz Operation (SCO). [2]

Cscope itself is implemented in C. [2] The text interface is built on top of curses. [3] Cscope is well-integrated with vim and Emacs. [3]

In April 2000, SCO announced that it was contributing cscope to open source under a BSD license, while still maintaining it. The move came as SCO was staging several initiatives in the open source and Linux space, [4] even as it was competition from those spaces that would soon lead to SCO's demise. [5]

Petr Sorfa, a software engineer at SCO, became the maintainer of cscope and did the work for the first open source release of it, including porting it to the GNU gcc environment. [6] Sorfa subsequently continued as a maintainer of it, through an association with SourceForge. [7]

Cscope is still used by developers today, some of whom are most accustomed to using vi or other text-based editors, instead of GUI editors. The functions in cscope are available to varying degrees in modern graphical text editors.

Cscope's maintainers later became Hans-Bernhard Bröker and Neil Horman. [8]

The Linux kernel's top-level makefile has a target for building for cscope. [9] Indeed, an O'Reilly Media book about Linux networking published in 2006 recommends use of cscope for browsing the Linux kernel source code. [10] Similarly, a Packt Publishing book about Linux kernel programming published in 2024 has multiple mentions of using cscope in connection with understanding aspects of the kernel source code. [9]

Analysts have also found cscope useful for software audit reviews. According to a 2007 book published by John Wiley & Sons, "Cscope can be invaluable for auditing and is used by many security researchers on a regular basis." [3]

Usage

Cscope is used in two phases. First, a developer builds the cscope database of the source code. The developer can often use find or other Unix tools to get the list of filenames needed to index into a file called cscope.files. The developer then builds a database using the command cscope -b -q -k. The k flag is intended to build a database for an operating system or C library source code. It will not look in /usr/include. Second, the developer can now search those files using the command cscope -d. An index must be rebuilt whenever changes are made to indexed files. [11]

The menus within the cscope user interface allows the developer to search for functions, variables, and preprocessor directives including macros. [12]

There are a number of other options to the cscope command that can tailor its behavior. [12] The cscope database file is known for sometimes becoming large and requiring sufficient disk space. [10]

As created, cscope was created to search content within C code, but it can also be used (with some caveats) for C++ and Java code. [8] Cscope can also process lex and yacc files. [12]

While cscope normally runs on Unix and Linux systems, it has also been built in a version for Microsoft Windows. [3]

Derived software

See also

References

  1. Horman, Neil (24 July 2018). "update configure.in script for 15.9 release" . Retrieved 4 October 2018 via SourceForge.
  2. 1 2 3 "The History of Cscope". SourceForge. Retrieved 2023-09-06.
  3. 1 2 3 4 Anley, Chris; Heasman, John; Lindner, Felix "FX"; Richarte, Gerardo (2007). The Shellcoder's Handbook: Discovering and Exploiting Security Holes (Second ed.). Indianapolis: John Wiley & Sons. pp. 482–483.
  4. "SCO Contributes to the Open Source Community" (Press release). HPCwire. April 21, 2000. Retrieved 2025-08-15.
  5. Pittman, Jennifer (October 16, 2000). "Parting Company: Local high-tech firm prepares to merge, spin off and disappear". Santa Cruz Sentinel. pp. A-1, A-10 via Newspapers.com. See also "'New Caldera' employees to remain in Santa Cruz" sidebar, same by-line, same pages.
  6. "cscope.spec". Debian.org. Retrieved 2025-08-15.
  7. "cscope". Open Invention Network. Retrieved 2025-08-15. See also this page.
  8. 1 2 "Cscope". SourceForge. Retrieved 2011-09-02. The fuzzy parser supports C, but is flexible enough to be useful for C++ and Java[...]
  9. 1 2 Billimoria, Kaiwan N. (2024). Linux Kernel Programming: A comprehensive and practical guide to kernel internals, writing modules, and kernel synchronization (Second ed.). Birmingham, UK: Packt Publishing. pp. 30, also 3, 215, 401, 630, 713, 757.
  10. 1 2 Benvenuti, Christian (2006). Understanding Linux Network Internals. Sebastopol, California: O'Reilly Media. p. 19.
  11. "Using Cscope on large projects (example: the Linux kernel)". SourceForge. Retrieved 2025-08-15.
  12. 1 2 3 Robbins, Arnold (1999). UNIX in a Nutshell: A Desktop Quick Reference for System V Release 4 and Solaris 7 (Third ed.). Sebastopol, California: O'Reilly Media. pp. 37–38.
  13. KScope homepage
  14. Seascope homepage
  15. Gscope homepage
  16. "CCTree - C Call-Tree Explorer -- Cscope based source-code browser; code flow analyzer : Vim online".
  17. Csope homepage