1 Star 0 Fork 0

wangcichen/bcc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
shmsnoop_example.txt 2.73 KB
一键复制 编辑 原始数据 按行查看 历史
olsajiri 提交于 2018-11-17 06:23 +08:00 . Add shmsnoop/sofdsnoop tools v2 (#2045)
Demonstrations of shmsnoop, the Linux eBPF/bcc version.
shmsnoop traces shm*() syscalls, for example:
# ./shmsnoop.py
PID COMM SYS RET ARGs
19813 server SHMGET 10000 key: 0x78020001, size: 20, shmflg: 0x3b6 (IPC_CREAT|0666)
19813 server SHMAT 7f1cf8b1f000 shmid: 0x10000, shmaddr: 0x0, shmflg: 0x0
19816 client SHMGET 10000 key: 0x78020001, size: 20, shmflg: 0x1b6 (0666)
19816 client SHMAT 7f4fd8ee7000 shmid: 0x10000, shmaddr: 0x0, shmflg: 0x0
19816 client SHMDT 0 shmaddr: 0x7f4fd8ee7000
19813 server SHMDT 0 shmaddr: 0x7f1cf8b1f000
19813 server SHMCTL 0 shmid: 0x10000, cmd: 0, buf: 0x0
Every call the shm* syscall (SHM column) is displayed
on separate line together with process info (PID/COMM
columns) and argument details: return value (RET column)
and syscall arguments (ARGs column).
The ARGs column contains 'arg: value' couples that represent
given syscall arguments as described in their manpage.
This works by tracing shm* system calls and sending
argument details to the python script.
A -T option can be used to include a timestamp column,
and a -n option to match on a command name. Regular
expressions are allowed. For example, matching commands
containing "server" with timestamps:
# ./shmsnoop.py -T -n server
TIME(s) PID COMM SYS RET ARGs
0.563194000 19825 server SHMDT 0 shmaddr: 0x7f74362e4000
0.563237000 19825 server SHMCTL 0 shmid: 0x18000, cmd: 0, buf: 0x0
A -p option can be used to trace only selected process:
# ./shmsnoop.py -p 19855
PID COMM SYS RET ARGs
19855 server SHMDT 0 shmaddr: 0x7f4329ff8000
19855 server SHMCTL 0 shmid: 0x20000, cmd: 0, buf: 0x0
USAGE message:
# ./shmsnoop.py -h
usage: shmsnoop.py [-h] [-T] [-p PID] [-t TID] [-d DURATION] [-n NAME]
Trace shm*() syscalls
optional arguments:
-h, --help show this help message and exit
-T, --timestamp include timestamp on output
-p PID, --pid PID trace this PID only
-t TID, --tid TID trace this TID only
-d DURATION, --duration DURATION
total duration of trace in seconds
-n NAME, --name NAME only print process names containing this name
examples:
./shmsnoop # trace all shm*() syscalls
./shmsnoop -T # include timestamps
./shmsnoop -p 181 # only trace PID 181
./shmsnoop -t 123 # only trace TID 123
./shmsnoop -d 10 # trace for 10 seconds only
./shmsnoop -n main # only print process names containing "main"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wangcichen/bcc.git
git@gitee.com:wangcichen/bcc.git
wangcichen
bcc
bcc
master

搜索帮助