%( CONFIG_GENERIC_SIGALTSTACK == "n" || kernel_v < "3.8" %?
# sigaltstack ________________________________________________
# long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
#		struct pt_regs *regs)
# asmlinkage long
# sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,
#		  stack_ia32_t __user *uoss_ptr,
#		  struct pt_regs *regs)
#
# NOTE: args vary between archs.
#

@define _SYSCALL_SIGALTSTACK_NAME
%(
	name = "sigaltstack"
%)

@define _SYSCALL_SIGALTSTACK_ARGSTR
%(
	argstr = sprintf("%s, %p", uss_str, uoss_uaddr)
%)

probe syscall.sigaltstack = dw_syscall.sigaltstack !, nd_syscall.sigaltstack {}
probe syscall.sigaltstack.return = dw_syscall.sigaltstack.return !,
                                   nd_syscall.sigaltstack.return {}

# dw_sigaltstack _____________________________________________________

probe dw_syscall.sigaltstack = kernel.function("sys_sigaltstack").call,
	kernel.function("sys32_sigaltstack").call ?
{
	@_SYSCALL_SIGALTSTACK_NAME
	uss_uaddr = @choose_defined($uss, $uss_ptr)
	uoss_uaddr = @choose_defined($uoss, $uoss_ptr)
# 'regs_uaddr' should have been 'regs'.  Deprecate the old name.
%(systemtap_v <= "1.4" %?
	regs_uaddr = $regs
%)
%(systemtap_v < "2.3" %?
	regs = $regs
%)
	uss_str = (@__compat_task ? _stp_compat_sigaltstack_u(uss_uaddr)
	                          : _stp_sigaltstack_u(uss_uaddr))
	@_SYSCALL_SIGALTSTACK_ARGSTR
}
probe dw_syscall.sigaltstack.return = kernel.function("sys_sigaltstack").return,
	kernel.function("sys32_sigaltstack").return ?
{
	@_SYSCALL_SIGALTSTACK_NAME
	retstr = return_str(1, $return)
}

# nd_sigaltstack _____________________________________________________

probe nd_syscall.sigaltstack = kprobe.function("sys_sigaltstack"),
	kprobe.function("sys32_sigaltstack").call ?
{
	@_SYSCALL_SIGALTSTACK_NAME
	asmlinkage()
	uss_uaddr = pointer_arg(1)
	uoss_uaddr = pointer_arg(2)
%(systemtap_v < "2.3" %?
	regs_uaddr = pointer_arg(3)
	regs = pointer_arg(3)
%)
	uss_str = (@__compat_task ? _stp_compat_sigaltstack_u(uss_uaddr)
	                          : _stp_sigaltstack_u(uss_uaddr))
	@_SYSCALL_SIGALTSTACK_ARGSTR
}
probe nd_syscall.sigaltstack.return = kprobe.function("sys_sigaltstack").return,
	kprobe.function("sys32_sigaltstack").return ?
{
	@_SYSCALL_SIGALTSTACK_NAME
	retstr = returnstr(1)
}
%)
