SystemTap知识(二)

简介:

Unbuntu安装systemtap:

http://www.cnblogs.com/hdflzh/archive/2012/07/25/2608910.html

1 更新源到http://mirror.ubuntu9.com/topmirror/sourceslist/all/54772423e19231bbb722a69fd878df28.list

2 apt-get install systemtap

3 apt-get install systemtap-sdt-dev

4

cdHOME

$ sudo apt-get install dpkg-dev debhelper gawk

apt-get install ncurses-dev

$ mkdir tmp

$ cd tmp

sudoaptgetbuilddepnoinstallrecommendslinuximage(uname -r)

aptgetsourcelinuximage(uname -r)

$ cd linux-2.6.31 (this is currently the kernel version of 9.10)

$ fakeroot debian/rules clean

$ AUTOBUILD=1 fakeroot debian/rules binary-generic skipdbg=false

$ sudo dpkg -i ../linux-image-debug-2.6.31-19-generic_2.6.31-19.56_amd64.ddeb

https://gist.github.com/shino/30c6745bb7a5db6fdce0/raw/e4d191fed1d44c038020c2f2e897bd08b513fe8e/systemtap_ubuntu12.10_memo.rst

http://sourceware.org/systemtap/wiki/SystemtapOnUbuntu

出现错误:

/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/stapXuHMle/stap_f534cd5578062befad3b2b49cf30135c_2471.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: ?.truct hlist_head?.has no member named ?.ext?

In file included from /tmp/stapXuHMle/stap_f534cd5578062befad3b2b49cf30135c_2471.c:61:0:

/usr/share/systemtap/runtime/stat.c: In function ?.stp_stat_get?.

/usr/share/systemtap/runtime/stat.c:213:2: error: ?.pu_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: ?.pu_possible_map?.undeclared (first use in this function)

cc1: all warnings being treated as errors

解决:

http://blog.sina.com.cn/s/blog_820c67660101cgke.html

测试是否成功:

stap -e 'probe kernel.function("vfs_read") { printf("%s \n", $$vars)}' -vv

用户域的探针

Systemtap最初是用于内核态的探针的,但是基于用户态的探针能定位解决用户的程序问题。Systemtap0.6能往用户态的进程中放入探针。SystemTap能支持在用户态的进程中的某个方法的入口和出口的地方放入探针。

用户态Systemtap的探针要求安装utrace内核扩展。utrace的介绍在:

http://sourceware.org/systemtap/wiki/utrace

使用命令来判断当前系统是否安装了utrace

grep CONFIG_UTRACE /boot/config-`uname -r`

如果支持用户态探针,会输出:

CONFIG_UTRACE=y

用户态Systemtap也需要uprobes内核模块。如果没有安装的话,你在运行需要uprobes模块的时候会出现下面的问题:

Image(5)

用户态的事件

用户态事件以process开始,有下面几种形式

PATH是可执行程序的路径

process("PATH").function("function")

process("PATH").statement("statement")

process("PATH").mark("marker")

process.begin

process.thread.begin

process.end

process.thread.end

process.syscall





本文转自轩脉刃博客园博客,原文链接:http://www.cnblogs.com/yjf512/p/3294337.html,如需转载请自行联系原作者

目录
打赏
0
0
0
0
56
分享
相关文章
Linux笔记之ldd命令详解
`ldd`命令是Linux环境下一个非常实用的工具,用于显示一个程序运行时所需的共享库依赖。它帮助开发者和系统管理员快速诊断程序运行问题,特别是在处理"找不到库文件"或者"错误的库文件版本"等错误时。然而,出于安全的考虑,对于不信任的可执行文件,应该慎用 `ldd`命令,可以考虑使用其他工具如 `objdump`。总的来说,懂得如何妥善且安全地使用 `ldd`,对于维护一个稳定和高效的Linux系统来说,是非常重要的。
201 9
Linux命令`arch`详解
`arch`命令在Linux中用于显示系统CPU架构,如x86_64、ARM等。它在跨平台编程、软件包管理和系统故障排除时很有用。通过`arch`,用户能得知系统运行的架构,但注意这可能与物理CPU架构不同,尤其是在虚拟环境中。在某些系统中,`arch`可能是`uname`命令的别名。了解CPU架构对有效管理系统至关重要。
|
10月前
|
内核编译bpf
内核编译bpf
73 0
SystemTap工具的使用基础
systemtap工具的安装 准备工作 uname -a 查看当前内核版本是哪一个,然后使用 yum install kernel-devel 安装kernel debuginfo包 rpm -qi kernel-devel 找到内核构建的详细信息,然后去对应发布网站上找kernel-debuginfo和kernel-debuginfo-common包。
2081 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等