本文共 2217 字,大约阅读时间需要 7 分钟。
安装systemtap
按照官网说的安装:
我的操作系统是centos
uname -rm:
2.6.18-164.el5xen x86_64
yum install systemtap
wget
wget
[root@test34x-nova ~/software]# rpm -Uhv kernel-debuginfo-*rpm
warning: kernel-debuginfo-2.6.18-164.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897 Preparing... ########################################### [100%] 1:kernel-debuginfo-common########################################### [ 50%] 2:kernel-debuginfo ########################################### [100%]stap -ve 'probe begin { log("hello world") exit() }'
提示:
Checking "/lib/modules/2.6.32-279.el6.x86_64/build/.config" failed with error: 没有那个文件或目录
Incorrect version or missing kernel-devel package, use: yum install kernel-devel-2.6.32-279.el6.x86_64
比如我放在这个目录里:
/home/yejianfeng/software/FlameGraph-master
这里有个自己写的mysecret2的模块
安装配置好,确保能访问
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | global s; global quit = 0; probe timer.profile { if (pid() == target()) { if (quit) { foreach (i in s-) { print_ustack(i); printf( "\t%d\n" , @ count (s[i])); } exit ; } else { s[ubacktrace()] <<< 1; } } } probe timer.s(20) { quit = 1; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <P>[root@test34x-nova ~/handcode]# stap --ldd -d /home/yejianfeng/nginx/nginx/sbin/nginx --all-modules -D MAXMAPENTRIES=256 -D MAXACTION=20000 -D MAXTRACE=100 -D MAXSTRINGLEN=4096 -D MAXBACKTRACE=100 -x 26150 /home/yejianfeng/handcode/ngx.stp --vp 0001 > /home/yejianfeng/ngx.out <P>WARNING: never-assigned local variable 'exit' (alternatives: i s quit): identifier 'exit' at /home/yejianfeng/handcode/ngx.stp:10:4 <P> source: exit ; <P> ^ <P>WARNING: Eliding side-effect-free expression : identifier 'exit' at :10:4 <P> source: exit ; <P> ^ <P>WARNING: missing unwind/symbol data for module 'kernel' <P>WARNING: missing unwind/symbol data for module 'uprobes' <P>Pass 4: compiled C into "stap_7ee66ba3cf5480d819b30e4f49bf3bb1_3633.ko" in 5560usr/1320sys/9525real ms. <P>WARNING: /usr/bin/staprun exited with status: 1 <P>Pass 5: run failed. Try again with another '--vp 00001' option.</P> |
纯笔记。。。搞了半天没搞出来。。。MMD。。。水平太搓了。。。
转载地址:http://durql.baihongyu.com/