Ubuntu下SystemTap的安装&&问题解决记录

SystemTap的安装方式:

一.直接通过apt-get安装

sudo apt-get install systemtap

二.通过安装包下载

$ sudo apt-get install build-essential
$ sudo apt-get install gettext
$ sudo apt-get install elfutils
$ sudo apt-get install libdw-dev
$ wget https://sourceware.org/systemtap/ftp/releases/systemtap-2.9.tar.gz
$ tar xvzf systemtap-2.9.tar.gz
$ cd systemtap-2.9
$ ./configure
$ make
$ sudo make install

也可以直接在网站(https://sourceware.org/systemtap/ftp/releases/)下载源码压缩包,解压后安装

验证是否安装成功(成功打印出hello systemtap!)

stap -ve 'probe begin { log("hello systemtap!") exit() }'

三.重新安装可能需要卸载之前安装的systemtap

1.apt-get安装
sudo apt-get remove systemtap

2.安装包安装
进入systemtap-2.9文件夹
make uninstall

安装过程中出现的问题:

1../configure时

configure: Running systemtap uninstalled, entirely out of the build tree,
configure: is not supported.

这个问题暂时忽略掉,没解决但是暂时没发现对后续操作有什么影响

configure: error: missing elfutils development headers/libraries (install elfutils-devel, libebl-dev, libdw-dev and/or libebl-devel)
ly@ly-ubuntu:~/Downloads/systemtap-4.4$ sudo apt-get install libdw-dev

2.make时,出现以下问题:

bpf-translate.cxx:37:29: fatal error: elfutils/libebl.h: No such file or directory
compilation terminated.
Makefile:1677: recipe for target 'stap-bpf-translate.o' failed

因为提示elfutils相关,所以一直以为是elfutils的安装问题,但是通过尝试,猜想是因为elfutils已经更新了版本,但我们安装的是2.9版本的SystemTap,复盘的时候觉得应该是重新安装到最新版本4.4的SystemTap解决了这个问题

就根据之前的步骤,下载4.4版本的SystemTap,然后安装

3.make时,编译时内存不足(系统没有交换分区, 编译过程中内存耗尽, 导致了编译中断)

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
//创建分区文件
root@ubuntu:~/systemtap-3.2# sudo dd if=/dev/zero of=/swapfile bs=64M count=16 16+0 records in 16+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.7991 s, 283 MB/s root@ubuntu:~/systemtap-3.2#
//生成swap文件系统 root@ubuntu:
~/systemtap-3.2# sudo mkswap /swapfile Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) no label, UUID=5d981976-9350-4fe8-bb06-5aac1b41c220 root@ubuntu:~/systemtap-3.2#
//激活swap文件 root@ubuntu:
~/systemtap-3.2# swapon /swapfile swapon: /swapfile: insecure permissions 0644, 0600 suggested.

4.安装了4.4版本的SystemTap,./configure无误,make时换了一个错误,发现胜利曙光了

HelperSDT/_HelperSDT.c:9:20: fatal error: Python.h: No such file or directory
compilation terminated.

因为没有安装python的开发版,即Python-devel这个包

sudo apt-get install python-dev

5.安装完毕后,执行systemtap的操作报错

root@ubuntu:~# stap -e 'probe begin{printf("hello"); exit();}'  
/usr/local/share/systemtap/runtime/linux/access_process_vm.h:35:54: error: passing argument 6 of ‘get_user_pages’ makes pointer from integer without a cast [-Werror=int-conversion]
root@ubuntu:~# stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
In file included from /usr/share/systemtap/runtime/linux/runtime.h:204:0,
                 from /usr/share/systemtap/runtime/runtime.h:24,
                 from /tmp/stap5B8ZsJ/stap_46c39130569454c3b11457bdcd15b4a0_1277_src.c:25:
/usr/share/systemtap/runtime/linux/access_process_vm.h: In function ‘__access_process_vm_’:
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:54: error: passing argument 6 of ‘get_user_pages’ makes pointer from integer without a cast [-Werror=int-conversion]
/usr/share/systemtap/runtime/linux/access_process_vm.h:35:13: error: too many arguments to function ‘get_user_pages’

这几个报错,找了很久资料,stackflow上有一个问答, 觉得应该是问题的根源:https://stackoverflow.com/questions/46047270/systemtap-error-on-ubuntu

简而言之,就是“Ubuntu的systemtap软件包当前已过期”

那么就通过选择4.4版本的systemtap即可解决

总而言之,在安装过程中遇到的这些错误,通过卸载掉之前低版本的systemtap,安装最新版本的systemtap即可解决

posted @ 2021-02-16 16:56  闲不住的小李  阅读(1178)  评论(0编辑  收藏  举报