title: perf enable demangling of callgraph
body: <p>How do I enable C++ demangling for the perf callgraph? It seems to demangle symbols when I go into annotate mode, but not in the main callgraph.</p>
  
  <p>Sample code (using <a href="https://github.com/google/benchmark">Google Benchmark</a>):</p>
  
  <pre><code>#include &lt;benchmark/benchmark.h&gt;
  #include &lt;vector&gt;
  
  static __attribute__ ((noinline)) int my_really_big_function()
  {
    for(size_t i = 0; i &lt; 1000; ++i)
    {
      benchmark::DoNotOptimize(i % 5);
    }
    return 0;
  }
  
  static __attribute__ ((noinline)) void caller1()
  {
    for(size_t i = 0; i &lt; 1000; ++i)
    {
      benchmark::DoNotOptimize(my_really_big_function());
      benchmark::DoNotOptimize(i % 5);
    }
  }
  
  static __attribute__ ((noinline)) void myfun(benchmark::State&amp; state)
  {
    while(state.KeepRunning())
    {
      caller1();
    }
  }
  
  BENCHMARK(myfun);
  
  BENCHMARK_MAIN();
  </code></pre>
  
  <p>build command:</p>
  
  <pre><code>clang++ main.cpp -o main -fno-omit-frame-pointer -O0 -lpthread -lbenchmark
  </code></pre>
  
  <p>perf commands:</p>
  
  <pre><code>perf record -g ./main
  perf report -g 'graph,0.5,caller'
  </code></pre>
  
  <p>I've also tried enabling the --demangle option, but that doesn't seem to affect the output.</p>
  
  <p>callgraph missing demangled symbols:</p>
  
  <pre><code>Samples: 3K of event 'cycles', Event count (approx.): 2946754102
  Children      Self  Command  Shared Object      Symbol
  +   99.82%     0.00%  main     main               [.] _ZL5myfunRN9benchmark5StateE
  +   99.82%     0.00%  main     main               [.] _ZN9benchmark12_GLOBAL__N_111RunInThreadEPKNS_8internal9Benchmark8InstanceEmiPNS0_11ThreadStatsE
  +   99.82%     0.00%  main     main               [.] _ZN9benchmark22RunSpecifiedBenchmarksEPNS_17BenchmarkReporterE
  +   99.82%     0.00%  main     main               [.] main
  +   99.82%     0.00%  main     libc-2.21.so       [.] __libc_start_main
  +   99.82%     0.00%  main     [unknown]          [.] 0x7fbe258d4c544155
  +   99.75%     0.30%  main     main               [.] _ZL7caller1v
  +   99.52%    99.46%  main     main               [.] _ZL22my_really_big_functionv
  </code></pre>
  
  <p>annotated disassembly showing demangled calls:</p>
  
  <pre><code>       │
         │    0000000000404310 &lt;caller1()&gt;:
         │    _ZL7caller1v():
         │      push   %rbp
         │      mov    %rsp,%rbp
         |    $0x30,%rsp
         |   $0x0,-0x18(%rbp)
         │10:   cmpq   $0x3e8,-0x18(%rbp)
         │    ↓ jae    6f
         │    → callq  my_really_big_function()
         │      lea    -0x1c(%rbp),%rcx
         │      mov    %eax,-0x1c(%rbp)
   14.29 │      mov    %rcx,-0x10(%rbp)
         │      mov    -0x10(%rbp),%rcx
         │      lea    -0x28(%rbp),%rcx
         │      mov    $0x5,%eax
         │      mov    %eax,%edx
         │      mov    -0x18(%rbp),%rax
         │      xor    %esi,%esi
         │      mov    %rdx,-0x30(%rbp)
         │      mov    %esi,%edx
         │      mov    -0x30(%rbp),%rdi
         │      div    %rdi
   85.71 │      mov    %rdx,-0x28(%rbp)
         │      mov    %rcx,-0x8(%rbp)
         │      mov    -0x8(%rbp),%rcx
         │      mov    -0x18(%rbp),%rax
         │      add    $0x1,%rax
         │      mov    %rax,-0x18(%rbp)
         │    ↑ jmpq   10
         │6f:   add    $0x30,%rsp
         │      pop    %rbp
         │    ← retq
  </code></pre>
  
  <p>System info:</p>
  
  <ul>
  <li>Ubuntu 15.04 64-bit</li>
  <li>Intel i5-6600k</li>
  <li>perf 3.19.8-ckt6</li>
  <li>clang 3.6.0-2ubuntu1</li>
  </ul>