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

cdcdHOME

$ sudo apt-get install dpkg-dev debhelper gawk

apt-get install ncurses-dev

$ mkdir tmp

$ cd tmp

sudoaptgetbuilddepnoinstallrecommendslinuximagesudoapt−getbuild−dep−−no−install−recommendslinux−image−(uname -r)

aptgetsourcelinuximageapt−getsourcelinux−image−(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,如需转载请自行联系原作者

相关文章
|
19天前
|
XML Java Linux
【Linux 第三方库】linux 交叉编译dbus,expat
【Linux 第三方库】linux 交叉编译dbus,expat
56 0
|
19天前
|
人工智能 Ubuntu 机器人
【Valgrind】Valgrind安装(ubuntu系统)
【Valgrind】Valgrind安装(ubuntu系统)
|
Linux 编译器
Linux下make -j加快编译速度
Linux下make -j加快编译速度
116 0
|
Ubuntu Linux 编译器
【Linux】内存检测工具Valgrind
【Linux】内存检测工具Valgrind
|
C语言 Linux
SystemTap工具的使用基础
systemtap工具的安装 准备工作 uname -a 查看当前内核版本是哪一个,然后使用 yum install kernel-devel 安装kernel debuginfo包 rpm -qi kernel-devel 找到内核构建的详细信息,然后去对应发布网站上找kernel-debuginfo和kernel-debuginfo-common包。
1999 0
|
监控 网络协议 安全