生成特定架构内核cscope数据库

tags代码浏览工具

tags工具介绍

一般来说,如果我们想要研究一个c/c++项目的源码,我们首先要做的是为该项目生成tags文件,tags文件种类有很多,比如 ctags、etags、cscope、gtags 等,有关他们的区别可以参考下面链接里的内容:

https://github.com/oracle/opengrok/wiki/Comparison-with-Similar-Tools

ctags使用

ctags官网

提供下载,安装、手册、FAQ等信息

http://ctags.sourceforge.net/

ctags功能

ctags的功能:扫描指定的源文件,找出其中所包含的语法元素,并将找到的相关内容记录下来。

ctags常用命令

ctags的功能:扫描指定的源文件,找出其中所包含的语法元素,并将找到的相关内容记录下来。
img

cscope使用

cscope官网

提供下载,安装、手册、FAQ等信息

http://cscope.sourceforge.net/

cscope功能

cscope是用来浏览源码的工具,可生成符号数据库,以方便快速的搜索和索引。相对ctags提供了更多功能,查找符号调用位置,正则表达式搜索等。

cscope常用命令

cscope -Rbk:迭代遍历子目录生成数据库,但不打开GUI。

gtags使用

gtags官网

http://www.gnu.org/software/global/

gtags功能

它与ctags或etags相似,为源码生成符号索引,并且提供了更多强大的功能,如符号调用位置,正则表达式搜索,符号补全搜索等。

gtas使用

GTAGS    definition database
GRTAGS   reference database
GPATH    path name database$ global //生成符号$ global symbal //搜索符号文件路径$ global -c prefix  //补全符号

生成kernel标签

Linux内核不仅包含了x86架构的函数还包含了如:arm、powerPC等等其他架构的函数,如果直接生成tags文件,将来查找时,多种架构的同名函数会混淆在一起,很不方便。贴心的Linux内核组给准备了tags.sh文件,可以自动生成相应的tags(ctags用),和cscope.out(cscope用)。linux的Makefile里已经帮我们写好了如何生成各种tags,

$ make help
  # 省略其他
  tags/TAGS    - Generate tags file for editors
  cscope    - Generate cscope index
  gtags           - Generate GNU GLOBAL index

由上可以看到,我们只要执行对应的make命令,就可以生成各种tags文件了,make调用Makefile,然后把参数传递给**/script/tags.sh,**tags.sh会接收更多的参数ARCH, SUBARCH, SRCARCH, srctree, src。

  1. ARCH: which architecture to index. You can see all architectures list just by doing ls -l arch/ in your kernel source tree.
  2. SUBARCH: the meaning of this variable depends on your architecture:
    • if ARCH=arm, SUBARCH will be used to determine arch/arm/mach-* and arch/arm/plat-* directories, and these directories will be indexed
    • if ARCH=um, use SUBARCH to specify which architecture you actually want to use in your User-Mode Linux (like SUBARCH=arm or SUBARCH=x86)
    • for the rest of architectures, you can omit this variable
  3. ALLSOURCE_ARCHS: use this to index more than one architecture. Like ALLSOURCE_ARCHS="x86 mips arm" or ALLSOURCE_ARCHS="all". If you only want to index one architecture, omit this variable and use ARCH instead.
  4. COMPILED_SOURCE: set this variable to 1 if you want to index only actually compiled source files. If you want to index all source files, omit setting this variable.
  5. O= (this is actually Makefile parameter): use absolute paths (useful if you want to load created cscope/ctags index files outside of kernel directory, e.g. for development of out-of-tree kernel modules). If you want to use relative paths (i.e. you’re gonna do development only in kernel dir), just omit that parameter.

例如:

内核生成特定架构cscope数据库
make cscope ARCH=x86
make cscope ALLSOURCE_ARCHS=“x86 arm” 生成多种架构

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值