systemtap install ubuntu

11 篇文章 1 订阅

机器环境

uname -r

4.15.0-47-generic

uname -a

Linux jinbo-Latitude-E5440 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
安装systemtap
sudo apt-get install systemtap systemtap-runtime

检测安装

执行命令测试一下或者使用stap-prep 查看

stap -v -e 'probe vfs.read {printf(“read performed\n”); exit()}'

WARNING: Kernel function symbol table missing [man warning::symbols]
Pass 1: parsed user script and 465 library scripts using 126200virt/44648res/7372shr/37716data kb, in 120usr/10sys/137real ms.
semantic error: while resolving probe point: identifier 'kernel' at /usr/share/systemtap/tapset/linux/vfs.stp:915:18
        source: probe vfs.read = kernel.function("vfs_read")
                                 ^
 
semantic error: missing x86_64 kernel/module debuginfo [man warning::debuginfo] under '/lib/modules/4.15.0-47-generic/build'
 
semantic error: resolution failed in alias expansion builder
 
semantic error: while resolving probe point: identifier 'vfs' at <input>:1:7
        source: probe vfs.read {printf("read performed\n"); exit()}
                      ^
 
semantic error: no match
 
Pass 2: analyzed script: 0 probes, 0 functions, 0 embeds, 0 globals using 127256virt/46552res/7996shr/38772data kb, in 30usr/100sys/124real ms.
Pass 2: analysis failed.  [man error::pass2]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.

stap-prep

You need package linux-image-4.15.0-47-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

安装 linux-image-4.15.0-47-generic-dbgsym

根据提示进入 https://wiki.ubuntu.com/DebuggingProgramCrash

CRTL+F  搜索 "Non-built-in debug symbol packages (*-dbgsym)" 

或者直接访问如下链接:
https://wiki.ubuntu.com/DebuggingProgramCrash#Non-built-in_debug_symbol_packages_.28.2A-dbgsym.29

创建 /etc/apt/sources.list.d/ddebs.list

echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list

echo -e "deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse\ndeb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list


sudo apt install ubuntu-dbgsym-keyring


sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622

sudo apt-get update

继续检测

stap-prep

Please install linux-image-4.15.0-47-generic-dbgsym

根据提示安装:

sudo apt-get install linux-image-4.15.0-47-generic-dbgsym

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  linux-image-unsigned-4.15.0-47-generic-dbgsym
The following NEW packages will be installed:
  linux-image-4.15.0-47-generic-dbgsym linux-image-unsigned-4.15.0-47-generic-dbgsym
0 upgraded, 2 newly installed, 0 to remove and 46 not upgraded.
Need to get 781 MB of archives.
After this operation, 5,485 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ddebs.ubuntu.com bionic-updates/main amd64 linux-image-unsigned-4.15.0-47-generic-dbgsym amd64 4.15.0-47.50 [781 MB]
Get:1 http://ddebs.ubuntu.com bionic-updates/main amd64 linux-image-unsigned-4.15.0-47-generic-dbgsym amd64 4.15.0-47.50 [781 MB]
Get:1 http://ddebs.ubuntu.com bionic-updates/main amd64 linux-image-unsigned-4.15.0-47-generic-dbgsym amd64 4.15.0-47.50 [781 MB]
Get:1 http://ddebs.ubuntu.com bionic-updates/main amd64 linux-image-unsigned-4.15.0-47-generic-dbgsym amd64 4.15.0-47.50 [781 MB]
Get:2 http://ddebs.ubuntu.com bionic-updates/main amd64 linux-image-4.15.0-47-generic-dbgsym amd64 4.15.0-47.50 [12.9 kB]       
Fetched 618 MB in 5h 18min 8s (32.4 kB/s)                                                                                       
Selecting previously unselected package linux-image-unsigned-4.15.0-47-generic-dbgsym.
(Reading database ... 262650 files and directories currently installed.)
Preparing to unpack .../linux-image-unsigned-4.15.0-47-generic-dbgsym_4.15.0-47.50_amd64.ddeb ...
Unpacking linux-image-unsigned-4.15.0-47-generic-dbgsym (4.15.0-47.50) ...
Selecting previously unselected package linux-image-4.15.0-47-generic-dbgsym.
Preparing to unpack .../linux-image-4.15.0-47-generic-dbgsym_4.15.0-47.50_amd64.ddeb ...
Unpacking linux-image-4.15.0-47-generic-dbgsym (4.15.0-47.50) ...
Setting up linux-image-unsigned-4.15.0-47-generic-dbgsym (4.15.0-47.50) ...
Setting up linux-image-4.15.0-47-generic-dbgsym (4.15.0-47.50) ...

注:包有安装包有些大
Need to get 781 MB of archives.
After this operation, 5,485 MB of additional disk space will be used.

再次检测安装环境

stap-prep
没有任何提示,恭喜你安装成功了!

运行测试执行脚本

stap -v -e 'probe vfs.read {printf(“read performed\n”); exit()}'

Pass 1: parsed user script and 465 library scripts using 122716virt/49568res/7224shr/42640data kb, in 110usr/20sys/132real ms.
Pass 2: analyzed script: 1 probe, 1 function, 7 embeds, 0 globals using 348260virt/276660res/8656shr/268184data kb, in 2030usr/250sys/2291real ms.
Pass 3: translated to C into "/tmp/stap4N1z5i/stap_b59c23d8c67219a47c3e7d36242c79ab_2666_src.c" using 348260virt/276852res/8848shr/268184data kb, in 10usr/10sys/6real ms.
Pass 4: compiled C into "stap_b59c23d8c67219a47c3e7d36242c79ab_2666.ko" in 2460usr/430sys/2666real ms.
Pass 5: starting run.
read performed
Pass 5: run completed in 20usr/30sys/522real ms.

注:建议使用sudo 执行,或者按提示添加用户组

附件

https://sourceware.org/systemtap/SystemTap_Beginners_Guide.pdf

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值