Building Perf with Babeltrace (for Perf to CTF Conversion)
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:
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. ie
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).
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.
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
).
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.
上一篇: 用CAP从bash脚本启动perf