Friday, July 13, 2007

Cscope with CTAGS

Run this in the main Source code directory
to build the data base
cscope -b -q -R
-b = build
-q = qick
-R = recursive
Note by default cscope takes .c and .h only.  If files are in .cpp .cc or .java then use cscope.files
find . -name '*.cc' > cscope.files
find . -name '*.c' >> cscope.files

build cscope Database as

cscope -b
or cscope -b -q -k

-k = kernel mode
To open Cscope for code browsing :
cscope -d
-d = do not build

it will open menu to search
use Tab to change the fields
for CTAGS

find . -name "*.h" > cscopefileslist.txt
find . -name "*.c" >> cscopefileslist.txt

ctags -aBF -L cscopefileslist.txt
explaination
-a Append output to an existing tags file.
-B Use backward searching patterns (?...?).
-F Use forward searching patterns (/.../) (default).---------
# Ctrl-] Find the tag under the cursor.
# Ctrl-T Return to previous location before jump to tag.

Change default editor of cscope to VIM :
By default cscope opens file through Vi to change that do these in .bashrc
VISUAL=/usr/bin/vim;
export VISUAL;
EDITOR=/usr/bin/vim;
export EDITOR;

To set default shell as BASH change .profile

1 comment:

Amit K Sharma (xamitx) said...

add cscope -b -i cscopefileslist.txt