OSDN Git Service

perf script: Add 'brstackinsnlen' for branch stacks
authorKan Liang <kan.liang@linux.intel.com>
Mon, 21 Mar 2022 14:00:12 +0000 (07:00 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 22 Mar 2022 21:00:45 +0000 (18:00 -0300)
commit6f680c6aa276ceff7dde98d5ae3f19574cd12eff
tree3c40c8b4af2e583b598b665142a815310c5b56bf
parentbc355822f0d9623b632069105d425c822d124cc8
perf script: Add 'brstackinsnlen' for branch stacks

When analyzing with 'perf script', it's useful to understand the
captured instruction and the next sequential instruction.

To calculate the address of the next sequential instruction, the length
of the captured instruction is required.

For example, you can’t know the next sequential instruction after an
unconditional branch unless you calculate that based on its length.

For branch stacks, 'perf script' only prints the instruction bytes with
'brstackinsn', but lacks the instruction length.

Add 'brstackinsnlen' to print the instruction length.

  $ perf script -F ip,brstackinsn,brstackinsnlen --xed
     7fa555be8f75
        _start:
        00007fa555be8090    mov %rsp, %rdi              ilen: 3
        00007fa555be8093    callq  0x7fa555be8ea0       ilen: 5 # PRED 102 cycles [102] 0.02 IPC
        _dl_start+38:
        00007fa555be8ec6    movq  %rdx,0x227853(%rip)   ilen: 7
        00007fa555be8ecd    leaq  0x227f94(%rip),%rdx   ilen: 7

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Ahmad Yasin <ahmad.yasin@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/1647871212-184070-1-git-send-email-kan.liang@linux.intel.com
[ Added the new field to tools/perf/Documentation/perf-script.txt ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-script.txt
tools/perf/builtin-script.c