【源码阅读方法论】

7次阅读

共计 583 个字符,预计需要花费 2 分钟才能阅读完成。

周生政
valgrind 查看调用关系
在学习开源代码时,我们希望有个工具能够给我们全局的视角而不过早的陷入细节的泥淖中。读书可以跳读,读代码也是可以跳读的。valgrind 可以生成整个调用关系链。该关系链指导我们,迅速定位到我们关心的细节。
安装
ubuntu 系统
1 apt-get install valgrind
2 apt-get install kcachegrind
mac 系统
1 brew install qcachegrind –with-graphviz
使用
使用 valgrind 生成调用关系
1 valgrind –tool=callgrind –trace-children=yes –callgrind-out-file=/data/opt/callgrind.out.1111 ./nginx
使用 qcachegrind 查看调用关系
qcachegrindhttps://raw.githubusercontent…
可能遇到的问题
Error: can not open cache simulation output file
保证写的目录有写的权限,可以创建一个目录,赋值为 777,在该目录下启动命令 valgrind –tool=callgrind –trace-children=yes /data/server/nginx/sbin/nginx, 使用 kill 终止程序 kill SIGINT pid

正文完
 0