GPerfTools not showing function names

524 views Asked by At

I am new to profiling and am trying to create a flat profile for my c++ project. Looks like gperftools is popular. I installed gperftools using Homebrew and followed this simple tutorial

When I try creating a flat profile, using pprof --text ./my_program_name my_program_name.prof, A profile is generated but some of the profile is just memory addresses and not function names. Part of the generated profile is shown below.

 3585  25.5%  25.5%     3585  25.5% 0x00007ff812f740ea
 1780  12.6%  38.1%     1780  12.6% 0x00007ff812f728d2
  484   3.4%  41.6%      866   6.2% Block::Block@100005fc0
  419   3.0%  44.5%      782   5.6% _OSSL_PARAM_locate
  363   2.6%  47.1%      378   2.7% std::__1::basic_string::__zero

For reference, I am compiling my code using g++ -std=c++17 -lprofiler -lpthread -lcrypto my_program_name.cpp -o my_program_name

I am not sure why some of the profile is memory addresses. When I create the profile using the pprof command, A bunch of errors show up before the profile is generated. The errors all are a missing file in /usr/lib or /usr/lib/system. Errors look like the one shown below.

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: /usr/lib/liboah.dylib (No such file or directory)

I am really not sure what to do. Any help would be appreciated. Thank you! Also, running on macOS Monterey 12.3.1.

1

There are 1 answers

0
frank On

tcmalloc & pprof must be match.

For example: link libtcmalloc.a in location:
/usr/local/Cellar/gperftools/2.9.1_1/lib/libtcmalloc.a

pprof should be /usr/local/Cellar/gperftools/2.9.1_1/bin/pprof