2006年12月18日星期一

A tool for call graphs--Egypt

今天继续看tty_io.c的代码,代码中定义了很多操作buffer的函数,它们之间有相互调用,看着真混乱。于是,就想找一个能生成函数调用图的软件,尝试了doxygen,发现只能生成C++的类关系图,对于C没作用。然后,找到这个,感觉功能比较简单,好上手,先试试。。。

Egypt is a simple tool for creating call graphs of C programs.

egypt [--omit function,function,...] [--include-external] ... | dotty -
egypt [--omit function,function,...] [--include-external] ... | dot

omit
Omit the given functions from the call graph. Multiple function names may be given separated by commas.
include-external
Include calls to external functions in the call graph. A function is considered external if it is not defined in any of the input files. For example, functions in the standard C library are external. By default, such calls are not shown. Even with this option, only direct calls will be shown; there is no way to show indirect calls to external functions.

Generating the RTL file
make clean
make CFLAGS=-dr
Viewing the CALL GRAPH
egypt foo.c.00.rtl | dotty -

优点和缺点:使用gcc分析source code,使用 dotty生成图像,使用简单;但是必须要生成相应的rtf文件,对于很大的工程,也许相当麻烦。

没有评论: