perf-report显示CPU寄存器的值

时间:2017-05-24 15:46:17

标签: linux linux-kernel cpu intel perf

我关注this document并将perf record--intr-regs=ax,bx,r15一起使用,尝试使用PEBS记录记录其他CPU注册信息。

但是如何从perf.data查看这些信息?原始命令是perf report,它只显示一些字段,如开销,命令,共享对象和符号。

有没有办法显示CPU regs的值?

2 个答案:

答案 0 :(得分:2)

使用perf script字段iregs尝试perf script -F ip,sym,iregs数据转储命令。所有字段-F均已记录,源代码为tools/perf/builtin-script.c - struct output_option .. all_output_optionsiregs仍在此处(同一文件中也为OPT_CALLBACK('F', "fields" ...)。还有perf-script.txt文档 - https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/perf-script.txt#L115

-F::
--fields::
    Comma separated list of fields to print. Options are:
    comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
    srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn,
    callindent, insn, insnlen. Field list can be prepended with the type, trace, sw or hw,
    to indicate to which event type the field list applies.

有提交到linux内核git的提交标记--intr-regs。从选项实施开始:

https://github.com/torvalds/linux/search?utf8=%E2%9C%93&q=intr-regs&type=

  

tools/perf/builtin-record.c       OPT_CALLBACK_OPTARG('我','intr-regs',& record.opts.sample_intr_regs,NULL,“任何寄存器”,

然后在提交中搜索“sample_intr_regs”:https://github.com/torvalds/linux/search?q=sample_intr_regs&type=Commits

几个提交是关于内核部分和perf_attr调试打印。但这有intr-regs印刷的例子(2015年9月1日) https://github.com/torvalds/linux/commit/532026612455a4a6fd27c1b2e7111263f63218a2

  

从Arnaldo Carvalho de Melo获取穿孔/核心改进和修复:      - 添加指定选择要记录的寄存器的功能,       减少perf.data文件的大小,也允许打印       'perf script'中的寄存器:( Stephane Eranian)

  # perf record --intr-regs=AX,SP usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.016 MB perf.data (8 samples) ]
  # perf script -F ip,sym,iregs | tail -5
   ffffffff8105f42a native_write_msr_safe   AX:0xf    SP:0xffff8802629c3c00
   ffffffff8105f42a native_write_msr_safe   AX:0xf    SP:0xffff8802629c3c00
   ffffffff81761ac0 _raw_spin_lock   AX:0xffff8801bfcf8020    SP:0xffff8802629c3ce8
   ffffffff81202bf8 __vma_adjust_trans_huge   AX:0x7ffc75200000    SP:0xffff8802629c3b30
   ffffffff8122b089 dput   AX:0x101    SP:0xffff8802629c3c78
  #

答案 1 :(得分:0)

我找到了一种方法来使用overflow: hidden来实现它,然后找到寄存器'按记录记录所需的名称(但这似乎效率很低......)。

或者其他人可以提供更简化的方法?