相關資源‎ > ‎

cscope

The website of Cscope is cscope.sourceforge.net

Steps to create cscope

cd $ProjectDirectory
find . -name '*.c' -o -name '*.h' -o -name '*.cc'  > cscope.files


Exclude all files in ./python_kit path  (A easier way is to change properties of directory 
chmod 000 directory)
find .  ! -path './python_kit/*' -name '*.c' -o -name '*.h' -o  -name '*.cc'  > cscope.files
find .  -wholename './python_kit' -prune -o -wholename './pin' -prune  -o -wholename './pin_kit' -prune  -name '*.c' -o -name '*.h' -o  -name '*.cc'  > cscope.files

Use >> to add additional files
find /usr/include/X11/ -name '*.h' >> cscope.filese

#Create database
cscope -b -q -R -i cscope.files
or

cscope -b -q -R

The -q flag is used to build a faster (but larger) database. -R tells Cscope to search for symbols recursively. -b builds the database only, but does not start the Cscope browser. -i cscope.files specifies the list of source files. The output of this command will be a set of files in your current directory: cscope.in.out, cscope.out, and cscope.po.out.

Setting $CSCOPE_DB environment variable
CSCOPE_DB=/foo/cscope.out; export CSCOPE_DB

Change CSCOPE editor

export CSCOPE_EDITOR=`which emacs`

Run cscope
cscope -d
The -d flag tells Cscope not to regenerate the database (which you already did in the previous step). Within the Cscope browser, type ? to see the help page, and type Ctrl-d to exit. The browser will show you a list of the searches you can perform in your code:

Find this C symbol:
Find this global 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:

Reference
Cscope Tutorial http://www.cs.washington.edu/education/courses/cse451/12sp/tutorials/tutorial_cscope.html

Comments