I would like to generate call-graphs to track optimizations that should be done in the source code of a complex application.
I tried to use oprofile and perf, but both fail to generate a proper call-graph for the part that is related to my library.
perf is able to generate a callgraph for kernel functions if provided with the kernel symbols.
I compiled my native library with the following flags:
LOCAL_CFLAGS := -g -fno-omit-frame-pointer $(LOCAL_CFLAGS)
Then when I get samples for the call graph I use:
perf record -g -ecpu-clock -c50000 -p<mypid>
and output the report via:
perf report -g > perfoutput.txt
When I look at this report, the hierarchy doesn't appear for the functions that are in my library. I got somethign like:
7.43% fec.fecbench libFecBenchNative.so [.] FecBench7_NoOp3
1.84% fec.fecbench libFecBenchNative.so [.] rand
But actually I call rand() inside the FecBench_NoOp3 function, which is called by FecBench_NoOp2 function.
I expected the output to be something like:
FecBench_NoOp2 ---> FecBench_NoOp3 ---> rand().
But it seems that perf can not see that these functions are actually related.
But for the kernel functions I get a correct graph like:
|0.11% fec.fecbench [kernel]||[k] _raw_spin_unlock_irqrestore|
Any ideas? Don't hesitate to suggest another solution if you know of a good way to get a callgraph in android for native code.
I also tried with Oprofile but I think it didn't even give anything useful on the kernel...