Hi, I want to use perf
in Fedora. Write a trivial main.cpp. Compile it using g++ -ggdb main.cpp -o main
. Perf it using perf record ./main
. Annotate it using perf annotate main
. Howeber, there is no source code annotation only assembly
Samples: 2K of event 'cycles:Pu', 4000 Hz, Event count (approx.): 2895263961
main /home/fanta/develop/cpp/main [Percent: local period]
Percent │ 0x401136 <main>:
│ pushq %rbp
│ movq %rsp,%rbp
│ subq $0x10,%rsp
│ movq $0x0,-0x8(%rbp)
│ movl $0x0,-0xc(%rbp)
│ ↓ jmp 26
15.73 │19:┌─→movl -0xc(%rbp),%eax
2.76 │ │ cltq
8.92 │ │ addq %rax,-0x8(%rbp)
18.55 │ │ addl $0x1,-0xc(%rbp)
5.98 │26:├──cmpl $0x3b9ac9ff,-0xc(%rbp)
48.06 │ └──jle 19
│ movq -0x8(%rbp),%rax
│ movq %rax,%rsi
│ movl $0x404040,%edi
│ → callq std::ostream::operator<<(unsigned long)@plt
│ movl $0x4022b8,%esi
│ movq %rax,%rdi
│ → callq std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char co
│ movl $0x0,%eax
│ leave
│ ← retq
I’m using Fedora workstation 41
perf version 6.12.6-200.fc41.x86_64
I can reproduce this issue in a freshly installed VM. And using the same steps, source code annotation can be shown on Ubuntu 24.04.