用于 C 变量赋值的 Perf 探测事件
Perf probe event for C variable assignment
我一直在将 perf probe
与 malloc
一起使用,但似乎找不到合适的 perf 事件来处理变量赋值。有这样的活动吗?
理想情况下,当 int var = 17;
之类的事情发生时,是否缺少一些相应的事件?在变量的实例化之外,而是值的实际赋值和每次连续更改。
是的,这可以通过硬件断点事件实现。 perf record
如果你知道地址就支持这个:
a hardware breakpoint event in the form of \mem:addr[/len][:access]
where addr is the address in memory you want to break in. Access is
the memory access type (read,
write, execute) it can be passed as follows: \mem:addr[:[r][w][x]]. len is the range, number of bytes from
specified addr, which the breakpoint will cover. If you want to
profile read-write accesses in 0x1000, just set mem:0x1000:rw. If you want to profile write accesses in [0x1000~1008),
just set mem:0x1000/8:w.
事先获取内存地址可能比较困难。你也可以在你的程序中使用perf_event_open
,但是你需要在你的程序中解析perf示例记录。
我一直在将 perf probe
与 malloc
一起使用,但似乎找不到合适的 perf 事件来处理变量赋值。有这样的活动吗?
理想情况下,当 int var = 17;
之类的事情发生时,是否缺少一些相应的事件?在变量的实例化之外,而是值的实际赋值和每次连续更改。
是的,这可以通过硬件断点事件实现。 perf record
如果你知道地址就支持这个:
a hardware breakpoint event in the form of \mem:addr[/len][:access] where addr is the address in memory you want to break in. Access is the memory access type (read, write, execute) it can be passed as follows: \mem:addr[:[r][w][x]]. len is the range, number of bytes from specified addr, which the breakpoint will cover. If you want to profile read-write accesses in 0x1000, just set mem:0x1000:rw. If you want to profile write accesses in [0x1000~1008), just set mem:0x1000/8:w.
事先获取内存地址可能比较困难。你也可以在你的程序中使用perf_event_open
,但是你需要在你的程序中解析perf示例记录。