【问题标题】:How to use the stap -L option?如何使用 stap -L 选项?
【发布时间】:2012-05-15 09:01:59
【问题描述】:

我正在关注 SystemTap 教程,我正在尝试执行第 2.3 节中的练习 1 - "Tracing. Exercises"-L 选项似乎永远不起作用。我得到了这个脚本:

probe kernel.function("*nit*"){}

我在终端输入:

$ stap -L PROBE t.stp

什么都没有发生。

【问题讨论】:

    标签: linux-kernel ubuntu-11.10 systemtap


    【解决方案1】:
    $ stap -L 'kernel.function("blahblah")'
    

    Systemtap 很棒,但文档很差。

    【讨论】:

      【解决方案2】:

      来自man stap(安装了systemtap*-1.7-2.fc15.x86_64 RPM)

         stap [ OPTIONS ] -l PROBE [ ARGUMENTS ]
         stap [ OPTIONS ] -L PROBE [ ARGUMENTS ]
      
         -l PROBE
                Instead of running a probe script, just list all available probe
                points  matching  the given single probe point.  The pattern may
                include wildcards and aliases, but not comma-separated  multiple
                probe  points.  The process result code will indicate failure if
                there are no matches.
      
         -L PROBE
                Similar to "-l", but list probe points  and  script-level  local
                variables.
      

      “探针点”指的是'kernel.function("blahblah")'等。之前没有关键字“probe”,之后没有probe handler。

      【讨论】:

        【解决方案3】:
        stap -L kernel.function("*nit*") | sort
        

        【讨论】:

        • 您需要撇号才能使用:stap -L 'kernel.function("*nit*")' | sort
        【解决方案4】:

        您可以尝试以下示例。

        获取所有内核函数的列表。

        $ stap -l 'kernel.function("*")' |排序

        kernel.function("vfs_read@/build/linux-lts-xenial-Hu9lgy/linux-lts-xenial-4.4.0/fs/read_write.c:440") [....]

        获取内核函数和参数(局部变量)

        $ stap -L 'kernel.function("*")' | grep vfs_read

        kernel.function("vfs_read@/build/linux-lts-xenial-Hu9lgy/linux-lts-xenial-4.4.0/fs/read_write.c:440") $file:struct file* $buf:char * $count:size_t $pos:loff_t*

        [....]

        【讨论】:

          【解决方案5】:

          只是补充一下比我更有学识的人所说的话:

          stap -L 'module("module-name-here").function("*")'
          

          对于常规内核探测:

          stap -L 'kernel.function("*")'
          

          希望这对将来的其他人有所帮助!

          【讨论】:

            猜你喜欢
            • 2013-12-28
            • 1970-01-01
            • 2014-10-10
            • 1970-01-01
            • 2017-11-04
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多