I’ve written myself a small C++ test program that I want to profile using perf on an arm. Running and profiling the program on my x86 WSL produces expected perf results. However when I profile the program on the arm system, the perf report contains no callstacks and shows different methods compared to the x86 output. I wil show my program, the perf output of the x86 and the perf output of the arm.
My program has a main function that continuously loops a short and a long method, which both call run.
#include <map>
int run(int loop, std::map<int,int> m)
{
int x = 0;
for(int i = 0; i < loop; i++)
{
x += i + i * x;
m.insert({i,x});
}
return x;
}
int short_method(std::map<int,int> m)
{
return run(100, m);
}
int long_method(std::map<int,int> m)
{
return run(10000, m);
}
int main()
{
while(true)
{
std::map<int,int> m;
short_method(m);
long_method(m);
}
return 0;
}
First look at the expected behavior under x86 WSL.
Compilation and profiling:
g++ -g -O0 main.cpp
perf record -g -F 1000 -p$(pgrep -d, a.out) sleep 5
[ perf record: Woken up 3 times to write data ]
[ perf record: Captured and wrote 0.637 MB perf.data (5002 samples) ]
perf report -g
Output:
perf output of example program on x86 WSL
Now compilation and profiling on the arm system:
arm-__-linux-gnueabi-g++ -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -O0 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/sdk/sysroots/cortexa7t2hf-neon-vfpv4-__-linux-gnueabi -g -fno-omit-frame-pointer main.cpp -o a_arm.out
perf record -g -F 1000 -p 405 sleep 5
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.346 MB perf.data (5005 samples) ]
perf report -g
Output:
perf output on arm
In this screenshot you can see what bothers me. Different calls are at the top of execution time, its not clearly visible that most of the time is spent in main and on openening any of the top most functions, I do not see a proper callstack, telling me who calls the functions or what functions are being called.
I wonder why I don’t have a callstack here, any ideas?
Max is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.