• 制作火焰图(纯笔记)


    安装systemtap

    按照官网说的安装:http://sourceware.org/systemtap/wiki/SystemTapOnCentOS

    我的操作系统是centos

    uname -rm:

    2.6.18-164.el5xen x86_64

    yum install systemtap

    wget http://debuginfo.centos.org/5/x86_64/kernel-debuginfo-2.6.18-164.el5.x86_64.rpm

    wget http://debuginfo.centos.org/5/x86_64/kernel-debuginfo-common-2.6.18-164.el5.x86_64.rpm

    [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

    下载Flame Graph

    https://github.com/brendangregg/FlameGraph

    比如我放在这个目录里:

    /home/yejianfeng/software/FlameGraph-master

    下面拿nginx的一个模块来进行测试

    http://www.cnblogs.com/yjf512/archive/2013/06/13/3133569.html

    这里有个自己写的mysecret2的模块

    安装配置好,确保能访问

    Image(15)

    写一个systemtrap脚本:

    global s;
    global quit = 0;
    probe timer.profile {
    if(pid() == target()) {
    if (quit) {
    foreach (i in s-) {
    print_ustack(i);
    printf("	%d
    ", @count(s[i]));
    }
    exit;
    } else {
    s[ubacktrace()] <<< 1;
    }
    }
    }
    probe timer.s(20) {
    quit = 1;
    }
    <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 &gt; 
    /home/yejianfeng/ngx.out&nbsp;
    <P>WARNING: never-assigned local variable 'exit' (alternatives: i s quit): 
    identifier 'exit' at /home/yejianfeng/handcode/ngx.stp:10:4
    <P>&nbsp;source: exit;
    <P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^
    <P>WARNING: Eliding side-effect-free expression : identifier 'exit' at :10:4
    <P>&nbsp;source: exit;
    <P>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^
    <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. &nbsp;Try again with another '--vp 00001' option.</P>

     

     

    纯笔记。。。搞了半天没搞出来。。。MMD。。。水平太搓了。。。

  • 相关阅读:
    @雅礼集训01/13
    @hdu
    @bzoj
    @hdu
    @bzoj
    @雅礼集训01/10
    @codeforces
    @spoj
    @bzoj
    @bzoj
  • 原文地址:https://www.cnblogs.com/yjf512/p/3374014.html
Copyright © 2020-2023  润新知