# mlock2 _____________________________________________________
#
# long sys_mlock2(unsigned long start, size_t len, int flags)
#

@define _SYSCALL_MLOCK2_NAME
%(
	name = "mlock2"
%)

@define _SYSCALL_MLOCK2_ARGSTR
%(
	argstr = sprintf("%p, %u, %s", addr, len, flags_str)
%)

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

# dw_mlock2 _____________________________________________________

probe dw_syscall.mlock2 = kernel.function("sys_mlock2").call ?
{
	@_SYSCALL_MLOCK2_NAME
	addr = __ulong($start)
	len = __ulong($len)
	flags = __int32($flags)
	flags_str = _stp_mlock2_str(__int32($flags))
	@_SYSCALL_MLOCK2_ARGSTR
}
probe dw_syscall.mlock2.return = kernel.function("sys_mlock2").return ?
{
	@_SYSCALL_MLOCK2_NAME
	retstr = return_str(1, $return)
}

# nd_mlock2 _____________________________________________________

probe nd_syscall.mlock2 = kprobe.function("sys_mlock2") ?
{
	@_SYSCALL_MLOCK2_NAME
	asmlinkage()
	addr = ulong_arg(1)
	len = ulong_arg(2)
	flags = int_arg(3)
	flags_str = _stp_mlock2_str(flags)
	@_SYSCALL_MLOCK2_ARGSTR
}
probe nd_syscall.mlock2.return = kprobe.function("sys_mlock2").return ?
{
	@_SYSCALL_MLOCK2_NAME
	retstr = returnstr(1)
}
