Ubuntu 安装 SystemTap_ubuntu安装systemtap_替换法fj的博客-程序员秘密

技术标签: 调试  Linux  性能优化  linux  

Systemtap 简介

借用官方的话就是:

  1. 收集 linux 以及运行在linux 系统上程序的运行的信息
  2. 调查程序的性能

怎么安装呢

对于 ubuntu 系统来说直接

sudo apt-get install systemtap

那么 centos 就是

yum install systemtap

上面安装的 systemtap 有一定程度不可用,例如在运行的时候出现 这个问题,部分截图如下所示:
在这里插入图片描述

出现上面问题的原因是 linux 内核版本太新,而 systemtap 版本太旧导致的,这个时候需要用源码安装。

1. 下载源码

官方的 release 版本。从里面挑选最新的版本来安装。比如 ubuntu 20,那么就选 systemtap-4.6.tar.gz

wget https://sourceware.org/systemtap/ftp/releases/systemtap-4.6.tar.gz

下载完包以后直接解压:

tar -zxf systemtap-4.6.tar.gz

2. 安装相关依赖

sudo apt-get install build-essential
sudo apt-get install gettext
sudo apt-get install elfutils
sudo apt-get install libdw-dev

3. 编译

cd 到systemtap-4.6目录中进行编译

cd systemtap-4.6
./configure

make -j4 && sudo make install

4. 安装内核 debug info

由于ubuntu 桌面版默认没有安装kernel-debug-info,所以安装了systemtap后仍然不能够追踪内核信息,因此需要手动安装kernel-debug-info包

1. 查看当前内核版本

uname -a

输出:

Linux dev-25 5.13.0-35-generic #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

2. 寻找合适的 debug info

这里需要根据机器具体的架构选择

wget http://ddebs.ubuntu.com/pool/main/l/linux/linux-image-unsigned-5.13.0-35-generic-dbgsym_5.13.0-35.40_amd64.ddeb

3. 安装

sudo dpkg -i  linux-image-unsigned-5.13.0-35-generic-dbgsym_5.13.0-35.40_amd64.ddeb

4. 安装elfutils并进行相应配置

sudo apt-get install elfutils

5.最后进行测试

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

在这里插入图片描述
结果如上所示,表示成功安装

如何删除

1.apt-get安装

sudo apt-get remove systemtap

2.安装包安装

进入systemtap文件夹

make uninstall

安装中出现的问题

1. configure时

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

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

2.make时

1. 问题一

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,然后安装。

2. 问题二

内存不足时

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.

系统没有交换分区, 编译过程中内存耗尽, 导致了编译中断

//创建分区文件[email protected]:~/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
[email protected]:~/systemtap-3.2# //生成swap文件系统
[email protected]:~/systemtap-3.2# sudo mkswap /swapfile 
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=5d981976-9350-4fe8-bb06-5aac1b41c220
[email protected]:~/systemtap-3.2# //激活swap文件
[email protected]:~/systemtap-3.2# swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.

安装了4.4版本的SystemTap,./configure无误,make时换了一个错误

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

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

sudo apt-get install python-dev

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

[email protected]:~# 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]
[email protected]:~# 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’

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

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

缺少 Python module Setuptools,参考

To install setuptools on Debian:

sudo apt-get install python3-setuptools

For an older version of Python (Python 2.x):

sudo apt-get install python-setuptools
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_39932195/article/details/123919394

智能推荐

拖拽------阻止浏览器默认事件_拖拽为什么要组织默认事件_youyou_builder的博客-程序员秘密

用原生js写一个拖拽,需要考虑到兼容的问题,事件绑定的问题,浏览器默认事件的问题。首先需要用到Event 对象,代表事件的状态,比如事件在其中发生的元素、键盘按键的状态、鼠标的位置、鼠标按钮的状态。代码如下:<!DOCTYPE html><html lang="en"><head> <meta c...

【问题记录】raise IndexError(‘index {} is out of range‘.format(idx)) index 0 is out of range_march of Time的博客-程序员秘密

