[英]how perf record get the virtual memory address of instruction of the target process and what data struct does perf use to store it
I'm reading source code of perf and try to make sense of how perf record
get the the virtual memory address of an Instruction of the target process that trigger perf to count(for example the virtual address of call test
,which is assembly code watched by perf report
's annotation). 我正在阅读perf的源代码,并尝试理解perf record
如何获取触发perf计数的目标进程的指令的虚拟内存地址(例如, call test
的虚拟地址,该代码是受监视的汇编代码)通过性能perf report
的注释)。 And what data structure does perf use to store the virtual address of the instruction that make perf-event happen and trigger counter? perf使用什么数据结构来存储使perf事件发生并触发计数器的指令的虚拟地址?
In order to get the instruction pointers for samples, you must include PERF_SAMPLE_IP
in perf_attr.sample_type
for the perf_event_open
call. 为了得到样品的指令指针,你必须包括PERF_SAMPLE_IP
在perf_attr.sample_type
为perf_event_open
电话。 This will include the ip
field in the struct for PERF_RECORD_SAMPLE
events that you can read from the mmap
ringbuffer. 这将包含可从mmap
环形缓冲区读取的PERF_RECORD_SAMPLE
事件的结构中的ip
字段。 See the manpage for details. 有关详细信息,请参见手册页。
PERF_RECORD_SAMPLE
This record indicates a sample.
struct {
struct perf_event_header header;
u64 sample_id; /* if PERF_SAMPLE_IDENTIFIER */
u64 ip; /* if PERF_SAMPLE_IP */
u32 pid, tid; /* if PERF_SAMPLE_TID */
u64 time; /* if PERF_SAMPLE_TIME */
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.