安装cscope后,执行以下命令:
# cd /usr/src/linux
# find . -name '*.h' -o -name '*.c' > cscope.files
# cscope -b -k -q
# ctags -R
# echo 'cs add .' >> /etc/vimrc
此后进入/usr/src/linux,使用vim就支持代码跟踪了。
执行 :cs help 可以显示cscope帮助信息:
cscope commands:
add : Add a new database (Usage: add file|dir [pre-path] [flags])
find : Query for a pattern (Usage: find c|d|e|f|g|i|s|t name)
c: Find functions calling this function
d: Find functions called by this function
e: Find this egrep pattern
f: Find this file
g: Find this definition
i: Find files #including this file
s: Find this C symbol
t: Find assignments to
help : Show this message (Usage: help)
kill : Kill a connection (Usage: kill #)
reset: Reinit all connections (Usage: reset)
show : Show connections (Usage: show)
常用命令:
:cs find g hash #查找hash函数或变量的定义
:cs find e hash #查找包含hash字段的代码行
常用快捷键:
:ctrl + ] #跳转到光标所在符号的定义位置
:ctrl +T #回到上一次的位置
Have fun!
没有评论:
发表评论