26.2. 安装 SystemTap
要开始使用 SystemTap,请安装所需的软件包。要在具有多个内核的系统上使用 SystemTap,请为每个内核版本安装对应的内核软件包。
先决条件
- 您已启用了 debug 软件仓库,如 启用调试和源存储库 中所述。
流程
安装所需的 SystemTap 软件包:
# dnf install systemtap安装所需的内核软件包:
使用
stap-prep:# stap-prep如果
stap-prep无法正常工作,请手动安装所需的内核软件包:# dnf install kernel-debuginfo-$(uname -r) kernel-debuginfo-common-$(uname -m)-$(uname -r) kernel-devel-$(uname -r)$(uname -m)会自动替换为您系统的硬件平台,$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. read performed Pass 5: run completed in 10usr/40sys/73real ms.其中:
-
传递 5:启动运行表示 SystemTap 成功创建了检测程序来探测内核并运行检测。 -
执行读取表示 SystemTap 检测到指定的事件,本例中为 VFS 读取。 -
pass 5: run in & lt;time& gt; ms表示 SystemTap 执行有效的处理器。它显示文本并关闭且无错误。