2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * Copyright (c) 1996-2018 The strace developers.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/timex.h>
37 print_timezone(struct tcb *const tcp, const kernel_ulong_t addr)
41 if (umove_or_printaddr(tcp, addr, &tz))
44 tprintf("{tz_minuteswest=%d, tz_dsttime=%d}",
45 tz.tz_minuteswest, tz.tz_dsttime);
48 SYS_FUNC(gettimeofday)
51 print_timeval(tcp, tcp->u_arg[0]);
53 print_timezone(tcp, tcp->u_arg[1]);
59 SYS_FUNC(osf_gettimeofday)
62 print_timeval32(tcp, tcp->u_arg[0]);
64 print_timezone(tcp, tcp->u_arg[1]);
70 SYS_FUNC(settimeofday)
72 print_timeval(tcp, tcp->u_arg[0]);
74 print_timezone(tcp, tcp->u_arg[1]);
80 SYS_FUNC(osf_settimeofday)
82 print_timeval32(tcp, tcp->u_arg[0]);
84 print_timezone(tcp, tcp->u_arg[1]);
93 print_timespec(tcp, tcp->u_arg[0]);
98 * Second (returned) timespec is only significant if syscall
99 * was interrupted. On success and in case of other errors we
100 * print only its address, since kernel doesn't modify it,
101 * and printing the value may show uninitialized data.
103 if (is_erestart(tcp)) {
104 temporarily_clear_syserror(tcp);
105 print_timespec(tcp, tcp->u_arg[1]);
106 restore_cleared_syserror(tcp);
108 printaddr(tcp->u_arg[1]);
114 #include "xlat/itimer_which.h"
119 printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
123 print_itimerval(tcp, tcp->u_arg[1]);
129 SYS_FUNC(osf_getitimer)
132 printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
136 print_itimerval32(tcp, tcp->u_arg[1]);
145 printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
148 print_itimerval(tcp, tcp->u_arg[1]);
151 print_itimerval(tcp, tcp->u_arg[2]);
157 SYS_FUNC(osf_setitimer)
160 printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
163 print_itimerval32(tcp, tcp->u_arg[1]);
166 print_itimerval32(tcp, tcp->u_arg[2]);
172 #include "xlat/adjtimex_state.h"
175 do_adjtimex(struct tcb *const tcp, const kernel_ulong_t addr)
177 if (print_timex(tcp, addr))
179 tcp->auxstr = xlat_idx(adjtimex_state, ARRAY_SIZE(adjtimex_state) - 1,
180 (kernel_ulong_t) tcp->u_rval);
187 return do_adjtimex(tcp, tcp->u_arg[0]);
191 #include "xlat/clockflags.h"
192 #include "xlat/clocknames.h"
195 printclockname(int clockid)
198 # include "xlat/cpuclocknames.h"
201 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
202 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
205 CPUCLOCK_PERTHREAD(clockid) ?
206 "MAKE_THREAD_CPUCLOCK" :
207 "MAKE_PROCESS_CPUCLOCK",
208 CPUCLOCK_PID(clockid));
209 printxval_index(cpuclocknames,
210 (unsigned int) clockid & CLOCKFD_MASK,
216 printxval_index(clocknames, clockid, "CLOCK_???");
219 SYS_FUNC(clock_settime)
221 printclockname(tcp->u_arg[0]);
223 print_timespec(tcp, tcp->u_arg[1]);
228 SYS_FUNC(clock_gettime)
231 printclockname(tcp->u_arg[0]);
234 print_timespec(tcp, tcp->u_arg[1]);
239 SYS_FUNC(clock_nanosleep)
242 printclockname(tcp->u_arg[0]);
244 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
246 print_timespec(tcp, tcp->u_arg[2]);
250 * Second (returned) timespec is only significant
251 * if syscall was interrupted and flags is not TIMER_ABSTIME.
253 if (!tcp->u_arg[1] && is_erestart(tcp)) {
254 temporarily_clear_syserror(tcp);
255 print_timespec(tcp, tcp->u_arg[3]);
256 restore_cleared_syserror(tcp);
258 printaddr(tcp->u_arg[3]);
264 SYS_FUNC(clock_adjtime)
267 return do_adjtimex(tcp, tcp->u_arg[1]);
268 printclockname(tcp->u_arg[0]);
273 SYS_FUNC(timer_create)
276 printclockname(tcp->u_arg[0]);
278 print_sigevent(tcp, tcp->u_arg[1]);
281 printnum_int(tcp, tcp->u_arg[2], "%d");
286 SYS_FUNC(timer_settime)
289 tprintf("%d, ", (int) tcp->u_arg[0]);
290 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
292 print_itimerspec(tcp, tcp->u_arg[2]);
295 print_itimerspec(tcp, tcp->u_arg[3]);
300 SYS_FUNC(timer_gettime)
303 tprintf("%d, ", (int) tcp->u_arg[0]);
305 print_itimerspec(tcp, tcp->u_arg[1]);
310 #include "xlat/timerfdflags.h"
312 SYS_FUNC(timerfd_create)
314 printclockname(tcp->u_arg[0]);
316 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
318 return RVAL_DECODED | RVAL_FD;
321 SYS_FUNC(timerfd_settime)
324 printfd(tcp, tcp->u_arg[0]);
326 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
328 print_itimerspec(tcp, tcp->u_arg[2]);
331 print_itimerspec(tcp, tcp->u_arg[3]);
336 SYS_FUNC(timerfd_gettime)
339 printfd(tcp, tcp->u_arg[0]);
342 print_itimerspec(tcp, tcp->u_arg[1]);