ngx_cycle的初始化及Graphviz dot使用 生成图

nginx源码分析—全局变量ngx_cycle的初始化
可以看
http://www.oschina.net/question/234345_42061
其中有个神器:
用 Graphviz 可视化函数调用
https://www.ibm.com/developerworks/cn/linux/l-graphvis/

http://www.ibm.com/developerworks/cn/linux/l-graphvis/

qemu
http://www.ibm.com/developerworks/cn/linux/l-qemu/


apt-get install graphviz
装dot
#!/bin/sh
gcc -g -finstrument-functions includefunction.c test.c instrument.c -o test
./test
pvtrace test
dot -Tjpg graph.dot -o graph.jpg


[root@killinux dot]# cat test.c 
#include <stdio.h>
#include "hao.h"
int heihei(){
	test2();
}

int haha(){
	heihei();
	printf("haha this is haha\n");
}
int main()
{
  heihei();
  haha();
  printf("Hello World\n");
  return 0;
}
----------------------------
[root@killinux dot]# cat includefunction.c 
#include <stdlib.h>
#include "hao.h"
int test1(){
	printf("this is test1\n");
}
int test2(){
	test1();
	printf("this is test1\n");
}


-------
#gcc -Wl,-Map=test.map -g -o test test.c

#[root@killinux dot]# grep main test.map 
                0x00000000004003c8                __libc_start_main@@GLIBC_2.2.5
                0x00000000004004c4                main

#addr2line 0x00000000004004c4 -e test -f
#

gcc -g -finstrument-functions test.c instrument.c -o test
./test 
cat trace.txt 
pvtrace test
dot -Tjpg graph.dot -o graph.jpg


执行如图

猜你喜欢

转载自haoningabc.iteye.com/blog/1670743