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.