今天训练模型输入python3 train.py --model_def config/yolov3-custom.cfg --data_config config/custom.data第一次出现这个错误,记录解决方案:查了看到有人说什么加上except:continue;大概跟我出的错不一样,总之我没法按照这样解决问题,先截图一下我出问题的界面:File “train.py”, line 62, in model = Darknet(opt.model_def).to(device)File

[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#3_spythree的博客-程序员秘密

编程题#3:发票统计注意: 总时间限制: 1000ms 内存限制: 65536kB描述有一个小型的报账系统,它有如下功能:(1)统计每个人所报发票的总钱数(2)统计每类发票的总钱数将此系统简化为如下:假设发票类别共有A、B、C三种;一共有三个人,ID分别为1、2、3。输入系统输入包含三行,每行第一个数为人员ID(整型,1或2或

Jenkins SSH报错:Exception when publishing, exception message [Exec exit status not zero. Status [1]]_doye_chen的博客-程序员秘密

Jenkins SSH报错:Exception when publishing, exception message [Exec exit status not zero. Status [1]]报错图片:网上通常见到的返回码是-1,而对于1的基本没看到,偶尔找到一两篇博客有提及,但是给出的解决方案也不符合我的情况。这边介绍下我这里遇到的情况。直接上干货。首先,排查下我SSH连接有没有问题,这个可以在Jenkins 系统管理那里找到对应的服务器-配置,点击Test Configurat.

常用的Linux命令_我只会发热的博客-程序员秘密

整理文档的时候突然发现这么个东西,顺手发出来,后面看浏览量和点赞量再做补充或者调整Linux作为每个程序员都要打交道的系统,其操作命令实在是太重要了chmod赋予权限数字权限意义chmod是Linux下设置文件权限的命令,后面的数字表示不同用户或用户组的权限。一般是三个数字:第一个数字表示文件所有者的权限第二个数字表示与文件所有者同属一个用户组的其他用户的权限第三个数字表示其它用户组的权限。权限分为三种:读(r=4),写(w=2),执行(x=1)。综合起来还有可读可执行(rx.

UITableView学习笔记_anmumi8165的博客-程序员秘密

UITableView学习笔记                                 作者:一片枫叶  看TableView的资料其实已经蛮久了,一直想写点儿东西,却总是因为各种原因拖延,今天晚上有时间静下心来记录一些最近学习的TableView的知识。下面进入正题,UITableView堪称UIKit里面最复杂的一个控件了,使用起来不算难,但是要用好并不...

随便推点

国外有什么好的网站推荐?_AndroidCC的博客-程序员秘密

先来一张用百度脑图做的“国外优秀网站”思维导图,让你一目了然。

chrome控制台报错_飞天小虎的博客-程序员秘密

chrome开发者模式控制台报如下错误DevTools failed to load SourceMap: Could not load content for chrome-extension://ncennffkjdiamlpmcbajkmaiiiddgioo/js/xl-content.js.map: HTTP error: status code 404, net::ERR_UNKNOW...

ffmpeg基础五:单独解码裸流aac或MP3或H264-程序员秘密

ffmpeg基础五:单独解码裸流aac或MP3或H264用于解析输入的数据流并把它们分成一帧一帧的压缩编码数据。比较形象的说法就是把长长的一段连续的数据“切割”成一段段的数据。av_parser_parse2():解析数据获得一个Packet, 从输入的数据流中分离出一帧一帧的压缩编码数据。读取文件流,使用av_parser_parse2就可以获取出packet。这也是为什么后面使用。

spring框架入门之一_weixin_30642869的博客-程序员秘密

一.什么是Spring框架  1.什么是Spring    Spring框架是个一个全栈的框架.意思就是使用Spring的框架可以开发web层,service层还有dao层.    本质:Spring就是一个对象的容器,因为在这个容器中有可以处理请求的对象,所以可以用来写web层,因为有service层对象,所以可以用来写service层,因为有dao层对象,所以可以用...

简单的五子棋小游戏(html+css+js)_html五子棋代码可复制_瑟瑟发抖的小喵喵的博客-程序员秘密

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>五子棋</title> <style type="text/css"> canvas { display: block;

推荐文章

热门文章

相关标签