概述
1. calltree
Download source codes from Ref(1) or (2), and compile it.
Then copy the "calltree" utility to /usr/local/bin/
You also need a special script which called tree2dot-filter.sh
to make life easy, and it can be get from Ref(3).
By using the following example, you will get fuction calling relations
in a picture test_calltree.jpg.
sandbox$ which calltree tree2dot-filter.sh
/usr/local/bin/calltree
/usr/local/bin/tree2dot-filter.sh
sandbox$ cat test_calltree.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$ calltree -mb -np test_calltree.c
main:
| do_something_finally
| | printf
| do_something_firstly
| | free
| | malloc
| printf
sandbox$ calltree -mb -np test_calltree.c | tree2dot-filter.sh > test_calltree.dot
sandbox$ dot -Tjpg test_calltree.dot -o test_calltree.jpg
2. Graphviz and CodeViz
Download source codes from Ref(6) and (7), and compile them.
Then copy the "gcc-graph", "genfull", and "gengraph" utility to /usr/local/bin/
By using the following example, you will get fuction calling relations
in a picture main.png.
sandbox$ which gcc-graph genfull gengraph
/usr/local/bin/gcc-graph
/usr/local/bin/genfull
/usr/local/bin/gengraph
sandbox$ gcc-graph test_calltree.c
sandbox$ genfull
sandbox$ gengraph --output-type "png" -f main
Reference:
(1) http://directory.fsf.org/project/calltree/
(2) http://linux.softpedia.com/progDownload/calltree-Download-971.html
(3) http://download.csdn.net/source/3567869
(4) http://www.linuxsir.org/bbs/printthread.php?t=246389
(5) http://blog.csdn.net/cqbamboo/article/details/6736627
(6) http://www.graphviz.org/
(7) http://www.csn.ul.ie/~mel/projects/codeviz/
(8) http://www.ibm.com/developerworks/cn/linux/l-graphvis/
(9) http://blog.csdn.net/cqbamboo/article/details/6739024
最后
以上就是悲凉大叔为你收集整理的How to use calltree and Graphviz/CodeViz的全部内容,希望文章能够帮你解决How to use calltree and Graphviz/CodeViz所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复