4

我的目标是获得在 Ubuntu 12.04/precise 主机上使用用户空间探测的能力。这可以从 3.5.0 内核开始,所以我安装了以下软件包:

linux-headers-3.5.0-34
linux-headers-3.5.0-34-generic
linux-image-3.5.0-34-generic
linux-image-3.5.0-34-generic-dbgsym
linux-image-generic-lts-quantal
linux-source
linux-source-3.5.0

和来自 12.10/quantal 的 systemtap v1.7。

但在启动任何 stap 脚本后我看到的唯一内容是:

ERROR: module version mismatch (#55-Ubuntu SMP Thu Jun 6 20:18:19 UTC 2013 vs #55~precise1-Ubuntu SMP Fri Jun 7 16:25:50 UTC 2013), release 3.5.0-34-generic
ERROR: Build-id mismatch [man error::buildid]: "/usr/lib/debug/boot/vmlinux-3.5.0-34-generic" byte 0 (0x84 vs 0xc2) address 0xffffffff8168e60c rc 0

unname -a:

Linux nginx-dev01g 3.5.0-34-generic #55~precise1-Ubuntu SMP Fri Jun 7 16:25:50 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

来自 13.04/raring 的 systemtap v2.1 显示完全相同的错误。

systemtap v1.6(12.04 中的默认版本)在编译时失败:

In file included from /usr/share/systemtap/runtime/transport/transport.c:53:0,
             from /usr/share/systemtap/runtime/print.c:18,
             from /usr/share/systemtap/runtime/runtime.h:128,
             from /tmp/stapYh6Wqv/stap_c22f4bc3b03cd6f9fed549d2973f11fd_361755.c:59:
/usr/share/systemtap/runtime/transport/relay_v2.c:241:2: error: initialization from incompatible pointer type [-Werror]
/usr/share/systemtap/runtime/transport/relay_v2.c:241:2: error: (near initialization for ‘__stp_relay_callbacks.create_buf_file’) [-Werror]
In file included from /usr/share/systemtap/runtime/print.c:18:0,
             from /usr/share/systemtap/runtime/runtime.h:128,
             from /tmp/stapYh6Wqv/stap_c22f4bc3b03cd6f9fed549d2973f11fd_361755.c:59:
/usr/share/systemtap/runtime/transport/transport.c: In function ‘_stp_get_root_dir’:
/usr/share/systemtap/runtime/transport/transport.c:386:8: error: ‘struct hlist_head’ has no member named ‘next’
In file included from /tmp/stapYh6Wqv/stap_c22f4bc3b03cd6f9fed549d2973f11fd_361755.c:61:0:
/usr/share/systemtap/runtime/stat.c: In function ‘_stp_stat_get’:
/usr/share/systemtap/runtime/stat.c:213:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/stat.c:213:2: note: each undeclared identifier is reported only once for each function it appears in
/usr/share/systemtap/runtime/stat.c: In function ‘_stp_stat_clear’:
/usr/share/systemtap/runtime/stat.c:248:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
In file included from /tmp/stapYh6Wqv/stap_c22f4bc3b03cd6f9fed549d2973f11fd_361755.c:13594:0:
/usr/share/systemtap/runtime/pmap-gen.c: In function ‘_stp_pmap_new_sx’:
/usr/share/systemtap/runtime/pmap-gen.c:717:3: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/pmap-gen.c: In function ‘_stp_pmap_get_sx’:
/usr/share/systemtap/runtime/pmap-gen.c:943:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
In file included from /usr/share/systemtap/runtime/map.c:20:0,
             from /tmp/stapYh6Wqv/stap_c22f4bc3b03cd6f9fed549d2973f11fd_361755.c:13609:
/usr/share/systemtap/runtime/map-stat.c: In function ‘_stp_pmap_new_hstat_linear’:
/usr/share/systemtap/runtime/map-stat.c:71:3: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/map-stat.c: In function ‘_stp_pmap_new_hstat_log’:
/usr/share/systemtap/runtime/map-stat.c:98:3: error: ‘cpu_possible_map’ undeclared (first use in this function)
In file included from /tmp/stapYh6Wqv/stap_c22f4bc3b03cd6f9fed549d2973f11fd_361755.c:13609:0:
/usr/share/systemtap/runtime/map.c: In function ‘_stp_pmap_new’:
/usr/share/systemtap/runtime/map.c:242:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/map.c: In function ‘_stp_pmap_clear’:
/usr/share/systemtap/runtime/map.c:350:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/map.c: In function ‘_stp_pmap_del’:
/usr/share/systemtap/runtime/map.c:402:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/map.c: In function ‘_stp_pmap_agg’:
/usr/share/systemtap/runtime/map.c:732:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
/usr/share/systemtap/runtime/map.c: In function ‘_stp_pmap_size’:
/usr/share/systemtap/runtime/map.c:908:2: error: ‘cpu_possible_map’ undeclared (first use in this function)
cc1: all warnings being treated as errors

不幸的是,不能选择更新到 12.10/13.04。

那么,是否有机会在 Ubuntu 12.04/precise 上使用 3.5.0 或 3.8.0 内核获得工作 systemtap?

4

2 回答 2

2

您可能需要更新您的 systemtap 版本,因为非常旧的版本(例如 2012 年初的 1.7)通常无法与非常新的内核一起使用(反之亦然)。

OTOH,原始的 build-id 错误是 ubuntu -dbgsym 存储库中真正的版本不匹配问题。您需要确保您的运行内核版本与 dbgsym 完全匹配。对于 Ubuntu,这可能会很棘手,因为“uname -r”和 dpkg 名称不包含唯一标识构建。查看两者之间的区别:

#55-Ubuntu SMP Thu Jun 6 20:18:19 UTC 2013

#55~precise1-Ubuntu SMP Fri Jun 7 16:25:50 UTC 2013

为什么你需要内核调试符号来进行用户空间探测呢?请包括您的 stap 脚本和 stap-report 输出。也试试 stap-prep 脚本。

另一个复杂的因素是 Ubuntu 内核中可能缺少 CONFIG_UPROBES。另见http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691167

于 2013-07-12T01:59:05.100 回答
1

我编译了systemstap release-2.3。它适用于带有 linux-image-3.5.0-40-generic-dbgsym 的 Ubuntu 12.04。

使用调试信息安装内核。哪里可以获得内核 X 的调试符号?

编译systemstap 2.3

sudo apt-get build-dep systemtap
git clone git://sourceware.org/git/systemtap.git
cd systemtap
git checkout release-2.3
./configure
make all # you can ignore the xmlto error

# enjoy it
sudo ./stap testsuite/systemtap.examples/network/tcpdumplike.stp
于 2013-09-26T04:35:50.887 回答