How can we use perf to generate call-graphs? (Android 4.2.2 (JellyBean) on Sabre SD board)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can we use perf to generate call-graphs? (Android 4.2.2 (JellyBean) on Sabre SD board)

1,696 Views
floriang
Contributor III

Hello!

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

            |

            --- 0x78a8ea54

     1.84%  fec.fecbench  libFecBenchNative.so   [.] rand

            |

            --- 0x78a8ea3c

               |         

                --100.00%-- 0x0

            |

            --- 0x78a8ea54

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

        |
        --- _raw_spin_unlock_irqrestore

           |    
           |--55.21%-- do_send_sig_info

           |      kill_pid_info

           |      sys_kill

           |      ret_fast_syscall

           |      0x78a8ea54
           |    
           |--15.10%-- try_to_wake_up

           |      |    
           |      |--68.97%-- run_timer_softirq

           |      |      __do_softirq

           |      |      irq_exit

           |      |      do_local_timer

           |      |      __irq_usr

           |      |      |    
           |      |      |--65.00%-- 0x78a8ea54
           |      |      |    
           |      |      |--20.00%-- 0x78a8ea3c

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...

0 Kudos
0 Replies