SystemTap

来自 Arch Linux 中文维基

本文内容或本节内容已经过期。

原因: 请提供模板的第一个位置参数以概括原因。 (在Talk:SystemTap讨论)

Systemtap 是一种在运行时收集 Linux 系统信息的自由软件(GPL)框架。

SystemTap[编辑 | 编辑源代码]

安装 systemtapAURsystemtap-gitAUR。和上游版本的对比:[1].

要从源代码编译,请访问 这里。最新代码会包含新内核版本和发行版的支持。

标准内核[编辑 | 编辑源代码]

至少需要安装软件包 linux-headers

Arch 会从发布的二进制文件,包括内核中删除调试数据。很多 systmetap 功能就不能使用了。stapprobes 手册记录了 NON-DWARF 和 AUTO-DWARF 类型下什么功能可用:

  • kernel tracepoints: kernel.trace("*")
  • user-space probes: process("...").function("...") (for programs you build yourself with -g)
  • user-space markers: process("...").mark("...") (if they were configured with the <sys/sdt.h> markers)
  • perfctr-based probes: perf.*
  • non-dwarf kernel probes: kprobe.function("...") and nd_syscall.* tapset (if a /boot/System.map* file is available, see below).

内核重新编译[编辑 | 编辑源代码]

可用自定义 linux-custom 软件包之后再运行 SystemTap。重新编译 linux 软件包也非常方便。参考 Kernels/Traditional compilation

Prepare[编辑 | 编辑源代码]

First, run cd ~/ && mkdir build && cd build/ && asp checkout linux && cd linux/trunk to get the original kernel build files. Then use makepkg --verifysource to get the additional files. By performing the verification, you can safely skip the steps on "Update checksum".

修改config文件[编辑 | 编辑源代码]

编辑 config (32位内核) 或 config.x86_64 (64位内核), 确保打开这些选项:

  • CONFIG_KPROBES=y
  • CONFIG_KPROBES_SANITY_TEST=n
  • CONFIG_KPROBE_EVENT=y
  • CONFIG_NET_DCCPPROBE=m
  • CONFIG_NET_SCTPPROBE=m
  • CONFIG_NET_TCPPROBE=y
  • CONFIG_DEBUG_INFO=y
  • CONFIG_DEBUG_INFO_REDUCED=n
  • CONFIG_X86_DECODER_SELFTEST=n
  • CONFIG_DEBUG_INFO_VTA=y

默认只有CONFIG_DEBUG_INFOCONFIG_DEBUG_INFO_REDUCED没被打开,修改这两个即可.

更新校验值[编辑 | 编辑源代码]

执行 md5sum config[.x86_64] 获得新的文件校验值.

编辑 PKGBUILD 文件, 这一部分 md5sums=('sum-of-first' ... 'sum-of-last') 和这一部分 source=('first-source' ... 'last-source') 是个数相同,顺序相同的, 把新获得的校验值在合适的位置替换.

makepkg --skipchecksums 使用命令可以跳过校验,但这样做对其它文件(比如下载的内核源码包)来说不安全,因此建议按这里给出的方法操作

编译并安装[编辑 | 编辑源代码]

可选步骤: 可以在 /etc/makepkg.conf 文件中设置 MAKEFLAGS="-j16" 加速编译.

执行 makepkg 开始编译, 然后 sudo pacman -U *.pkg.tar.gz 安装编译好的包. pacman 会提示你这是重新安装 (reinstall), 这就对了!

linuxlinux-headers 需要安, linux-docs 则随意.

通过这个方法, 外部内核模块 (例如 nvidiavirtualbox) 就不需要被重新编译了.

Systemtap[编辑 | 编辑源代码]

AUR 中安装systemtap即可: systemtapAUR, 完成.

编译自定义内核[编辑 | 编辑源代码]

参考这个 官方README

问题处理[编辑 | 编辑源代码]

版本匹配问题[编辑 | 编辑源代码]

如果出现如下错误:

   /usr/share/systemtap/runtime/stat.c:214:2: error: 'cpu_possible_map' undeclared (first use in this function)

请安装 systemtap-git。

System.map is missing[编辑 | 编辑源代码]

You can recover it where you build your linux kernel with DEBUG_INFO enabled

   cp src/linux-3.6/System.map /boot/System.map-3.6.7-1-ARCH

Alternately,

   sudo cp /proc/kallsyms /boot/System.map-`uname -r`

Process return probes not available[编辑 | 编辑源代码]

If you are sure that your kernel configuration is correct, but on launching stap you get both of the following messages:

   WARNING: Kernel function symbol table missing [man warning::symbols]
   semantic error: process return probes not available [man error::inode-uprobes]

then SystemTap may have failed to verify support for this feature. You can fix this by following the steps in System.map is missing.