Search code examples
androidlinuxprofilingperf

Perf does not display call graph properly on Android


I am trying to use perf to profile my Android application.

With help of fplutil project I managed to install perf on Android device, run perf record and then perf report on host machine.

Usually when I run perf report -g I expect to see call graph similar to this one:

47.91%    a.out  a.out              [.] f5()
          |
          --- f5()
             |
             |--53.82%-- f4()
             |          |
             |          |--56.16%-- f3()
             |          |          |
             |          |          |--49.14%-- f2()
             |          |          |          |
             |          |          |          |--52.92%-- f1()
             |          |          |          |          a()
             |          |          |          |          main
             |          |          |          |          __libc_start_main
             |          |          |          |
             |          |          |           --47.08%-- a()
             |          |          |                     main
             |          |          |                     __libc_start_main

However when I execute perf report for data collected on Android device I do not see proper call graph, like if stack is not unwinding properly:

4.98%  app_name  my_lib.so  [.] void quat_apply<double>(double*, double const*, double const*, int, double)
            |                                                                                              
            --- 0xbee75fe4                                                                                 

            |                                                                                              
            --- 0xbee760c4                                                                                 

            |                                                                                              
            --- 0xbee75c0c 

What should I do to replace these hex addresses with function names?

I am already building my code with -g and -fno-omit-frame-pointer, am I missing something else?


Solution

  • Bingo!

    -mapcs-frame
    

    Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions, even if this is not strictly necessary for correct execution of the code. Specifying -fomit-frame-pointer with this option causes the stack frames not to be generated for leaf functions. The default is -mno-apcs-frame. This option is deprecated.

    Although option is marked as deprecated, it fixed call graph for me.