perf probe

https://hustcat.github.io/perf-trace-and-perf-probe/

Bash下:

 perf probe -x /lib64/libc.so.6 '--add=__GI_read fd=%di buf=%si len=%dx'

 perf record -e probe_libc:__GI_read -aRg -p 917 --filter 'fd==0x3a'                  ===========fd值来自下面

bash-4.4# perf script

注意点 read可能不能被 record    。。。。。   


bash-4.4# perf probe -x /lib64/libc.so.6 '--add=read fd=%di buf=%si len=%dx'
Added new event:
probe_libc:read (on read in /lib64/libc-2.28.so with fd=%di buf=%si len=%dx)


You can now use it in all perf tools, such as:


perf record -e probe_libc:read -aR sleep 1


bash-4.4# perf record -e probe_libc:read -aR sleep 1
event syntax error: 'probe_libc:read'
\___ parser error
Run 'perf list' for a list of valid events


Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]


-e, --event <event> event selector. use 'perf list' to list available events
bash-4.4# perf probe -l
probe_libc:read (on __GI_read in /lib64/libc-2.28.so with fd buf len)
bash-4.4# perf probe -x /lib64/libc.so.6 '--add=__GI_read fd=%di buf=%si len=%dx'
Added new event:
probe_libc:__GI_read (on __GI_read in /lib64/libc-2.28.so with fd=%di buf=%si len=%dx)


You can now use it in all perf tools, such as:


perf record -e probe_libc:__GI_read -aR sleep 1


bash-4.4# perf record -e probe_libc:__GI_read -aR sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.024 MB perf.data (330 samples) ]
bash-4.4# perf script
sleep 3686 [000] 5408.696390: probe_libc:__GI_read: (7fda2231d6d0) fd=0x7 buf=0x56506bafc9a0 len=0x400
sleep 3686 [000] 5408.696429: probe_libc:__GI_read: (7fda2231d6d0) fd=0x7 buf=0x56506bafc9a0 len=0x400
swapper 0 [000] 5408.724221: probe_libc:__GI_read: (7f5a9bef36d0) fd=0x1e buf=0x55daf0dbd090 len=0x400
swapper 0 [000] 5408.724297: probe_libc:__GI_read: (7f5a9bef36d0) fd=0x1e buf=0x55daf0dbd090 len=0x400
swapper 0 [000] 5408.724355: probe_libc:__GI_read: (7f5a9bef36d0) fd=0x1e buf=0x55daf0dbd090 len=0x400

bash-4.4# perf record -e probe_libc:__GI_read -aRg --filter 'len==0x400' sleep 2
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.999 MB perf.data (156 samples) ]
bash-4.4# perf script
sleep 3746 [000] 5505.194003: probe_libc:__GI_read: (7f8f97a636d0) fd=0x7 buf=0x562658cc09a0 len=0x400
7f8f97a636d0 read+0x0 (/usr/lib64/libc-2.28.so)

sleep 3746 [000] 5505.194048: probe_libc:__GI_read: (7f8f97a636d0) fd=0x7 buf=0x562658cc09a0 len=0x400
7f8f97a636d0 read+0x0 (/usr/lib64/libc-2.28.so)

diagd 928 [000] 5505.229120: probe_libc:__GI_read: (7f4fe489c6d0) fd=0x45 buf=0x2288c90 len=0x400

 

 

posted on 2023-03-18 16:08  爱新觉罗玄烨  阅读(98)  评论(0编辑  收藏  举报

导航