gprof : How to generate call graph for functions in shared library that is linked to main program

前端 未结 3 519
一个人的身影
一个人的身影 2020-12-24 12:44

I am working on Linux environment. I have two \'C\' source packages train and test_train.

  1. train package when compiled generates libtrain.so
  2. test_train
3条回答
  •  被撕碎了的回忆
    2020-12-24 13:11

    I'm loading my library from Python and didn't have any luck with sprof. Instead, I used oprofile, which was in the Fedora repositories, at least:

    operf --callgraph /path/to/mybinary

    Wait for your application to finish or do Ctl-c to stop profiling. Now let's generate a profile summary:

    opreport --callgraph --symbols

    See the documentation to interpret it. It's kind of a mess. In the generated report, each symbol is listed in a block of its own. The block's main symbol is the one that's not indented. The items above it are functions that call that function, and the ones below it are the things that get called by it. The percentages in the below section are the relative amount of time it spent in those callees.

提交回复
热议问题