# sched_getattr ______________________________________________
#
# SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,
#                 unsigned int, size, unsigned int, flags)
#

@define _SYSCALL_SCHED_GETATTR_NAME
%(
	name = "sched_getattr"
%)

@define _SYSCALL_SCHED_GETATTR_ARGSTR
%(
	argstr = sprintf("%d, %s, %u, %u", pid, sched_attr_str, size, flags)
%)

probe syscall.sched_getattr = dw_syscall.sched_getattr !, nd_syscall.sched_getattr ? {}
probe syscall.sched_getattr.return = dw_syscall.sched_getattr.return !,
                                     nd_syscall.sched_getattr.return ? {}

# dw_sched_getattr _____________________________________________________

probe dw_syscall.sched_getattr = kernel.function("sys_sched_getattr") ?
{
	@_SYSCALL_SCHED_GETATTR_NAME
	pid = __int32($pid)
	sched_attr_uaddr = $uattr
	sched_attr_str = _struct_sched_attr_u(sched_attr_uaddr)
	size = __uint32($size)
	flags = __uint32($flags)
	@_SYSCALL_SCHED_GETATTR_ARGSTR
}
probe dw_syscall.sched_getattr.return =
	kernel.function("sys_sched_getattr").return ?
{
	@_SYSCALL_SCHED_GETATTR_NAME
	retstr = return_str(1, $return)
}

# nd_sched_getattr _____________________________________________________

probe nd_syscall.sched_getattr = kprobe.function("sys_sched_getattr") ?
{
	@_SYSCALL_SCHED_GETATTR_NAME
	asmlinkage()
	pid = int_arg(1)
	sched_attr_uaddr = pointer_arg(2)
	sched_attr_str = _struct_sched_attr_u(sched_attr_uaddr)
	size = uint_arg(3)
	flags = uint_arg(4)
	@_SYSCALL_SCHED_GETATTR_ARGSTR
}
probe nd_syscall.sched_getattr.return =
	kprobe.function("sys_sched_getattr").return ?
{
	@_SYSCALL_SCHED_GETATTR_NAME
	retstr = returnstr(1)
}
