#741

assembler label support

OpenGitMenschopened 1y ago

Is your feature request related to a problem? Please describe. I have a scenario of generated asm labels.

    asm volatile(
        ".globl labelC_sym\n"
        ".type  labelC_sym, @function\n"
        "labelC_sym:\n"
    );

perf report shows them "as expected", while those are "invisible" in hotspot.

Samples: 22  of event 'cycles:Pu', Event count (approx.): 1350026
  Children      Self  Command  Shared Object         Symbol
+   69.86%     0.00%  a.out    a.out                 [.] _start                                                        ▒
+   69.86%     0.00%  a.out    libc.so.6             [.] __libc_start_main@GLIBC_2.2.5 (inlined)                       ▒
+   69.86%     0.00%  a.out    libc.so.6             [.] __libc_start_call_main                                        ▒
-   69.86%     0.00%  a.out    a.out                 [.] main                                                          ▒
   - main                                                                                                              ▒
      - 23.94% labelA_sym                                                                                              ▒
           usleep                                                                                                      ▒
           nanosleep (inlined)                                                                                         ▒
           clock_nanosleep@@GLIBC_2.17 (inlined)                                                                       ◆
         + __internal_syscall_cancel                                                                                   ▒
      - 23.33% labelC_sym                                                                                              ▒
           usleep                                                                                                      ▒
           nanosleep (inlined)                                                                                         ▒
           clock_nanosleep@@GLIBC_2.17 (inlined)                                                                       ▒
           __internal_syscall_cancel                                                                                   ▒
           0xffffffff81f12f02                                                                                          ▒
      - 22.59% labelB_sym                                                                                              ▒
           usleep                                                                                                      ▒
           nanosleep (inlined)                                                                                         ▒
           clock_nanosleep@@GLIBC_2.17 (inlined)                                                                       ▒
           __internal_syscall_cancel                                                                                   ▒
           0xffffffff81f12f02                                                                                          ▒

vs.

Describe the solution you'd like Make those labels visible as perf report does, likely needs adjustments to perfparser.

Steps to reproduce (reproducer created by ChatGPT)

chck.c

gcc -g chck.c
perf record -o perf.asm.data --aio --call-graph dwarf,8192 --sample-cpu --mmap-pages 4M ./a.out
perf report -i perf.asm.data
hotsport perf.asm.data

Activity

1
milianw1y ago

you can help us by doing some pre-investigations on your own: start with looking at the output of perf script, find some backtrace with code offsets into binaries for the labels. then take those offsets and pass them to both, eu-addr2line and just addr2line - my suspicion is that this will require some fixes in elfutils? or, if eu-addr2line manages to resolve the label names, then we need to look at the code of that utility and copy over the necessary bits to hotspot.