技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 发现 --> 在Ubuntu上使用SystemTap

在Ubuntu上使用SystemTap

浏览:2889次  出处信息

虽然很早以前听说过,但基本没用过,最近褚霸同学的介绍,勾起了我对这个东西的兴趣。最近在工作笔记本上装了个Ubuntu10.10做为主操作系统,因此正好在上面也实验学习下SystemTap。

安装systemtap

sudo apt-get install systemtap

Ubuntu Desktop默认没有安装kernel debug info的包,systemtap无法追踪内核信息。查看内核版本

ningoo@ning:~/stap$ uname -r
2.6.35-22-generic

这里下载对应的kernel debug info包,安装

sudo dpkg -i linux-image-2.6.35-22-generic-dbgsym_2.6.35-22.35_i386.ddeb

至此内核追踪已经可以执行,但module的信息还需要多做些工作

sudo apt-get install elfutils

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-2`
      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

Hello world

ningoo@ning:~/stap$ sudo stap -ve 'probe begin { log("hello world") exit() }'
Pass 1: parsed user script and 72 library script(s)
 using 18896virt/12868res/1880shr kb, in 130usr/20sys/150real ms.
Pass 2: analyzed script: 1 probe(s), 2 function(s), 0 embed(s), 0 global(s)
 using 19160virt/13132res/1908shr kb, in 10usr/0sys/5real ms.
Pass 3: using cached /home/ningoo/.systemtap/cache
 /f1/stap_f10ab2aeba4f2da2c03646b27b4d3627_757.c
Pass 4: using cached /home/ningoo/.systemtap/cache
 /f1/stap_f10ab2aeba4f2da2c03646b27b4d3627_757.ko
Pass 5: starting run.
hello world
Pass 5: run completed in 0usr/30sys/297real ms.

参考:
http://sourceware.org/systemtap/documentation.html

建议继续学习:

  1. linux内核研究笔记(一)内存管理 – page介绍    (阅读:8009)
  2. Linux下如何知道文件被那个进程写    (阅读:4711)
  3. PHP内核介绍及扩展开发指南―Extensions 的编写    (阅读:4449)
  4. 我的内核配置文件    (阅读:3496)
  5. Linux内核协议栈对于timewait状态的处理    (阅读:3457)
  6. PHP内核介绍及扩展开发指南―高级主题    (阅读:3382)
  7. PHP内核介绍及扩展开发指南―基础知识    (阅读:3179)
  8. 在 Dell PowerEdge 1950 上安装 Linux 2.6.32-rc8 内核的问题与解决    (阅读:2898)
  9. Linux内核模块开发(笔记)    (阅读:2867)
  10. 内核编译升级失败了以后的处理方案    (阅读:2836)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1