xref: /freebsd/cddl/usr.sbin/dwatch/libexec/nanosleep (revision 4f52dfbb)
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
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 )
49
50################################################################################
51# END
52################################################################################
53