{{short description|Text-based programming tool that allows for searching source code written in C}} {{lowercase title}} {{about||the educational curriculum|CSCOPE (education)|the type of radar display|Radar display#C-Scope}}{{Infobox Software | name = cscope | logo = | screenshot = Cscope browsing it's own source code.jpg | caption = | developer = | latest release version = 15.9 | latest release date = {{Start date and age|2018|7|24}}<ref>{{cite web|url=https://sourceforge.net/p/cscope/cscope/ci/612a539b585ccdb70a1261652954f579ccedb270/|title=update configure.in script for 15.9 release|via=SourceForge|first=Neil|last=Horman|date=24 July 2018|accessdate=4 October 2018}}</ref> | latest preview version = | latest preview date = | operating system = Unix, Linux, DOS | genre = Programming tool,<br />for C | license = BSD | programming language = C }}
'''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.
==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.<ref name="hist">{{Cite web |title=The History of Cscope |url=https://cscope.sourceforge.net/history.html |access-date=2023-09-06 |publisher=SourceForge}}</ref>
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).<ref name="hist"/>
Cscope itself is implemented in C.<ref name="hist"/> The text interface is built on top of curses.<ref name="anley-etal"/> Cscope is well-integrated with vim and Emacs.<ref name="anley-etal"/>
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,<ref name="sco-2000">{{cite press release | url=https://www.hpcwire.com/2000/04/21/sco-contributes-to-the-open-source-community/ | title=SCO Contributes to the Open Source Community| publisher=HPCwire | date=April 21, 2000 | access-date=2025-08-15}}</ref> even as it was competition from those spaces that would soon lead to SCO's demise.<ref>{{cite news | url=https://www.newspapers.com/clip/76095220/ | title=Parting Company: Local high-tech firm prepares to merge, spin off and disappear | author-first=Jennifer | author-last=Pittman | newspaper=Santa Cruz Sentinel | date=October 16, 2000 | pages=A-1, A-10 | via=Newspapers.com}} See also "'New Caldera' employees to remain in Santa Cruz" sidebar, same by-line, same pages.</ref>
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.<ref>{{cite web | url=https://sources.debian.org/src/cscope/15.8b-2/packages/cscope.spec/ | title=cscope.spec | publisher=Debian.org | access-date=2025-08-15}}</ref> Sorfa subsequently continued as a maintainer of it, through an association with SourceForge.<ref>{{cite web | url=https://www.openinventionnetwork.com/linux-system-definition/table-10/cscope/ | title=cscope | publisher=Open Invention Network | access-date=2025-08-15}} See also [https://sources.debian.org/src/cscope/15.7a-3.2/AUTHORS/ this page].</ref>
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.<ref name="main"/>
The Linux kernel's top-level makefile has a target for building for cscope.<ref name="billimoria"/> Indeed, an O'Reilly Media book about Linux networking published in 2006 recommends use of cscope for browsing the Linux kernel source code.<ref name="benvenuti">{{cite book | url=https://books.google.com/books?id=ALapr7CvAKkC&pg=PA19&dq=cscope&hl=en&newbks=1&newbks_redir=0&sa=X&ved=2ahUKEwjD7YCS0IyPAxWol4kEHT9NJ0oQuwV6BAgLEAg#v=onepage&q=cscope&f=false | title=Understanding Linux Network Internals | first=Christian | last=Benvenuti | publisher=O'Reilly Media | location=Sebastopol, California | year=2006 | page=19 }}</ref> 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.<ref name="billimoria">{{cite book | title=Linux Kernel Programming: A comprehensive and practical guide to kernel internals, writing modules, and kernel synchronization | first=Kaiwan N. | last=Billimoria | publisher=Packt Publishing | location=Birmingham, UK | year=2024 | edition=Second | pages= 30; also 3, 215, 401, 630, 713, 757 }}</ref>
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."<ref name="anley-etal">{{cite book | url=https://books.google.com/books?id=aidqstv38G8C&pg=PA482&dq=sco+cscope+open+source&hl=en&newbks=1&newbks_redir=0&sa=X&ved=2ahUKEwiF4az-oY2PAxXHl4kEHUUbEsMQuwV6BAgGEAo#v=onepage&q=sco%20cscope%20open%20source&f=false | title=The Shellcoder's Handbook: Discovering and Exploiting Security Holes | first=Chris | last=Anley | first2= John | last2=Heasman | first3=Felix "FX" | last3=Lindner | first4=Gerardo | last4=Richarte | publisher=John Wiley & Sons | location=Indianapolis | year=2007 | edition=Second | pages= 482–483}}</ref>
==Usage== Cscope is used in two phases. First, a developer builds the cscope database of the source code. The developer can often use <code>find</code> or other Unix tools to get the list of filenames needed to index into a file called <code>cscope.files</code>. The developer then builds a database using the command <code>cscope -b -q -k</code>. The <code>k</code> flag is intended to build a database for an operating system or C library source code. It will not look in <code>/usr/include</code>. Second, the developer can now search those files using the command <code>cscope -d</code>. An index must be rebuilt whenever changes are made to indexed files.<ref>{{cite web | url=https://cscope.sourceforge.net/large_projects.html | title=Using Cscope on large projects (example: the Linux kernel) | publisher=SourceForge | access-date=2025-08-15}}</ref>
The menus within the cscope user interface allows the developer to search for functions, variables, and preprocessor directives including macros.<ref name="nutshell">{{cite book | url=https://books.google.com/books?id=hjSqwEKIyOAC&pg=PA37&dq=cscope&hl=en&newbks=1&newbks_redir=0&sa=X&ved=2ahUKEwjD7YCS0IyPAxWol4kEHT9NJ0oQuwV6BAgHEAg#v=onepage&q=cscope&f=false | title=UNIX in a Nutshell: A Desktop Quick Reference for System V Release 4 and Solaris 7 | first=Arnold | last=Robbins | publisher=O'Reilly Media | location=Sebastopol, California | year= 1999 | edition=Third | pages=37–38 }}</ref>
There are a number of other options to the cscope command that can tailor its behavior.<ref name="nutshell"/> The cscope database file is known for sometimes becoming large and requiring sufficient disk space.<ref name="benvenuti"/>
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.<ref name="main">{{cite web | url=https://cscope.sourceforge.net/ | title=Cscope | publisher=SourceForge | access-date=2011-09-02 | quote="The fuzzy parser supports C, but is flexible enough to be useful for C++ and Java[...]"}}</ref> Cscope can also process lex and yacc files.<ref name="nutshell"/>
While cscope normally runs on Unix and Linux systems, it has also been built in a version for Microsoft Windows.<ref name="anley-etal"/>
==Derived software== * KScope runs on KDE and integrates the Kate text editor. The KScope project is no longer being maintained.<ref>[https://kscope.sourceforge.net/ KScope homepage]</ref> * Seascope runs on PyQt4 and integrates the Scintilla text editor.<ref>[http://code.google.com/p/seascope/ Seascope homepage]</ref> * Gscope is based on GTK2 and GTK3 and integrates with multiple text editors.<ref>[https://github.com/tefletch/gscope/wiki Gscope homepage]</ref> * CCTree is a native Vim plugin that integrates with the Vim editor and offers functions similar to KScope and Seascope.<ref>{{Cite web|url=http://www.vim.org/scripts/script.php?script_id=2368|title = CCTree - C Call-Tree Explorer -- Cscope based source-code browser; code flow analyzer : Vim online}}</ref> * Csope is a fork with an altered TUI.<ref>[https://github.com/agvxov/csope Csope homepage]</ref>
==See also== *ctags *Cross-reference (X-Ref) *LXR Cross Referencer, Web-based source code browsing with hyperlinks *OpenGrok
==References== {{reflist}}
==External links== *{{Official website}} *[http://www.lemis.com/grog/software/source-code-navigation.php Source code navigation tools]
Category:Code comprehension tools Category:Code navigation tools Category:Static program analysis tools Category:Linux programming tools Category:Unix programming tools Category:Software using the BSD license