0

I try to profile functions provided by a shared library using sprof. The profiling works but the column containing the function names is very ugly formatted. I'm using for example the unordered_map provided by boost. The associated entry in the flat profile is:

Each sample counts as 0.01 seconds.
%   cumulative   self              self     total
time   seconds   seconds    calls  us/call  us/call  name
[...]
0.12     78.47     0.10   232327     0.43            _ZN5boost9unordered13unordered_mapIN4BALL6StringES3_NS_4hashIS3_EESt8equal_toIS3_ESaISt4pairIKS3_S3_EEEC1ERKSC_
[...]

I used the same commands as described in the sprof man page. I just changed the paths. The whole profile is difficult to read because one cannot see clearly the namespaces, class names, function names, etc.

I tried the small example of the sprof man page and it worked well.

Does anyone know why the name column is so ugly formatted here?

osgx
  • 90,338
  • 53
  • 357
  • 513
Fex
  • 322
  • 1
  • 13

1 Answers1

1

Names like '_ZN5boost9unordered13unordered_mapIN4BALL6StringES3_NS_4hashIS3_EESt8equal_toIS3_ESaISt4pairIKS3_S3_EEEC1ERKSC_' are from C++ name mangling. Namespaces, class names, template arguments, function name, function argument types are recorded in the name. With mangling, there are some additional features of C++ like overloading method for different arguments and templates to generate type-specific code.

You may filter the output with c++filt program which demangles most C++ symbol names to C++ code-like format, readable by human.

There are also online services to demangle names: https://demangler.com/ It demangles your symbol to:

boost::unordered::unordered_map<BALL::String, BALL::String, boost::hash<BALL::String>, std::equal_to<BALL::String>, std::allocator<std::pair<BALL::String const, BALL::String> > >::unordered_map(boost::unordered::unordered_map<BALL::String, BALL::String, boost::hash<BALL::String>, std::equal_to<BALL::String>, std::allocator<std::pair<BALL::String const, BALL::String> > > const&)

or, if we rewrite it:

boost::unordered_map<BALL::String, BALL::String...>::
 unordered_map(boost::unordered::unordered_map<BALL::String, BALL::String...> const&)

or finally - it is copy constructor

unordered_map<String, String...>::unordered_map( unordered_map<String, String...> const&)
osgx
  • 90,338
  • 53
  • 357
  • 513