使用stap命令时报如下错误

stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'

linux systemtap报错解决_依赖包

[root@myds1 tmp]# stap /usr/share/doc/systemtap-client-2.6/examples/io/inodewatch.stp  253 1 204550458
semantic error: while resolving probe point: identifier 'kernel' at /usr/share/systemtap/tapset/linux/vfs.stp:836:19
source: probe vfs.write = kernel.function("vfs_write")
^

semantic error: missing x86_64 kernel/module debuginfo [man warning::debuginfo] under '/lib/modules/3.10.0-229.el7.x86_64/build'

semantic error: while resolving probe point: identifier 'vfs' at /usr/share/doc/systemtap-client-2.6/examples/io/inodewatch.stp:3:7
source: probe vfs.write, vfs.read
^

semantic error: no match

Pass 2: analysis failed. [man error::pass2]
Number of similar error messages suppressed: 2.
Rerun with -v to see them.

报错原因:

缺少kernel-debuginfo-common、kernel-debuginfo两个依赖包

解决方式:

(1)查看linux内核版本

uname -r

linux systemtap报错解决_依赖包_02

(2)下载与内核版本一致的rpm包

linux systemtap报错解决_依赖包_03

(3)安装rpm包

rpm -ivh kernel-debuginfo-common-x86_64-3.10.0-229.el7.x86_64.rpm
rpm -ivh kernel-debuginfo-3.10.0-229.el7.x86_64.rpm

linux systemtap报错解决_ide_04

(4)重新运行测试命令

linux systemtap报错解决_ide_05

成功运行