xref: /freebsd/cddl/usr.sbin/dwatch/libexec/nanosleep (revision 190cef3d)
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# $FreeBSD$
8#
9############################################################ DESCRIPTION
10#
11# Print arguments being passed to nanosleep(2) [or similar]
12#
13############################################################ PROBE
14
15: ${PROBE:=syscall::$PROFILE:entry}
16
17############################################################ ACTIONS
18
19exec 9<<EOF
20this struct timespec *	rqtp;
21this time_t		requested_sec;
22this long		requested_nsec;
23
24$PROBE /* probe ID $ID */
25{${TRACE:+
26	print("<$ID>");
27}
28	/*
29	 * const struct timespec *
30	 */
31	this->rqtp = (struct timespec *)copyin(arg0, sizeof(struct timespec));
32	this->requested_sec  = (time_t)this->rqtp->tv_sec;
33	this->requested_nsec = (long)this->rqtp->tv_nsec;
34}
35EOF
36ACTIONS=$( cat <&9 )
37ID=$(( $ID + 1 ))
38
39############################################################ EVENT DETAILS
40
41if [ ! "$CUSTOM_DETAILS" ]; then
42exec 9<<EOF
43	/*
44	 * Dump nanosleep(2) arguments
45	 */
46	printf("%d.%d seconds",
47		this->requested_sec, this->requested_nsec / 100000);
48EOF
49EVENT_DETAILS=$( cat <&9 )
50fi
51
52################################################################################
53# END
54################################################################################
55