# sched_setattr ______________________________________________
#
# SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
#                 unsigned int, flags)
#

@define _SYSCALL_SCHED_SETATTR_NAME
%(
	name = "sched_setattr"
%)

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

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

# dw_sched_setattr _____________________________________________________

probe dw_syscall.sched_setattr = kernel.function("sys_sched_setattr") ?
{
	@_SYSCALL_SCHED_SETATTR_NAME
	pid = __int32($pid)
	sched_attr_uaddr = $uattr
	sched_attr_str = _struct_sched_attr_u(sched_attr_uaddr)
	flags = __uint32($flags)
	@_SYSCALL_SCHED_SETATTR_ARGSTR
}
probe dw_syscall.sched_setattr.return =
	kernel.function("sys_sched_setattr").return ?
{
	@_SYSCALL_SCHED_SETATTR_NAME
	retstr = return_str(1, $return)
}

# nd_sched_setattr _____________________________________________________

probe nd_syscall.sched_setattr = kprobe.function("sys_sched_setattr") ?
{
	@_SYSCALL_SCHED_SETATTR_NAME
	asmlinkage()
	pid = int_arg(1)
	sched_attr_uaddr = pointer_arg(2)
	sched_attr_str = _struct_sched_attr_u(sched_attr_uaddr)
	flags = uint_arg(3)
	@_SYSCALL_SCHED_SETATTR_ARGSTR
}
probe nd_syscall.sched_setattr.return =
	kprobe.function("sys_sched_setattr").return ?
{
	@_SYSCALL_SCHED_SETATTR_NAME
	retstr = returnstr(1)
}
