When you're working on a large software project, it's extremely difficult to keep all the bits and pieces in your head. cscope is designed to help eliminate all your needless searching through files, enabling you to quickly search for:

  • all references to a symbol
  • global definitions
  • functions called by a function
  • functions calling a function
  • text string
  • regular expression pattern
  • a file
  • files including a file

cscope is primarily designed to work with C, though it works reasonably well for C++ (I generally rely on tools like ack when cscope fails for C++).

Using cscope

Before you can start using cscope, you need to build the database for your source tree. I have created an alias in my .bashrc file so I don't have to remember all of the required arguments for generating a new cscope database:

alias cscope-gen="cscope -bkqR"

Once you have a database, you can start the program by running cscope -d. You should see the following options appear:

Find this C symbol:
Find this function definition:
Find functions called by this function:
Find functions calling this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:

And now you're ready to search! Navigate through the options with the up/down keys, and hit enter to execute the search. The default quit keystroke is ctrl+q.

cscope integrates very nicely with vim: more details can be found in the links below.

Further Reading:
cscope/vim tutorial
Using cscope on large projects