Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1680077
  • 博文数量: 1493
  • 博客积分: 38
  • 博客等级: 民兵
  • 技术积分: 5834
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-19 17:28
文章分类

全部博文(1493)

文章存档

2016年(11)

2015年(38)

2014年(137)

2013年(253)

2012年(1054)

2011年(1)

分类:

2012-05-09 08:35:05

原文地址:源代码阅读工具----Cscope 作者:himrpei

Using Cscope on large projects(example:the Linux kernel)

Procedure:
1.Figure out where you want to put your Cscope database files.
  /home/himrpei/work/cscope

2.Generate cscope.files with a list of files to be scanned.
  For some projects, you may want to include every C source file in the project's directories in your Cscope database. In that case you can skip this step, and just use 'cscope -R' in the project's top-level directory to build your Cscope database.   But if there's some code that you wish to exclude,and/or your project contains C++ or Java source code(by default Cscope only parses files with the .c,.h,.y,or .l extensions), you'll need to genetate a file called cscope.files, which should contain the name of all files that you wish to have Cscope scan(one file name per line).
  1. LNX=/home/jru/linux-2.4.18
  2. cd /
  3. find $LNX \
  4. -path "$LNX/arch/*" ! -path "$LNX/arch/i386*" -prune -o \
  5. -path "$LNX/include/asm-*" ! -path "$LNX/include/asm-i386*" -prune -o\
  6. -path "$LNX/tmp*" -prune -o \
  7. -path "$LNX/Documentation*" -prune -o \
  8. -path "$LNX/scripts*" -prune -o \
  9. -path "$LNX/drivers*" -prune -o \
  10. -name "*.[chxsS]" -print > /home/himrpei/cscope/cscope.files

3.Generate the Cscope database.
  1. cd /home/himrpei/cscope #the directory with 'cscope.files'
  2. cscope -b -q -k
 <
 The -b flag tells Cscope to just build the database, and not launch the Cscope GUI.
 The -q causes an additional, 'inverted index' file to be created, which makes searches run much faster for large databases.
 Finally, -k sets Cscope's 'kernel' mode--it will not look in           /usr/include for any header files that are #include in your source file(this is maily useful when you are using Cscope with operating system and/or C library source code, as we are here).
 >

4.Using the database.
Use Cscope to search within the editor.
Use the standalone Cscope curses-based GUI:
  1. cscope -d
This tells Cscope not to regenerate the database.Otherwise you'll have to wait while Cscope checks for modified files, which can take a while for large projects, even when no files have changed.
If you accidentally run 'cscope', without any flags, you will also cause the database to be recreated from scratch without the fast index or kernel modes being used, so you'll probably need to rerun your original cscope command above to correctly recreate the database.

5.Regenerating the database when the source code changes.
If there are new files in your project, rerun your 'find' command to update cscope.files if you're using it.
Then simple invoke cscope the same way(and in the same directory)as you did to generate the database initially(i.e,cscope -b -q -k).
阅读(289) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~