Rescued by cscope

17 06 2008

I have been working on mozilla codebase quite sometime. Its a huge codebase with millions of lines of code. A simple counting on the numbers of lines in *.cpp files for 3.0b2 release accounts 1778818 lines of code[1]. Most of the time I need to search for function definitions – I used grep -r xyz * as that was the only option I know until recently I have started using cscope which came as a rescue. cscope maintains its own database of symbol definition of the code. You can find the symbol, find a symbol definition, a file , a text within source code. Configuration of the cscope database is simple.

Step 1 . Make a directory to store the cscope db say $HOME/mycscope/mozilla

Step 2. cd /

Step 3. say $HOME/mozilla is the home directory of the project that contains the source files(*.c,*.cpp,*.h)

run find $HOME/mozilla -name “*.cpp” >> $HOME/mycscope/mozilla/cscope.files

run find $HOME/mozilla -name “*.h” >> $HOME/mycscope/mozilla/cscope.files etc.

It will simply populate the cscope.files used by cscope to create the data with the desired filenames.

Step 4. run in $HOME/mycscope cscope -b -q -k which will create the database cscope.out

Step 5. run cscope -d from $HOME/myscope and start searching and browsing code.

In case you want to invoke it from vim add the following lines to your .vimrc

set nocsverb ; supress cscope logging messages
cscope add $HOME/mycscope/cscope.out

You should be able to invoke cscope from vim window now . eg try :cs find 1 XYZ

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1. sum=0;for i in `find . -name “*.cpp” -exec wc -l {} \; |cut -d ‘ ‘ -f 1` ; do sum=`expr $sum + $i`; done; echo $sum


Actions

Information

Leave a comment