Systemtap命令stap----安装

一.安装systemtap

apt-get install systemtap

二.安装内核调试信息

直接在http://ddebs.ubuntu.com/pool/main/l/linux/页面下载下面的包(不需要重新编译内核,只需要下载这个包)

 

linux-image-unsigned-4.15.0-66-generic-dbgsym_4.15.0-66.75_amd64.ddeb(我的CPU是x86_64的下载的这个)

三.测试

stap -p4 sample.stp -m sample (根据sample.stp生成sample.ko,sample.stp的内容在下面)

staprun sample.ko (运行ko)

 运行后不报错就说明安装OK了

注意:如果不安装内核调试信息会遇到如下问题,下面这个过程就是我踩的坑

Ubuntu18.04下安装好Systemtap后运行如下测试命令

stap -p2 sample.stp

其中sample.stp内容如下:

#cat sample.stp 
probe kernel.function("sys_read") { printf("hi from sys_read!\n"); exit() }

1.运行报如下错误

semantic error: while resolving probe point: identifier 'kernel' at sample.stp:1:7
        source: probe kernel.function("sys_read") { printf("hi from sys_read!\n"); exit() }
                      ^

semantic error: missing x86_64 kernel/module debuginfo [man warning::debuginfo] under '/lib/modules/4.15.0-66-generic/build'

Pass 2: analysis failed.  [man error::pass2]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.

 

2.运行stap-prep命令

根据README.Debian的提示需要运行stap-prep命令

To use systemtap you need to manually install the linux-image-*-dbg and linux-header-* packages that match your running kernel. To simplify this task you can use the stap-prep command.

但运行stap-prep后会报如下问题(需要dbgsym信息)

You need package linux-image-4.15.0-66-generic-dbgsym but it does not seem to be available
 Ubuntu -dbgsym packages are typically in a separate repository
 Follow https://wiki.ubuntu.com/DebuggingProgramCrash to add this repository

3.直接在http://ddebs.ubuntu.com/pool/main/l/linux/页面下载下面的包(不需要重新编译内核,只需要下载这个包)

 

linux-image-unsigned-4.15.0-66-generic-dbgsym_4.15.0-66.75_amd64.ddeb(我的CPU是x86_64的下载的这个)

4.下载后运行如下的命令安装

dpkg -i linux-image-unsigned-4.15.0-66-generic-dbgsym_4.15.0-66.75_amd64.ddeb

5.再次运行stap-prep命令

综上,就可以用stap命令了

stap -p4 sample.stp -m sample (根据sample.stp生成sample.ko)

staprun sample.ko (运行ko)

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值