probe begin
{
    stp_pid = stp_pid()
    printf("%d\n%d begat %d\n", stp_pid, stp_pid, target())
}

# In the below code, why is the following necessary?
#
#	user_long(&@cast($rqtp, "struct timespec")->tv_sec)
#
# Why not just do '$rqtp->tv_sec'?  On s390x and ppc64, because of
# syscall wrappers, req_uaddr gets turned into a long. So, 'req_uaddr->tv_sec'
# won't work everywhere.
#
# Why not do '@cast(req_uaddr, "struct timespec")->tv_sec'? The pointer
# isn't to kernel memory, but to user memory, so we have to read it
# properly.

probe syscall.nanosleep
{
    if (target_set_pid(pid())
	&& user_long(&@cast(req_uaddr, "struct timespec", "kernel")->tv_sec) == $1)
	target_set_report()
}
probe syscall.compat_nanosleep ?
{
    if (target_set_pid(pid())
	&& user_long(&@cast(req_uaddr, "struct compat_timespec", "kernel")->tv_sec) == $1)
	target_set_report()
}

probe end
{
    target_set_report()
}
