• Kan Liang's avatar
    perf script: Print source line for each jump in brstackinsn · 112c5547
    Kan Liang authored
    With the srcline option, the perf script only prints a source line at
    the beginning of a sample with call/ret from functions, but not for
    each jump in brstackinsn. It's useful to print a source line for each
    jump in brstackinsn when the end user analyze the full assembler
    sequences of branch sequences for the sample.
    
    The srccode option can also be used to locate the source code line.
    However, it's printed almost for every line and makes the output less
    readable.
    
     $perf script -F +brstackinsn,+srcline --xed
    
    Before the patch,
    
     tchain_edit_deb 1463275 15228549.107820:     282495 instructions:u:            401133 f3+0xd (/home/kan/os.li>
      tchain_edit.c:22
            f3+40:  tchain_edit.c:20
            000000000040114e                        jle 0x401133                    # PRED 6 cycles [6]
            0000000000401133                        movl  -0x4(%rbp), %eax
            0000000000401136                        and $0x1, %eax
            0000000000401139                        test %eax, %eax
            000000000040113b                        jz 0x401143
            000000000040113d                        addl  $0x1, -0x4(%rbp)
            0000000000401141                        jmp 0x401147                    # PRED 3 cycles [9] 2.00 IPC
            0000000000401147                        cmpl  $0x3e7, -0x4(%rbp)
            000000000040114e                        jle 0x401133                    # PRED 6 cycles [15] 0.33 IPC
    
    After the patch,
    
     tchain_edit_deb 1463275 15228549.107820:     282495 instructions:u:            401133 f3+0xd (/home/kan/os.li>
      tchain_edit.c:22
            f3+40:  tchain_edit.c:20
            000000000040114e                        jle 0x401133                     srcline: tchain_edit.c:20      # PRED 6 cycles [6]
            0000000000401133                        movl  -0x4(%rbp), %eax
            0000000000401136                        and $0x1, %eax
            0000000000401139                        test %eax, %eax
            000000000040113b                        jz 0x401143
            000000000040113d                        addl  $0x1, -0x4(%rbp)
            0000000000401141                        jmp 0x401147                     srcline: tchain_edit.c:23      # PRED 3 cycles [9] 2.00 IPC
            0000000000401147                        cmpl  $0x3e7, -0x4(%rbp)
            000000000040114e                        jle 0x401133                     srcline: tchain_edit.c:20      # PRED 6 cycles [15] 0.33 IPC
    Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
    Reviewed-by: default avatarIan Rogers <irogers@google.com>
    Cc: ahmad.yasin@intel.com
    Cc: amiri.khalil@intel.com
    Cc: ak@linux.intel.com
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/r/20240205145819.1943114-1-kan.liang@linux.intel.com
    112c5547
builtin-script.c 116 KB