使用Babeltrace构建Perf(用于Perf到CTF的转换) [英] Building Perf with Babeltrace (for Perf to CTF Conversion)

查看:288
本文介绍了使用Babeltrace构建Perf(用于Perf到CTF的转换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用TraceCompass以便进一步调查我的系统跟踪.为此,您需要CTF格式,并且有两种在Linux中获取它的可能方法,即afaik:

  1. 使用LTTng进行跟踪并从中使用CTF格式
  2. 使用"perf数据转换"以从perf.data创建CTF数据

我一直在尝试使用第二个选项,因为第一个选项需要安装跟踪点,而从perf获得的内容对我来说就足够了. 因此,假设我有perf.data可用, 正在申请

perf data convert --to-ctf=./ctf 

结果:不编译任何版本支持. 从lwn浏览在线资源,我发现没有babeltrace不能进行这种转换.为了安装babeltrace,我尝试了以下方法:

第一个:

sudo apt-get install libbabeltrace-ctf-dev libbabeltrace-ctf1 libbabeltrace1 libbabeltrace-dev python3-babeltrace

不能完全解决以下问题:不编译任何版本支持.

第二个

我尝试从源代码构建babeltrace.我事先挖出并找到了所有依赖项:

sudo apt-get install dh-autoreconf bison libdw-dev libelf-dev flex uuid-dev libpopt-dev
git clone git://git.efficios.com/babeltrace.git
cd babeltrace
./bootstrap
sudo ./configure --prefix=/opt/libbabeltrace LDFLAGS=-L/usr/local/lib
sudo make -j4 prefix=/opt/libbabeltrace
sudo make install prefix=/opt/libbabeltrace

然后尝试

LD_LIBRARY_PATH=/opt/libbabeltrace/lib perf data convert --to-ctf=./ctf

这还会导致错误:不编译任何版本支持.

总而言之,我现在认为问题在于将babeltrace与perf相关联.虽然我还不知道如何在babeltrace支持下编译perf.我应该从内核模块构建所有内容(如下所述),还是有一种变通办法来重新编译或改编具有babeltrace支持的当前性能?

请注意,perf/core_ctf_convert是在以下内核模块中实现的:git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git

还请注意,我在Raspberry Pi 3上使用Raspbian Jessie.

先要感谢指导.

干杯

参考:

https://lwn.net/Articles/634333/

http://tracingsummit.org/w/images /9/98/TracingSummit2014-Perf-CTF.pdf

https://patchwork.kernel.org/patch/5883821/

https://patchwork.kernel.org/patch/5858601/


已解决 好的,这很棘手.首先,所有功劳归功于kernel.org的jolsa,他的建议使我明白了这一点.

从源代码构建libbabeltrace之后,将执行以下操作:

已安装一些依赖项(可能不需要一些依赖项,这些是我为满足Raspbian的大多数跟踪功能而安装的.不幸的是,bfd不可用,afaik)

sudo apt-get install libnewt-dev binutils-arm-none-eabi libcrypto++-dev libunwind-dev systemtap-sdt-dev libssl-dev libperl-dev libiberty-dev

然后

sudo git clone git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
cd linux/tools/perf
sudo git checkout perf/core
sudo LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make
sudo LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make install

安装完成后,使用LD_LIBRARY_PATH env执行性能.即

在perf.data所在的目录中,假设新建的perf位于/home/user/linux/tools/perf,请调用以下命令:

sudo LD_LIBRARY_PATH=/opt/libbabeltrace/lib ./home/user/linux/tools/perf/perf data convert --to-ctf=./ctf

然后,将CTF导入到TraceCompass:)

解决方案

您需要 build 与Babeltrace链接的perf以获得perf data convert支持(AFAIK).是的,您需要您的内核源代码树来执行此操作(您的确切版本).

  1. 获取Linux内核的源代码树.您可能应该使用发行版的内核源代码树:这可能包括修改主线项目的补丁.例如,请参见使用Ubuntu版本获取内核源代码.

    对于主线内核:

    git clone https://github.com/torvalds/linux.git
    

    别忘了签出适当的分支/标记/提交.

  2. 确保使用发行版的软件包(apt-get等)或通过从源代码构建(./configure; make; make install)来将Babeltrace安装到某个位置.

  3. 在内核源树根目录的tools/perf中,运行:

    LIBBABELTRACE=1 make
    

    如果系统目录中未安装Babeltrace,请使用LIBBABELTRACE_DIR指定自定义的Babeltrace安装目录:

    LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make
    

