どのPythonのコードの行で clone(2) が呼ばれたかをbpftraceで追えるんか...?
— RyuichiWatanabe@gurasan (@ryuichi_1208) 2025年5月13日
というのをやりたかった過程で調べたメモ。これはちょっと便利そう。
bpftrace -e '
tracepoint:syscalls:sys_enter_clone
{
printf("PID: %d, TID: %d, COMM: %s, clone_flags: 0x%lx\n", pid, tid, comm, args->clone_flags);
if (args->clone_flags & 0x00000100) { printf(" CLONE_VM\n"); }
if (args->clone_flags & 0x00000200) { printf(" CLONE_FS\n"); }
if (args->clone_flags & 0x00000400) { printf(" CLONE_FILES\n"); }
if (args->clone_flags & 0x00000800) { printf(" CLONE_SIGHAND\n"); }
if (args->clone_flags & 0x00010000) { printf(" CLONE_THREAD\n"); }
if (args->clone_flags & 0x00008000) { printf(" CLONE_PARENT\n"); }
if (args->clone_flags & 0x10000000) { printf(" CLONE_NEWUSER\n"); }
if (args->clone_flags & 0x20000000) { printf(" CLONE_NEWPID\n"); }
if (args->clone_flags & 0x40000000) { printf(" CLONE_NEWNET\n"); }
if (args->clone_flags & 0x00020000) { printf(" CLONE_NEWNS\n"); }
}
'
こんな感じで出力されます。
PID: 1369266, TID: 1369266, COMM: systemd-journal, clone_flags: 0x3d0f00 CLONE_VM CLONE_FS CLONE_FILES CLONE_SIGHAND CLONE_THREAD