首先,去cflow官网 http://www.gnu.org/s/cflow/ 下载,并编译
./configure
make
make install
然后,就可以使用了,下面举一个例子。
sandbox$ which cflow
/usr/local/bin/cflow
sandbox$ cat test-cflow.c
#include <stdio.h>
#include <stdlib.h>
void do_something_firstly()
{
char *str = NULL;
str = malloc(100);
free(str);
}
void do_something_finally()
{
printf("Bingo!\n");
}
int main()
{
printf("Hello, call tree :-)\n");
do_something_firstly();
do_something_finally();
return 0;
}
sandbox$ cflow test-cflow.c
main() <int main () at test-cflow.c:17>:
printf()
do_something_firstly() <void do_something_firstly () at test-cflow.c:4>:
malloc()
free()
do_something_finally() <void do_something_finally () at test-cflow.c:12>:
printf()