Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4825943
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类: LINUX

2010-11-14 13:35:32

1 下载

  下载gprof2dot.py
下载源代码graphviz-2.18.tar.gz
2  环境
[admin@b2bsearch80 bin]$ python -V
Python2.3.4
[admin@b2bsearch80 bin]$ gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat3.4.6-3)
[admin@b2bsearch80 bin]$ uname -a
Linux b2bsearch802.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux
 
3  安装
Chmod 744 gprof2dot.py
Tar -zxvf graphviz-2.18.tar.gz
  ./configure
 make
  su  -
 make install
 
4   编译代码
gcc -pg -g -o uniqueCoreDump uniqueCoreDump.c
 
5  执行代码生成gmon.out
  执行命令产生gmon.out文件
  ./uniqueCoreDump
ll gmon.out
如果gprof ./uniqueCoreDump有:
gmon.out file is missing call-graph data
则表示没有正确的编译选项或者只有一个main函数
6  生成图片
 gprof ./uniqueCoreDump  | ./gprof2dot.py -n0 -e0 | dot -Tpng -o output.png
 
  sz  output.png
note:
 对于后台程序都是daemon加死循环
 1. 如果是daemon程序的话,先去掉daemon
 2. 程序必须正常结束,注册一个signal,exit正常退出
最后来张图,有点大右边的被我去掉了
 
[root@localhost test]# gprof  -C heartBeat | sort -k3,3 -nr
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:256: (_Z10HandleLoopv:0x804988c) 3391 executions
/data/kenthy/dataProcess/heartBeat/multi_file_processing.c:307: (MfpWaitForFd:0x8049c19) 3390 executions
/data/kenthy/dataProcess/heartBeat/multi_file_processing.c:349: (MfpGetReadyFd:0x8049b20) 3389 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:210: (_Z17dbUpdateHeartBeatl:0x8049662) 3 executions
/usr/include/c++/4.1.2/iostream:76: (__tcf_0:0x8048392) 1 executions
/usr/include/c++/4.1.2/bits/stl_tree.h:1259: (_ZNSt8_Rb_treeIjSt4pairIKj12stAgent_infoESt10_Select1stIS3_ESt4lessIjESaIS3_EE8_M_eraseEPSt13_Rb_tree_nodeIS3_E:0x804993e) 1 executions
/data/kenthy/dataProcess/heartBeat/srv_framework.c:627: (ConnectToTCPALLSvr:0x804d0ab) 1 executions
/data/kenthy/dataProcess/heartBeat/srv_framework.c:460: (CreateUDPSocket:0x804bde7) 1 executions
/data/kenthy/dataProcess/heartBeat/srv_framework.c:257: (SrvFrameworkInit:0x804c68f) 1 executions
/data/kenthy/dataProcess/heartBeat/srv_framework.c:1159: (SrvFrameworkLoop:0x804d2a6) 1 executions
/data/kenthy/dataProcess/heartBeat/multi_file_processing.c:60: (MfpInit:0x8049f5a) 1 executions
/data/kenthy/dataProcess/heartBeat/multi_file_processing.c:206: (MfpAddFd:0x804a0d0) 1 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:54: (__tcf_1:0x8048366) 1 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:400: (_GLOBAL__I_stConfig:0x8048344) 1 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:399: (_Z41__static_initialization_and_destruction_0ii:0x80482b2) 1 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:388: (main:0x80495d4) 1 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:376: (_Z14InitSigHandlerv:0x8049566) 1 executions
/data/kenthy/dataProcess/heartBeat/heartBeat.cpp:282: (_Z4InitiPPc:0x804840c) 1 executions
阅读(4152) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-15 16:06:02

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com