calltree安装和简单使用

下载

地址 :https://github.com/htdy/calltree

编译

文件根目录下执行

cp ./Gmake.linux /usr/bin/Gmake
cp RULES/i686-linux-cc.rul RULES/x86_64-linux-cc.rul
find . -name “.[c|h]" |xargs sed -i -e “s/fexecve/fexecve_calltree/”
find . -name "
.[c|h]” |xargs sed -i -e “s/getline/getline_calltree/”
find . -name “.[c|h]" -exec grep getline -nH {} ;
find . -name "
.[c|h]” -exec grep fexecve -nH {} ;
make
ln -s 文件根目录 /bin/calltree

使用

calltree -h
下面介绍一下各选项:
list 开始函数
-b 就是那个竖线了,很直观地显示缩进层次。
-g 打印内部函数的所属文件名及行号,外部函数所属文件名和行号也是可打印的,详man
-np 不要调用c预处理器,这样打印出的界面不会很杂乱,但也可能会产生错误哦,如果我们只看函数的调用关系的话,不会有大问题。
-m 告诉程序从main开始
还有一个重要的选项是listfunction ,缩写是lf,用来只打印某个函数中的调用,用法是: lf=your_function
depth=#选项: 例如: calltree -gb -np -m bind9/bin/named/*.[c.h] depth=2 > codecalltree.txt

文本输出

calltree -bg list=“ev_run” *.c

图像输出

apt-get install graphviz
calltree -dot list=“ev_run” *.c > ev_run.dot
dot -Tgif ev_run.dot -o ev_run.gif

calltree -dot -np -b list=start_kernel depth=100 find ./init/ ./kernel/ -name "*.c" > maps.dot
dot -T png maps.dot -o maps.png
以linux内核效果展示
http://62.234.45.38:86/maps.png

Guess you like

Origin blog.csdn.net/qq_38595432/article/details/118384518