tools/perf/perf是您的perf实用程序,针对具有CTF转换支持的特定内核而构建.

I am trying to use TraceCompass in order to further investigate my system trace. For that purpose, you need CTF format and there are two possible ways to obtain it in Linux, afaik:

  1. Using LTTng for tracing and using CTF format from that
  2. Using 'perf data convert' in order to create CTF data from perf.data

I have been trying to use the second option as the first one requires installation of tracepoints and what I got from perf is simply enough for me. So assuming I have my perf.data available, Applying

perf data convert --to-ctf=./ctf 

resulted in: No version support compiled in. Digging into the online resources from lwn, I have found out that this conversion is not available without babeltrace. In order to install babeltrace I have tried following methods:

1st one:

sudo apt-get install libbabeltrace-ctf-dev libbabeltrace-ctf1 libbabeltrace1 libbabeltrace-dev python3-babeltrace

which did not quite solve the problem of: No version support compiled in.

2nd one

I have tried building babeltrace from source. I dug and found all its dependencies beforehand:

sudo apt-get install dh-autoreconf bison libdw-dev libelf-dev flex uuid-dev libpopt-dev
git clone git://git.efficios.com/babeltrace.git
cd babeltrace
./bootstrap
sudo ./configure --prefix=/opt/libbabeltrace LDFLAGS=-L/usr/local/lib
sudo make -j4 prefix=/opt/libbabeltrace
sudo make install prefix=/opt/libbabeltrace

Then tried,

LD_LIBRARY_PATH=/opt/libbabeltrace/lib perf data convert --to-ctf=./ctf

Which also resulted in the error: No version support compiled in.

So, all in all, right now I think that the problem is linking babeltrace with perf. Though I do not know yet how to compile perf with babeltrace support. Should I build everything from kernel modules (given below) or is there a workaround to re-compile or adapt my current perf with babeltrace support?

Please note that perf/core_ctf_convert is implemented in this kernel module: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git

Also note that I am using Raspbian Jessie on a Raspberry Pi 3.

Guidance is appreciated in advance.

Cheers,

References:

https://lwn.net/Articles/634333/

http://tracingsummit.org/w/images/9/98/TracingSummit2014-Perf-CTF.pdf

https://patchwork.kernel.org/patch/5883821/

https://patchwork.kernel.org/patch/5858601/


EDIT : RESOLVED Okay, this was tricky. First off, all credits go to jolsa from kernel.org who with his suggestions made me figure this out.

After the libbabeltrace is built from source, the following is done:

Some dependencies installed (some might not be needed, these are what I've installed to fulfil most of the tracing features available for Raspbian. Unfortunately bfd is not available, afaik)

sudo apt-get install libnewt-dev binutils-arm-none-eabi libcrypto++-dev libunwind-dev systemtap-sdt-dev libssl-dev libperl-dev libiberty-dev

Then,

sudo git clone git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
cd linux/tools/perf
sudo git checkout perf/core
sudo LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make
sudo LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make install

After the installation is complete, the perf is executed with the LD_LIBRARY_PATH env. i.e.

From the directory where perf.data is located, call the following assuming the newly built perf is located at /home/user/linux/tools/perf:

sudo LD_LIBRARY_PATH=/opt/libbabeltrace/lib ./home/user/linux/tools/perf/perf data convert --to-ctf=./ctf

And then, the CTF could be imported to TraceCompass :)

解决方案

You need to build perf linked with Babeltrace for perf data convert support (AFAIK). Yes you need your kernel source tree to do this (your exact version).

  1. Get your Linux kernel's source tree. You should probably use your distribution's kernel source tree: this could include patches which modify the mainline project. For example, see Obtaining the kernel sources for an Ubuntu release using git.

    For the mainline kernel:

    git clone https://github.com/torvalds/linux.git
    

    Don't forget to check out the appropriate branch/tag/commit.

  2. Make sure Babeltrace is installed to some location, either using your distribution's package (apt-get, etc.) or by building it from source (./configure; make; make install).

  3. In tools/perf from the kernel source tree's root, run:

    LIBBABELTRACE=1 make
    

    If Babeltrace is not installed in a system directory, use LIBBABELTRACE_DIR to specify a custom Babeltrace installation directory:

    LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make
    

tools/perf/perf is your perf utility, built for your specific kernel with CTF conversion support.

这篇关于使用Babeltrace构建Perf(用于Perf到CTF的转换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