参考
http://blog.csdn.net/cqbamboo/article/details/6736627
http://blog.csdn.net/younggift/article/details/9238383
64bit ubuntu12.04 编译通过
无法上传附件, 附已编译好的文件+源码包 地址: http://download.csdn.net/detail/elitemouse/8217185
1 解压
tar -xvf calltree-2.3.tar.bz2
2 编译 直接执行make 报错如下 :
2.1
RULES/rules1.top:234: incs/Dcc.x86_64-linux: No such file or directory
RULES/rules.top:39: RULES/x86_64-linux-cc.rul: No such file or directory
RULES/rules.cnf:56: incs/x86_64-linux-cc/Inull: No such file or directory
RULES/rules.cnf:57: incs/x86_64-linux-cc/rules.cnf: No such file or directory
p incs/x86_64-linux-cc
make: p: Command not found
make: [incs/x86_64-linux-cc/Inull] Error 127 (ignored)
/bin/sh: 1: cannot create incs/x86_64-linux-cc/Inull: Directory nonexistent
make: *** [incs/x86_64-linux-cc/Inull] Error 2
解决 :cp RULES/i686-linux-cc.rul RULES/x86_64-linux-cc.rul
原因:问题是calltree的这个版本里头没有X86064位对应的Makefile规则文件,可以直接把i686-linux-cc.rul复制为x86_64-linux-cc.rul
2.2 继续make , 报错:
In file included from stdio/io.h:29:0,
from stdio/cvmod.c:21:
../include/schily.h:110:12: error: conflicting types for ‘fexecve’
/usr/include/unistd.h:558:12: note: previous declaration of ‘fexecve’ was here
../include/schily.h:186:12: error: conflicting types for ‘getline’
/usr/include/stdio.h:675:20: note: previous declaration of ‘getline’ was here
make[2]: *** [OBJ/x86_64-linux-cc/cvmod.o] Error 1
make[2]: Leaving directory `/work/leilong.su/software/calltree-2.3/libschily'
make[1]: *** [all] Error 2
还有缺少头文件之类的一堆错误
解决:
find . -name "*.[c|h]" -exec grep getline -nH {} \;
find . -name "*.[c|h]" -exec grep fexecve -nH {} \;
将找到的文件 getline fexecve都改个名字
原因:[http://www.3null.org/?p=439],他说,"在比较新的内核(glibc库)上编译,会出现编译不过的问题。具体现象大概像下面这个样子..." 这个样子,就是你上面看到的样子。"具体解决办法有两种,一种就是给glibc打patch,另一种就麻烦点,把冲突的命名手动都改了。"
关于解决方案,打patch,怎么打啊,手动改命名,怎么改啊。此处说来话长,我略过吧。总之,我们就知道,应该这样手动命名:把calltree源代码里所有声明、定义、调用这两个函数的地方,都把这两个函数改个名字。只要新的名字不再与posix的重名,那就没冲突了,编译就能通过了。
3 使用
以kernle为例
calltree -np -b -dot list=start_kernel ./init/*.c > ~/start_kernel.dot
cd ~
dot -T png start_kernel.dot -o ./testhaha.png
calltree时会打印出各种already defined , 仍然可以生成dot文件, 不管它就是了
这样就生成了start_kernel的调用图