2

sys_enter_openat我为系统调用启用了 ftrace 事件跟踪。给出的相应输出格式events/syscalls/sys_enter_openat/format

print fmt: "dfd: 0x%08lx, filename: 0x%08lx, flags: 0x%08lx, mode: 0x%08lx", ((unsigned long)(REC->dfd)), ((unsigned long)(REC->filename)), ((unsigned long)(REC->flags)), ((unsigned long)(REC->mode))

正如预期的那样,ftrace 的示例输出行类似于

msm_irqbalance-1338  [000] ...1 211710.033931: sys_openat(dfd: ffffff9c, filename: 5af693f224, flags: 2, mode: 0)

有没有办法改变输出格式,filename: 5af693f224以便显示为filename: <string>而不是地址?我想这本来可以使用systemtaporkrpobe但我的设置现在不允许使用它。

4

1 回答 1

0

您可以使用自己的格式定义 kprobe 事件:

cd /sys/kernel/debug/tracing
echo 'p:open do_sys_open file=+0(%si):string' > kprobe_events
echo 1 > events/kprobes/open/enable
cat trace_pipe

输出:

cat-123 [001] .... 123.123: open: (do_sys_open+0x0/0x80) file="/etc/fstab"
cat-123 [001] .... 123.124: open: (do_sys_open+0x0/0x80) file="/dev/zero"

详情见:https ://events19.linuxfoundation.org/wp-content/uploads/2017/12/oss-eu-2018-fun-with-dynamic-trace-events_steven-rostedt.pdf

于 2021-05-19T12:15:21.457 回答