使用Babeltrace构建Perf (用于将Perf转换为CTF)

7
我正在尝试使用TraceCompass进一步研究我的系统跟踪。为此,您需要CTF格式,并且在Linux中有两种可能的方法可以获得它,据我所知:
1. 使用LTTng进行跟踪并从中使用CTF格式 2. 使用'perf data convert'创建来自perf.data的CTF数据
我一直在尝试使用第二个选项,因为第一个选项需要安装tracepoints,而我从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。我应该从内核模块构建所有内容(如下所示),还是有一种解决方法可以重新编译或调整我的当前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不可用)

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环境变量执行perf。例如:
从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中 :)

TraceCompass

1个回答

1
你需要使用Babeltrace构建perf,以支持perf data convert(据我所知)。是的,你需要使用你精确版本的内核源码树来完成这个过程。
  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 是您的性能工具,针对具有CTF转换支持的特定内核进行构建。


请纠正我如果我错了:我输入了以下命令:(1) git clone git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git 然后 (2) cd perf && LIBBABELTRACE=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ make 这导致出现以下错误:找不到配置文件'.config'! 请运行一些配置程序:“make oldconfig”或“make menuconfig”或“make xconfig”。我应该运行哪个配置程序,如何进行配置?你能帮我吗?谢谢。 - mozcelikors
@mozcelikors,请查看我的最新回答并获取更多详细信息。 - eepp

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接