作者:李明华
最近在看一个开源代码bind过程中,该代码是由纯C语言编写的,函数间调用关系特别的复杂。想对整体代码有一个大概的了解,这样就需要了解代码中主要的相关函数间调用关系,发现一个开源的小工具calltree,在linux下能够将代码中函数调用关系生成调用树,并可以选择生成dot语言文件,通过dot工具生成调用关系图。下面介绍一下calltree工具:
calltree基本命令:calltree -gb -np –m *.c
calltree所有的命令可以通过
calltree
–help查看,如下图:
[root@localhost i686-linux-cc]# ./calltree
-help
Usage: calltree
[calltree_options] [cpp_options] file1..filen
Options:
-b
Print a vertial Bar at each tab stop.
-r
Invert the structure of the tree.
-f
Flattened (cumulative) tree.
-g
Print file names past procedure names.
-m
Call structure for main only.
-p
Use C Preprocessor (default).
-np
Don't use C Preprocessor.
-u
List all f