在Ubuntu上安装使用Systemtap
因为最近开始学习Nginx,在网上看到别人介绍了一款强大的内核探测工具Systemtap,于是便准备学习下这款探测工具为以后代码分析做准备。
第一步便是安装。在自己电脑上安装的时候,也是费了一番劲儿。因此,为防止以后需要重新安装,也希望可以帮助后来学习的人,在这里准备写一篇博客做一个记录。
以下便是安装步骤:
(0)、安装elfutils,提供分析调试信息的库函数,及libcap-dev。
借助于Ubuntu方便强大的包管理器,可以很方便进行安装,如下:
sudo apt-get install elfutils
sudo apt-get install libcap-dev
(1)、安装systemtap。
借助于Ubuntu方便强大的包管理器,可以很方便进行安装,如下:
sudo apt-get install systemtap
后续如果需要卸载,可执行如下命令:
sudo apt-get remove systemtap
也可以通过源码进行安装,下载地址:https://sourceware.org/systemtap/ftp/releases/ 。解压然后进入根目录,执行如下命令:
./configure
make
sudo make instal
如果后续需要卸载,可进入根目录,执行如下命令:
sudo make uninstall
(2)、安装debug symbols。
1)、配置ddeb repository。
sudo cat > /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ precise main restricted universe multiverse
EOF sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
sudo apt-get update
上面添加仓库地址也可以直接在ddebs.list文件后面添加相应地址。
2)、添加完repository之后,便是下载和你当前内核版本相对应的debug symbols。在这里推荐一位外国朋友写的脚本,写的非常好,博文链接(http://www.domaigne.com/blog/random/getting-debug-kernel-on-ubuntu/),感兴趣的可以去学习学习。因此为了减少错误发生,这里采用这里的脚本进行下载和安装:
wget http://www.domaigne.com/download/tools/get-dbgsym chmod +x get-dbgsym sudo ./get-dbgsy
执行脚本后,可以去做些其他事情,因为这里可能需要等待较长的时间。
3)、生成systemtap/libelf所需的模块信息。将如下命令放入debug_ko.sh:
for file in `find /usr/lib/debug -name '*.ko' -print`
do
buildid=`eu-readelf -n $file| grep Build.ID: | awk '{print $3}'`
dir=`echo $buildid | cut -c1-`
fn=`echo $buildid | cut -c3-`
mkdir -p /usr/lib/debug/.build-id/$dir
ln -s $file /usr/lib/debug/.build-id/$dir/$fn
ln -s $file /usr/lib/debug/.build-id/$dir/${fn}.debug
done
然后执行该文件:
sudo ./debug_ko.sh
(4)、测试安装是否成功。执行如下命令:
stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
如果在终端打印出“hello world”说明安装成功。如果没有,继续往下看。
(5)、如果按照上述步骤安装完之后,仍然不能使用,那么请参考下面的场景分别进行补充。
1)、如果执行(4)中的命令后,终端打印如下信息:
stap: Symbol `SSL_ImplementedCiphers' has different size in shared object, consider re-linking
In file included from include/linux/mutex.h::,
from /tmp/staphH2yQD/stap_6e022ad97cbe9c6f46b582f7a0eac81d_1242_src.c::
include/linux/spinlock_types.h::: error: ‘__ARCH_SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)
.raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \
^
include/linux/spinlock_types.h::: note: in expansion of macro ‘__RAW_SPIN_LOCK_INITIALIZER’
{ { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname) } }
^
include/linux/spinlock_types.h::: note: in expansion of macro ‘__SPIN_LOCK_INITIALIZER’
(spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname)
^
include/linux/mutex.h::: note: in expansion of macro ‘__SPIN_LOCK_UNLOCKED’
, .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
^
include/linux/mutex.h::: note: in expansion of macro ‘__MUTEX_INITIALIZER’
struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
^
/tmp/staphH2yQD/stap_6e022ad97cbe9c6f46b582f7a0eac81d_1242_src.c::: note: in expansion of macro ‘DEFINE_MUTEX’
static DEFINE_MUTEX(module_refresh_mutex);
^
scripts/Makefile.build:: recipe for target '/tmp/staphH2yQD/stap_6e022ad97cbe9c6f46b582f7a0eac81d_1242_src.o' failed
make[]: *** [/tmp/staphH2yQD/stap_6e022ad97cbe9c6f46b582f7a0eac81d_1242_src.o] Error
Makefile:: recipe for target '_module_/tmp/staphH2yQD' failed
make: *** [_module_/tmp/staphH2yQD] Error
WARNING: kbuild exited with status:
Pass : compilation failed. [man error::pass4]
说明有些共享库需要重新readlink,执行如下命令:
readlink /lib/modules/`uname -r`/build/
参考文章如下:
1、http://www.domaigne.com/blog/random/running-systemtap-on-ubuntu/
2、https://sourceware.org/systemtap/wiki/SystemtapOnUbuntu
3、https://wiki.ubuntu.com/Kernel/Systemtap
【注】转载需经本人同意并注明出处:http://www.cnblogs.com/wtb2012/p/5218889.html
在Ubuntu上安装使用Systemtap的更多相关文章
- [异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议
一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题 ...
- Ubuntu上安装Robomongo及添加到启动器
到目前为止,Robomongo仍是MongoDB最好的客户端管理工具,如需在Ubuntu上安装Robomongo,可直接从官网下载.tar.gz压缩包进行解压,然后直接运行bin目录下的robomon ...
- 在 Ubuntu 上安装 Android Studio
在 Ubuntu 上安装 Android Studio http://www.linuxidc.com/Linux/2013-05/84812.htm 打开terminal,输入以下命令 sudo a ...
- Ubuntu上安装Karma失败对策
在Ubuntu上安装Karma遇到超时 timeout 错误.Google了一下,国外的码农给了一个快捷的解决方案,实测可行,贴在这里: sudo apt-get install npm nodejs ...
- 在Ubuntu上安装LAMP服务器
1.安装Ubuntu上安装LAMP apt-get install lamp-server^ 2.安装过程中设置MySql密码 3.测试 创建index.php var/www/html/index. ...
- [译]How to Setup Sync Gateway on Ubuntu如何在ubuntu上安装sync-gateway
参考文章https://hidekiitakura.com/2015/03/21/how-to-setup-sync-gateway-on-ubuntudigitalocean/ 在此对作者表示感谢 ...
- 在Ubuntu上安装JDK、Ant、Jmeter和Jenkins
一.前期准备 1. 在win7下载VMware.Ubuntu(用迅雷下比较快) 2. 安装完VMware后新建虚拟机,选择iso: 3. 具体配置参考如下,至此Ubantu安装完成 二.在Ubuntu ...
- Ubuntu上安装MongoDB(译)
add by zhj:直接从第四步开始就可以了,而且安装好MongoDB后会自动启动的,不必自己去执行启动命令 原文:https://docs.mongodb.com/manual/tutorial/ ...
- Ubuntu上安装ns2-2.34
Ubuntu上安装ns2-2.34 步骤1 下载ns-allinone-2.34 $ tar zxf ns-allinone-2.34.tar.gz 步骤2 sudo apt-get install ...
随机推荐
- 百度的一个Ajax跨域方法 JavaScript是没有域的限制
baidu的通行证处理都是在二级域名passport.baidu.com中处理的,但是baidu很多地方登录都好像是用ajax处理的,他是怎么做的呢?研究了一下,发现一个小技巧. 在http://zh ...
- CSS3的appearance属性--改变元素的外观
CSS3 appearance 属性 CSS 参考手册 实例 使 div 元素看上去像一个按钮: div { appearance:button; -moz-appearance:button; /* ...
- 51中的C语言数据类型
在标准C语言中基本的数据类型为char,int,short,long,float 和double,而在C51编译器中int和short相同,float和double相同. 说明: (1)类型修饰符si ...
- Google Cardboard
Google Cardboard是谷歌的一个虚拟现实开源项目,旨在使用户可以以一种简单.有趣且廉价的方式体验虚拟现实.用户只需要在Android手机上安装一个Google Cardboard应用,并将 ...
- cf E. Fox and Card Game
http://codeforces.com/contest/389/problem/E 题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的 ...
- WSS存储服务器(Windows Storage Server) 2012新功能解析
虽然最近一段时间有关微软的新闻大多数集中在Windows 8以及Surface平板设备身上,但数周之前Windows Server 2012新版本中所包含的Windows Storage Server ...
- dwr消息推送和tomcat集群
网友的提问: 项目中用到了dwr消息推送.而服务端是通过一个http请求后 触发dwr中的推送方法.而单个tomcat中.服务器发送的http请求和用户都在一个tomcat服务器中.这样就能精准推送到 ...
- ♫【Underscore.js】
Underscore.js Underscore.js 1.5.2 中文文档 Underscore 是一个JavaScript实用库,提供了类似Prototype.js (或 Ruby)的一些功能,但 ...
- Hadoop core-site.xml 配置项列表
core-default.xml与core-site.xml的功能是一样的,如果在core-site.xml里没有配置的属性,则会自动会获取core-default.xml里的相同属性的值 官方文档: ...
- bzoj 3158 千钧一发(最小割)
3158: 千钧一发 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 767 Solved: 290[Submit][Status][Discuss] ...