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, $rqtp gets turned into a long. So, '$rqtp->tv_sec'
# won't work everywhere.
#
# Why not do '@cast($rqtp, "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($rqtp, "struct timespec")->tv_sec) == $1)
	target_set_report()
}
probe syscall.compat_nanosleep ?
{
    if (target_set_pid(pid())
	&& user_long(&@cast($rqtp, "struct compat_timespec")->tv_sec) == $1)
	target_set_report()
}

probe end
{
    target_set_report()
}
