]> git.ipfire.org Git - thirdparty/linux.git/commit
perf script: Support 32bit code under 64bit OS with capstone
authorAndi Kleen <ak@linux.intel.com>
Mon, 1 Apr 2024 21:08:03 +0000 (14:08 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 5 Apr 2024 12:42:36 +0000 (09:42 -0300)
commit38ab60132b0d477e19d841daed701b491c20b465
tree546469bf0c779df9c52415b50bc544280785b8ab
parentc2f3d7dfc7373d53286f2a5c882d3397a5070adc
perf script: Support 32bit code under 64bit OS with capstone

Use the DSO to resolve whether an IP is 32bit or 64bit and use that to
configure capstone to the correct mode. This allows to correctly
disassemble 32bit code under a 64bit OS.

  % cat > loop.c
  volatile int var;
  int main(void)
  {
   int i;
   for (i = 0; i < 100000; i++)
   var++;
  }
  % gcc -m32 -o loop loop.c
  % perf record -e cycles:u ./loop
  % perf script -F +disasm
    loop   82665 1833176.618023:      1 cycles:u:   f7eed500 _start+0x0 (/usr/lib/ld-linux.so.2)   movl %esp, %eax
    loop   82665 1833176.618029:      1 cycles:u:   f7eed500 _start+0x0 (/usr/lib/ld-linux.so.2)   movl %esp, %eax
    loop   82665 1833176.618031:      7 cycles:u:   f7eed500 _start+0x0 (/usr/lib/ld-linux.so.2)   movl %esp, %eax
    loop   82665 1833176.618034:     91 cycles:u:   f7eed500 _start+0x0 (/usr/lib/ld-linux.so.2)   movl %esp, %eax
    loop   82665 1833176.618036:   1242 cycles:u:   f7eed500 _start+0x0 (/usr/lib/ld-linux.so.2)   movl %esp, %eax

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: https://lore.kernel.org/r/20240401210925.209671-2-ak@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c
tools/perf/util/print_insn.c
tools/perf/util/print_insn.h