관리-도구
편집 파일: sysc_getpid.stp
# getpid _____________________________________________________ # long sys_getpid(void) @define _SYSCALL_GETPID_NAME %( name = "getpid" %) @define _SYSCALL_GETPID_ARGSTR %( argstr = "" %) probe syscall.getpid = dw_syscall.getpid !, nd_syscall.getpid ? {} probe syscall.getpid.return = dw_syscall.getpid.return !, nd_syscall.getpid.return ? {} # dw_getpid _____________________________________________________ probe dw_syscall.getpid = kernel.function("sys_getpid").call { @_SYSCALL_GETPID_NAME @_SYSCALL_GETPID_ARGSTR } probe dw_syscall.getpid.return = kernel.function("sys_getpid").return { @_SYSCALL_GETPID_NAME @SYSC_RETVALSTR($return) } # nd_getpid _____________________________________________________ probe nd_syscall.getpid = nd1_syscall.getpid!, nd2_syscall.getpid!, tp_syscall.getpid { } probe nd1_syscall.getpid = kprobe.function("sys_getpid") { @_SYSCALL_GETPID_NAME @_SYSCALL_GETPID_ARGSTR } /* kernel 4.17+ */ probe nd2_syscall.getpid = kprobe.function(@arch_syscall0_prefix "sys_getpid") ? { @_SYSCALL_GETPID_NAME @_SYSCALL_GETPID_ARGSTR } /* kernel 3.5+, but undesirable because it affects all syscalls */ probe tp_syscall.getpid = kernel.trace("sys_enter") { @__syscall_compat_gate(@const("__NR_getpid"), @const("__NR_compat_getpid")) @_SYSCALL_GETPID_NAME @_SYSCALL_GETPID_ARGSTR } probe nd_syscall.getpid.return = nd1_syscall.getpid.return!, nd2_syscall.getpid.return!, tp_syscall.getpid.return { } probe nd1_syscall.getpid.return = kprobe.function("sys_getpid").return { @_SYSCALL_GETPID_NAME @SYSC_RETVALSTR(returnval()) } /* kernel 4.17+ */ probe nd2_syscall.getpid.return = kprobe.function(@arch_syscall0_prefix "sys_getpid").return ? { @_SYSCALL_GETPID_NAME @SYSC_RETVALSTR(returnval()) } /* kernel 3.5+, but undesirable because it affects all syscalls */ probe tp_syscall.getpid.return = kernel.trace("sys_exit") { __set_syscall_pt_regs($regs) @__syscall_compat_gate(@const("__NR_getpid"), @const("__NR_compat_getpid")) @_SYSCALL_GETPID_NAME @SYSC_RETVALSTR($ret) }