Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No function names when using gperftools/pprof

I've been trying to get gperftools CPU profiling working on my program.

I'm running into an issue where all the function names in my program are pointer addresses when reported by pprof. Annoyingly, most of the function names from libraries I've linked are readable, but none from my program files are. Example below.

s979258ca% pprof --text ./hmiss hmiss.prof                                        
Using local file ./hmiss.
Using local file hmiss.prof.
Total: 469 samples
     152  32.4%  32.4%      152  32.4% 0x000000010ba6dd45
      47  10.0%  42.4%       47  10.0% 0x000000010ba6d365
      46   9.8%  52.2%       46   9.8% 0x000000010ba6d371
      34   7.2%  59.5%       34   7.2% 0x000000010ba8a04a
      32   6.8%  66.3%       32   6.8% 0x000000010ba6d35a
      10   2.1%  68.4%       10   2.1% 0x000000010ba8873c
       9   1.9%  70.4%        9   1.9% 0x00007fff63f409da
       6   1.3%  71.6%        6   1.3% 0x000000010ba7feca
       6   1.3%  72.9%        6   1.3% 0x00007fff63f40116
       6   1.3%  74.2%        6   1.3% 0x00007fff63f409f2
       5   1.1%  75.3%        5   1.1% 0x000000010ba6dd4c
       ...

What do I need to do to get my functions names included in the pprof output?

Here's what the process to get to the above point looks like for me, if it helps. I build my program with the options below

clang++
"-std=c++17",
"-g",
"-O2",
"...cpp files..."
"-o",
"~/cpp/hmiss/hmiss",
"/usr/local/Cellar/gperftools/2.7/lib/libprofiler.dylib",

I enable CPU profiling with gprof by running

DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib CPUPROFILE=hmiss.prof ./hmiss

I then run pprof --text ./hmiss hmiss.prof

From an answer to a similar question I thought possibly including debugging symbols might get the names in there, but just building my program with -g didn't seem to help. Also, removing the -O2 flag did not help either.

like image 943
Max C Avatar asked Oct 25 '25 16:10

Max C


1 Answers

Use google's pprof instead of brew's pprof https://github.com/google/pprof

like image 189
Micah Martin Avatar answered Oct 28 '25 04:10

Micah Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!