0

I have profiled an application using perf, and I am confused why the names of the functions are so mangled in the report. For example, here is the output of perf report:

# Overhead      Command      Shared Object                                                                                                 
# ........  ...........  .................  .................................................................................................................................................................................................
#
    38.98%  hello_sp_tp  libc-2.19.so       [.] __memcpy_sse2_unaligned                                                                                                                                                                      
            |
            --- __memcpy_sse2_unaligned
               |          
               |--21.70%-- _ZN5nupic10algorithms6Cells46CStateaSERKS2_.local.1629
               |          
                --17.28%-- _ZN5nupic10algorithms6Cells46Cells420updateInferenceStateERKSt6vectorIjSaIjEE
                          _ZN5nupic10algorithms6Cells46Cells47computeEPfS3_bb

For example, I recognize the name nupic.algorithms.Cells4.updateInferenceState(), but I'm not sure what all the other characters that pad the names mean.

What is _ZN5? What is IjSaIjEE at the end of this function name? What do these mean? Where do they come from?

mateja
  • 150
  • 11

2 Answers2

1

These (C++ functions) names are mangled. Look at name mangling for the syntax details. That allows to encode complex C++ namings.

About your perf report, there are options to ask for demangling: --demangle that is theoretically set by default but real implementation may depend on the perf version or your CPU architecture.

amigadev
  • 396
  • 1
  • 5
  • Yes, I was confused by this because I learned from the perf man page that `--demangle` is set by default, yet I was still seeing name mangling. Are there any options I need to set for GCC to facilitate name demangling? – mateja Sep 09 '15 at 22:56
  • 1
    @mateja There is nothing to do at the GCC level. Demangling is done by perf. I see no direct visible reason why that could depend on arch but I saw a demangling bug on ARM64. If you really want to demangle without fixing perf, you could write a script to post-process the report, even if not very convenient. The script could call `c++filt` that is a command able to translate, for example `c++filt_ZN5nupic10algorithms6Cells46Cells47computeEPfS3_bb` will give `nupic::algorithms::Cells4::Cells4::compute(float*, float*, bool, bool)` – amigadev Sep 10 '15 at 09:24
0

perf is probably build without support for demangling on your system.

If your system is Ubuntu have a look here: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1396654 and workaround provided here: perf enable demangling of callgraph

Community
  • 1
  • 1
Peter
  • 785
  • 2
  • 7
  • 18