39.2. 安装 SystemTap
要开始使用 SystemTap,请安装所需的软件包。要在安装多个内核的内核上使用 SystemTap,为每个内核版本安装对应的内核软件包。
先决条件
- 您已启用了 debug 软件仓库,如启用 debug 和源存储库中所述。
流程
安装所需的 SystemTap 软件包:
# dnf install systemtap
安装所需的内核软件包:
使用
stap-prep
:# stap-prep
如果
stap-prep
无法正常工作,请手动安装所需的内核软件包:# dnf install kernel-debuginfo-$(uname -r) kernel-debuginfo-common-$(uname -i)-$(uname -r) kernel-devel-$(uname -r)
$ (uname -i)
会自动替换为您系统的硬件平台,$ (uname -r)
会自动替换为正在运行的内核的版本。
验证
如果当前使用 SystemTap 探测内核,请检查您的安装是否成功:
# stap -v -e 'probe kernel.function("vfs_read") {printf("read performed\n"); exit()}'
成功 SystemTap 部署会生成类似如下的输出:
Pass 1: parsed user script and 45 library script(s) in 340usr/0sys/358real ms. Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 290usr/260sys/568real ms. Pass 3: translated to C into "/tmp/stapiArgLX/stap_e5886fa50499994e6a87aacdc43cd392_399.c" in 490usr/430sys/938real ms. Pass 4: compiled C into "stap_e5886fa50499994e6a87aacdc43cd392_399.ko" in 3310usr/430sys/3714real ms. Pass 5: starting run. 1 read performed 2 Pass 5: run completed in 10usr/40sys/73real ms. 3
输出的最后三行(以
Pass 5
开始)代表: