Install cscope:
Generate cscope and ctag file for x86:
##################################
#!/bin/bash
# File name: genctags.sh
# Usage: genctags.sh x86
LNX=.
ARCH=x86
if [ ! -z "$1" ];then
ARCH="$1"
fi
if [ "$2" != "tag" ];then
echo "Gen cscope file for $ARCH ..."
find $LNX \
-path "$LNX/arch/*" ! -path "$LNX/arch/$ARCH*" -prune -o \
-path "$LNX/include/asm-*" ! -path "$LNX/include/asm-$ARCH*" -prune -o \
-path "$LNX/tmp*" -prune -o \
-path "$LNX/Documentation*" -prune -o \
-path "$LNX/scripts*" -prune -o \
-path "$LNX/drivers*" -prune -o \
-name "*.[chxsS]" -print > cscope.files
cscope -b -q -k
fi
echo "Gen ctags file ($ARCH)..."
EXCLUDE_PATH=`find . -path "$LNX/arch/*" ! -path "$LNX/arch/$ARCH*" -prune`
EXCLUDE_PATH2=
for path in $EXCLUDE_PATH
do
EXCLUDE_PATH2="$EXCLUDE_PATH2 --exclude=$path"
done
ctags -R $EXCLUDE_PATH2
###############################################
For vim:
Download http://cscope.sourceforge.net/cscope_maps.vim to ~/.vim/plugin/
try it:
vim ./init/main.c
move the cursor to a symbol then...
ctrl + ] -- goto definition
[ + d -- show macro definition (if it is a macro)
ctrl + o -- goto previous position
ctrl + i -- goto next position
ctrl + \ s -- list usages
ctrl + shift + space -- list usages and pops a select to a new window (ctrl+w o to close)
search tag "main":
: ta main
search tags including "main":
:ta /main
search tags beginning with "main":
:ta /^main
Ref: