systemTap的安装(设备端,交叉编译工具链)

一、systemtap工具编译

1.1、需要的源码,源码下载路径

https://sourceware.org/systemtap/ftp/releases/

http://zlib.net/

https://sourceware.org/elfutils/ftp/

1.2、交叉编译

编译前在工具链目录下搜索是否存在obstack.h fts.h头文件,编译elfutils需要

1.2.1、编译zlib库

tar -zxf zlib-1.2.11.tar.gz

cd zlib-1.2.11

CC=arm-linux-gcc ./configure --prefix=/home/dyh/tools/systemtap/zlib-1.2.11/output

make

make install

1.2.2、编译elfutils工具包

tar -xf elfutils-0.166.tar.bz2

cd elfutils-0.166

export LDFLAGS=-L/home/dyh/tools/systemtap/zlib-1.2.11/output/lib

export CPPFLAGS=-I/home/dyh/tools/systemtap/zlib-1.2.11/output/include

export LIBS=-lz

./configure --host=arm-linux --prefix=/home/dyh/tools/systemtap/elfutils-0.166/output --with-zlib

make

make install

1.2.3、编译systemtap工具

1.2.3.1、编译脚本

tar -zxf systemtap-3.0.tar.gz

cd systemtap-3.0

./configure --host=arm-linux --with-elfutils=/home/dyh/tools/systemtap/elfutils-0.166 CXXFLAGS=-static CFLAGS=-static --prefix=/home/dyh/tools/systemtap/systemtap-3.0/output --exec-prefix=/home/dyh/tools/systemtap/systemtap-3.0/output/usr --disable-docs --disable-refdocs --disable-grapher --without-rpm --disable-option-checking --disable-nls --enable-FEATURE=no --disable-ssp --without-nss --disable-translator

make

make install

1.2.3.2、编译遇到的问题

问题:找不到头文件



解决:添加头文件路径

./staprun/Makefile中CPPFLAGS变量后补充1.2.2生成libelf.h头文件的路径



问题:找不到动态库

 

解决:添加动态库路径

./staprun/Makefile中LDFLAGS变量后补充1.2.2生成libelf.so动态库的路径



2、验证systemtap能否正常工作

2.1、创建hello-world.stap脚本

PC端(https://blog.csdn.net/sydyh43/article/details/119281834)

probe begin

{

print ("hello world.\n")

exit ()

}

2.2、编译hello-world.stap脚本,生成hello-world.ko文件

/home/dyh/tools/systemtap/systemtap-3.0/host-output/bin/stap -gv -a arm -r /home/dyh/tools/systemtap/systemtap-3.0/host-output -B CROSS-COMPILE=arm-linux- -m hello-world.ko hello-world.stap

设备端

2.3、将1.2.3编译出来的staprun、stapio和3.2编译出来的hello-world.ko拷贝到根文件系统目录,制作根文件系统

2.4、设备上运行staprun hello-world.ko能否输出hello world



3、systemTap的使用

https://sourceware.org/systemtap/wiki

https://segmentfault.com/a/1190000010774974

PS:

1、stap命令与staprun命令的区别在于:

stap命令的操作对象是stp文件或script命令等,而staprun命令的操作对象是编译生成的内核模块。

2、设备使用systemtap,内核需要打开以下功能

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值