xref: /freebsd/cddl/usr.sbin/dwatch/libexec/nanosleep (revision d0b2dbfa)
1# -*- tab-width: 4 -*- ;; Emacs
2# vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM
3############################################################ IDENT(1)
4#
5# $Title: dwatch(8) module for nanosleep(2) [or similar] entry $
6# $Copyright: 2014-2018 Devin Teske. All rights reserved. $
7#
8############################################################ DESCRIPTION
9#
10# Print arguments being passed to nanosleep(2) [or similar]
11#
12############################################################ PROBE
13
14: ${PROBE:=syscall::$PROFILE:entry}
15
16############################################################ ACTIONS
17
18exec 9<<EOF
19this struct timespec *	rqtp;
20this time_t		requested_sec;
21this long		requested_nsec;
22
23$PROBE /* probe ID $ID */
24{${TRACE:+
25	print("<$ID>");
26}
27	/*
28	 * const struct timespec *
29	 */
30	this->rqtp = (struct timespec *)copyin(arg0, sizeof(struct timespec));
31	this->requested_sec  = (time_t)this->rqtp->tv_sec;
32	this->requested_nsec = (long)this->rqtp->tv_nsec;
33}
34EOF
35ACTIONS=$( cat <&9 )
36ID=$(( $ID + 1 ))
37
38############################################################ EVENT DETAILS
39
40if [ ! "$CUSTOM_DETAILS" ]; then
41exec 9<<EOF
42	/*
43	 * Dump nanosleep(2) arguments
44	 */
45	printf("%d.%d seconds",
46		this->requested_sec, this->requested_nsec / 100000);
47EOF
48EVENT_DETAILS=$( cat <&9 )
49fi
50
51################################################################################
52# END
53################################################################################
54