----------------------------------------
编译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
编译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