您的位置:首页 > 其它

How to use calltree and Graphviz/CodeViz

2011-09-01 23:14 381 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: