免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1107 | 回复: 0
打印 上一主题 下一主题

Systemtap usage [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-03 09:53 |只看该作者 |倒序浏览

       
       
       
       
       
       
       
       
        bibliography:
http://www.ibm.com/developerworks/cn/linux/l-systemtap/
man
stap(1)
man
stapprobes(5)
man
stapex(5)
less
/usr/share/doc/systemtap-0.5.13/*
probe
syntax:
        probe
PROBEPOINT [, PROBEPOINT] { [STMT ...] }
The
probe  handler  is  interpreted relative to the context of each
event. For events associated with kernel code, this context may
include variables defined in the source code at that spot.  These
[color="#ff0000"]"target variables"  are
presented  to  the script as variables whose names are prefixed with
[color="#ff0000"]"$".
[color="#ff0000"]Important:
        most
of the local variables are optimized and omitted. So be aware of the
variables exported by “nm ”
probe
point:
begin/end:
        begin:
when session starting.
        End:
when session ending, i.e. After calling exit().
Never:
        never
insert probe point, just check to see if error.
Timers:
        timer.jiffies(N)
        timer.jiffies(N).randomize(M)
        timer.ms(N)                //
millisecond
        timer.ms(N).randomize(M)
dwarf:
        kernel.function(PATTERN)
        kernel.function(PATTERN).return
        kernel.inline(PATTERN)
        module(MPATTERN).function(PATTERN)
        module(MPATTERN).function(PATTERN).return
        module(MPATTERN).inline(PATTERN)
        kernel.statement(PATTERN)
        kernel.statement(ADDRESS).absolute
        module(MPATTERN).statement(PATTERN)
        notation:
                MPATTERN:
module pattern (without “.ko”)
                PATTERN:
func[@pathname[:line num]]
                statement:
a point to relative or absolute address
markers:
        unknown
yet.
[color="#ff0000"]STATISTICS:
  • define
            varible as global
           
  • use
            “
           
  • invoke
            functions defined by systemtap to fetch statistics, i.e.  @count(v),
            @sum(v), @min(v), @max(v), @avg(v)
    [color="#ff0000"]expressions:
    %(
    CONDITION %? TRUE_VALUE %: FALSE_VALUE %)
    #
    eg. Attention $arch
    %(
    [color="#ff0000"]arch == "ia64" %? probe
    syscall.vliw = kernel.function("vliw_widget") {} %)
    #
    else, we could use kernel_vr or kernel_r to express like “2.6.18”
    some
    examples:
    #!/usr/bin/stap
    #
    Usage: stap   
    #
    when invoking arguments for filename, @1 is expressed as strings, $2
    is expressed as integer
    probe
    syscall.read
    {
          printf("fd = %d\n",fd)
            printf("strings:
    %s\n", @1)
            printf("integer:
    %d\n", $2)
    }
    probe
    syscall.read.return
    {
    exit() }
    #!/usr/bin/stap
    #
    To aggregate statistics
    global
    x
    probe
    foo
    {
            x
    }
    probe
    stat
    {
            printf(“sum
    is: %d”, @sum(x))
            exit()
    }
    #!/usr/bin/stap
    #
    note: we could get parameters to function before calling the function
    probe
    module("cdrom").function("cdrom_open")
    {
            printf("before
    running\n")
    [color="#800000"]      
    printf("give me local
    variable ret: %d\n", $cdi->speed)
    }
    probe
    module("cdrom").statement("cdrom_open@drivers/cdrom/cdrom.c:997")
    {
            printf("into
    func\n")
    }
    probe
    module("cdrom").function("cdrom_open").return
    {
            printf("after
    running\n")
            exit()
    }
                   
                   
                   

    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7356/showart_373121.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP