函数调用树生成工具calltree-2.3 使用小记。

----------------------------------------
编译calltree-2.3, 解决名字冲突
----------------------------------------
calltree 自身所带编译晦涩难懂,我弃之不用,改用qmake.
inc/ 目录可以猜测是测试文件,从project 中删除。

编译有如下错误: 这是新编译环境和代码名字冲突造成。
In file included from calltree/calltree.c:33:0:
include/schily.h:110:12: error: conflicting types for ‘fexecve’
 extern int fexecve __PR((const char *, FILE *, FILE *, FILE *,
            ^
In file included from include/unixstd.h:37:0,
                 from calltree/calltree.c:31:
/usr/include/unistd.h:557:12: note: previous declaration of ‘fexecve’ was here
 extern int fexecve (int __fd, char *const __argv[], char *const __envp[])
            ^
In file included from calltree/calltree.c:33:0:
include/schily.h:186:12: error: conflicting types for ‘getline’
 extern int getline __PR((char *, int));
            ^
In file included from calltree/calltree.c:28:0:
/usr/include/stdio.h:678:20: note: previous declaration of ‘getline’ was here
 extern _IO_ssize_t getline (char **__restrict __lineptr,

只有这两个错误,解决了就可以了。
解决办法,把冲突的名字换个名称。
find . -name "*.[c|h]" |xargs sed -i -e "s/fexecve/fexecve_my/"
find . -name "*.[c|h]" |xargs sed -i -e "s/getline/getline_my/"

----------------------------------------
使用calltree, 甚好!
----------------------------------------
calltree 是是静态分析法,它在一定程度上帮我们分析了问题。
当找不到函数入口时,就换一个目录,换一组文件试试。
不指定list, 将生成所有函数调用树。

以kernel为例
calltree -np -b -dot list=start_kernel ./init/*.c > ~/start_kernel.dot
dot -T png start_kernel.dot -o ./testhaha.png
这样就生成了start_kernel的调用图

以sys_setup为例
calltree -b -np list=sys_setup `find ./kernel -name "*.c"`
sys_setup:
|   CMOS_READ
|   |   inb_p
|   |   outb_p
|   bread
|   brelse
|   mount_root
|   panic
|   |   printk
|   |   |   __asm__
|   |   |   va_end
|   |   |   va_start
|   |   |   vsprintf
|   |   |   |   is_digit
|   |   |   |   number
|   |   |   |   |   do_div
|   |   |   |   |   |   __asm__
|   |   |   |   skip_atoi
|   |   |   |   |   is_digit
|   |   |   |   strlen
|   |   |   |   va_arg
|   |   sys_sync
|   printk
|   |   __asm__
|   |   va_end
|   |   va_start
|   |   vsprintf
|   |   |   is_digit
|   |   |   number
|   |   |   |   do_div
|   |   |   |   |   __asm__
|   |   |   skip_atoi
|   |   |   |   is_digit
|   |   |   strlen
|   |   |   va_arg
|   rd_load
|   |   MAJOR
|   |   bread
|   |   breada
|   |   brelse
|   |   memcpy
|   |   printk
|   |   |   __asm__
|   |   |   va_end
|   |   |   va_start
|   |   |   vsprintf
|   |   |   |   is_digit
|   |   |   |   number
|   |   |   |   |   do_div
|   |   |   |   |   |   __asm__
|   |   |   |   skip_atoi
|   |   |   |   |   is_digit
|   |   |   |   strlen
|   |   |   |   va_arg

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值