我正在尝试使用 stap
打印出程序调用的所有函数。我在网上做了一些研究并找到了这个脚本(称为 para-callgraph.stp
):
#! /usr/bin/env stap
function trace(entry_p, extra) {
printf("%s%s%s %s\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc (),
extra)
}
probe $1.call { trace(1, $$parms) }
probe $1.return { trace(-1, $$return) }
它的目的是像这样运行:
sudo stap para-callgraph.stp 'process.function("*")' -c `pwd`/my-program
现在,当我运行它时,我遇到了一个问题。一开始一切正常,但很快 systemtap
将其打印到 stderr,然后退出:
ERROR: probe overhead exceeded threshold
WARNING: Number of errors: 1, skipped probes: 0
WARNING: There were 62469 transport failures.
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run failed. [man error::pass5]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.
做一些研究 online向我揭示了 stap
启发式正在被触发并关闭我,我可以通过添加两个标志 -g
和 --suppress- 来关闭它时间限制
。 (这个建议得到了我系统上 man stap
的支持。)但是,这个解决方案根本不起作用,命令:
sudo stap -g --suppress-time-limits para-callgraph.stp 'process.function("*")' -c `pwd`/core-cpu1
打印一条非常相似的错误信息,然后退出:
ERROR: probe overhead exceeded threshold
WARNING: Number of errors: 1, skipped probes: 0
WARNING: There were 67287 transport failures.
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run failed. [man error::pass5]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.
为什么这个标志不是解决我的问题的合适方法?这个问题可以通过其他方式解决吗,还是 systemtap 根本不适合这种用例?
如果重要的话,我会在 32 位 Ubuntu VM 上运行它。
注意我最感兴趣的是为什么 systemtap 在这里失败了,而不是使用其他软件完成同样事情的其他方法。 (事实上 ,对于我的用例,上面的代码是对systemtap的滥用。)
最佳答案
探针和消费者之间的传输缓冲区也是有限的,所以如果你要在探针中打印 比消费者可以采取的速度更快,您将看到 SystemTap 中出现 NN 传输故障错误或 DTrace 上的 DTrace 在 CPU X 上掉线错误。
这个问题的答案是 简单:不那么冗长,更频繁地从缓冲区中获取数据(由 cleanrate 调节 在 DTrace 中可调)或增加缓冲区大小(-b 选项和 bufsize 在 DTrace 和 SystemTap 中的 -s 选项)。
引用: http://myaut.github.io/dtrace-stap-book/dtrace-stap-book-ns.pdf
关于c - 使用 system tap 时如何避免 "probe overhead exceeded threshold"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40335300/