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

c d HOME

$ sudo apt-get install dpkg-dev debhelper gawk

apt-get install ncurses-dev

$ mkdir tmp

$ cd tmp

s u d o a p t g e t b u i l d d e p n o i n s t a l l r e c o m m e n d s l i n u x i m a g e (uname -r)

a p t g e t s o u r c e l i n u x i m a g e (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

目录
相关文章
|
9月前
|
缓存 监控 Unix
vmstat命令详解
`vmstat` 是类 Unix 系统的监控工具,显示虚拟内存、物理内存、CPU、I/O 和系统中断等资源使用情况。基本用法是 `vmstat [interval [count]]`,可按指定时间间隔输出系统状态。主要字段包括进程(r/b)、内存(swpd/free/buff/cache)、交换(si/so)、I/O(bi/bo)、系统(in/cs)和CPU(us/sy/id/wa/st)的统计。使用 `-s`, `-a`, `-m`, `-d`, `-p` 等选项可获取不同类型的统计信息。详细信息可通过 `man vmstat` 查看。
144 3
|
8月前
|
XML Ubuntu Linux
探索Linux中的`busctl`命令:DBus的瑞士军刀
`busctl`是Linux下管理DBus消息总线的命令行工具,用于查看、监听和控制DBus服务。
|
C语言 Linux
SystemTap工具的使用基础
systemtap工具的安装 准备工作 uname -a 查看当前内核版本是哪一个,然后使用 yum install kernel-devel 安装kernel debuginfo包 rpm -qi kernel-devel 找到内核构建的详细信息,然后去对应发布网站上找kernel-debuginfo和kernel-debuginfo-common包。
2076 0
无法定位软件包dbus-glib-1
无法定位软件包dbus-glib-1
131 0
|
监控 网络协议 安全

热门文章

最新文章