Print ISO 8601 time for wall clock time values

Add an argument to print_time* routines that signalises, whether
the time value is wall clock time or not.

* aio.c (print_io_getevents): Add an argument to print_timespec call.
* defs.h (print_timeval32_t, print_timeval32, print_itimerval32): Add
"bool rtc" argument.
* desc.c (decode_select): Add bool argument to print_tv_ts callback
function argument.
* futex.c (SYS_FUNC(futex)) <case FUTEX_WAIT>: Call print_timespec with
rtc=false, as the timestamp is always relative.
<case FUTEX_LOCK_PI>: Call print_timespec with rtc=true, as the timeout
is always absolute.
<case FUTEX_WAIT_BITSET, case FUTEX_WAIT_REQUEUE_PI>: Call
print_timespec with rtc set to true when op has FUTEX_CLOCK_REALTIME
flag.
* ipc_sem.c (SYS_FUNC(semtimedop)): Call print_timespec with rtc=false,
as timeout is always relative.
* linux/dummy.h (sys_clock_getres, sys_stime): Remove.
* mmsghdr.c (SYS_FUNC(recvmmsg)): Call print_timespec with rtc=false, as
timeout is relative.
* mq.c (SYS_FUNC(mq_timedsend), SYS_FUNC(mq_timedreceive)): Call
print_timespec with rtc=true, as timeout is absolute.
* msghdr.c (print_scm_timestamp, print_scm_timestampns,
print_scm_timestamping): Call print_struct_timeval_data_size,
print_struct_timespec_data_size, print_struct_timespec_array_data_size
with rtc=true as timestamps presumed absolute.
* poll.c (SYS_FUNC(ppoll)): Call print_timespec with rtc=false, as
timeout is relative.
* print_time.c (print_time_t): New function.
(SYS_FUNC(time)): Use print_time_t for printing time.
(SYS_FUNC(stime)): New function.
* print_timespec.c (print_timespec_t, print_struct_timespec_data_size,
print_struct_timespec_array_data_size, print_timespec): Add rtc argument,
handle it.
(print_timespec_t_utime): Call print_timespec_t with rtc=false when
xlat_style is not abbreviated, call print_timespec_t with rtc=true
instead of manual time stamp printing.
(print_itimerspec): Call print_timespec_t with rtc=false.
* print_timeval.c (print_timeval_t, print_struct_timeval_data_size,
print_timeval, print_itimerval, print_timeval32_t, print_timeval32):
Add rtc argument, handle it.
(print_timeval_t_utime, print_timeval32_t_utime): Remove.
(print_struct_timeval): New function.
(print_timeval_utimes): Use print_struct_timeval instead of
print_timeval_t_utime.
* print_timex.c (print_timex): Add rtc argument, handle it.
* printrusage.c (printrusage): Call print_struct_timeval with rtc=false.
* sched.c (sched_rr_get_interval): Call print_timespec with rtc=false.
* signal.c (rt_sigtimedwait): Call print_timespec with rtc=false.
* time.c: Include "xlat/clocknames.h" under XLAT_MACROS_ONLY.
(gettimeofday, settimeofday): Call print_timeval with rtc=true.
(osf_gettimeofday, osf_settimeofday): Call print_timeval32 with rtc=true.
(nanosleep): Call print_timespec with rtc=false.
(getitimer, setitimer): Call print_itimerval with rtc=false.
(osf_getitimer, osf_setitimer): Call print_itimerval32 wirh rtc=false.
(do_adjtimex): Add rtc argument, handle it.
(is_rtcid): New function.
(clock_settime, clock_gettime): Call print_timespec with rtc=true if 0th
argument is a real-time clock (as indicated by is_rtcid).
(SYS_FUNC(clock_getres)): New syscall decoder.
(SYS_FUNC(clock_nanosleep)): Call print_timespec with rtc=true if clock
is realtime (as indicated by is_rtcid) and TIMER_ABSTIME is set in flags.
(SYS_FUNC(clock_adjtime)): Call do_adjtimex with rtc=true if clock is
realtime.
* tests/adjtimex.c: Update expected output.
* tests/clock_nanosleep.c: Likewise.
This commit is contained in:
Eugene Syromyatnikov 2018-10-07 06:00:36 +02:00
parent 3a94852d43
commit 9baa6bcc88
20 changed files with 168 additions and 124 deletions

2
aio.c
View File

@ -270,7 +270,7 @@ print_io_getevents(struct tcb *tcp, bool has_usig)
* whether the syscall has failed or not.
*/
temporarily_clear_syserror(tcp);
print_timespec(tcp, tcp->u_arg[4]);
print_timespec(tcp, tcp->u_arg[4], false);
if (has_usig) {
tprints(", ");
print_aio_sigset(tcp, tcp->u_arg[5]);

6
defs.h
View File

@ -1086,12 +1086,12 @@ typedef struct {
int tv_sec, tv_usec;
} timeval32_t;
extern void print_timeval32_t(const timeval32_t *);
extern void print_timeval32_t(const timeval32_t *, bool rtc);
extern void printrusage32(struct tcb *, kernel_ulong_t);
extern const char *sprint_timeval32(struct tcb *, kernel_ulong_t addr);
extern void print_timeval32(struct tcb *, kernel_ulong_t addr);
extern void print_timeval32(struct tcb *, kernel_ulong_t addr, bool rtc);
extern void print_timeval32_utimes(struct tcb *, kernel_ulong_t addr);
extern void print_itimerval32(struct tcb *, kernel_ulong_t addr);
extern void print_itimerval32(struct tcb *, kernel_ulong_t addr, bool rtc);
#endif
#ifdef HAVE_STRUCT_USER_DESC

4
desc.c
View File

@ -75,7 +75,7 @@ SYS_FUNC(dup3)
static int
decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
void (*const print_tv_ts) (struct tcb *, kernel_ulong_t),
void (*const print_tv_ts) (struct tcb *, kernel_ulong_t, bool),
const char * (*const sprint_tv_ts) (struct tcb *, kernel_ulong_t))
{
int i, j;
@ -128,7 +128,7 @@ decode_select(struct tcb *const tcp, const kernel_ulong_t *const args,
}
free(fds);
tprints(", ");
print_tv_ts(tcp, args[4]);
print_tv_ts(tcp, args[4], false);
} else {
static char outstr[1024];
char *outptr;

10
futex.c
View File

@ -78,6 +78,7 @@ SYS_FUNC(futex)
const kernel_ulong_t uaddr = tcp->u_arg[0];
const int op = tcp->u_arg[1];
const int cmd = op & 127;
const bool is_rt = op & FUTEX_CLOCK_REALTIME;
const kernel_ulong_t timeout = tcp->u_arg[3];
const kernel_ulong_t uaddr2 = tcp->u_arg[4];
const unsigned int val = tcp->u_arg[2];
@ -101,16 +102,17 @@ SYS_FUNC(futex)
case FUTEX_WAIT:
tprintf(", %u", val);
tprints(", ");
print_timespec(tcp, timeout);
/* timeout in FUTEX_WAIT is relative, contrary to other ops */
print_timespec(tcp, timeout, false);
break;
case FUTEX_LOCK_PI:
tprints(", ");
print_timespec(tcp, timeout);
print_timespec(tcp, timeout, true);
break;
case FUTEX_WAIT_BITSET:
tprintf(", %u", val);
tprints(", ");
print_timespec(tcp, timeout);
print_timespec(tcp, timeout, is_rt);
tprints(", ");
printxval(futexbitset, val3, NULL);
break;
@ -155,7 +157,7 @@ SYS_FUNC(futex)
case FUTEX_WAIT_REQUEUE_PI:
tprintf(", %u", val);
tprints(", ");
print_timespec(tcp, timeout);
print_timespec(tcp, timeout, is_rt);
tprints(", ");
printaddrpival(tcp, uaddr2);
break;

View File

@ -89,14 +89,14 @@ SYS_FUNC(semtimedop)
tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
tprints(", ");
#if defined(S390) || defined(S390X)
print_timespec(tcp, tcp->u_arg[2]);
print_timespec(tcp, tcp->u_arg[2], false);
#else
print_timespec(tcp, tcp->u_arg[4]);
print_timespec(tcp, tcp->u_arg[4], false);
#endif
} else {
tprint_sembuf_array(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprints(", ");
print_timespec(tcp, tcp->u_arg[3]);
print_timespec(tcp, tcp->u_arg[3], false);
}
return RVAL_DECODED;
}

View File

@ -60,7 +60,6 @@
/* like another call */
#define sys_acct sys_chdir
#define sys_chroot sys_chdir
#define sys_clock_getres sys_clock_gettime
#define sys_connect sys_bind
#define sys_fchdir sys_close
#define sys_fdatasync sys_close
@ -95,7 +94,6 @@
#define sys_setregid16 sys_setreuid16
#define sys_setresgid sys_setresuid
#define sys_setresgid16 sys_setresuid16
#define sys_stime sys_time
#define sys_swapoff sys_chdir
#define sys_symlink sys_link
#define sys_syncfs sys_close

View File

@ -211,7 +211,7 @@ SYS_FUNC(recvmmsg)
/* flags */
printflags(msg_flags, tcp->u_arg[3], "MSG_???");
tprints(", ");
print_timespec(tcp, tcp->u_arg[4]);
print_timespec(tcp, tcp->u_arg[4], false);
}
return 0;
} else {

4
mq.c
View File

@ -53,7 +53,7 @@ SYS_FUNC(mq_timedsend)
printstrn(tcp, tcp->u_arg[1], tcp->u_arg[2]);
tprintf(", %" PRI_klu ", %u, ", tcp->u_arg[2],
(unsigned int) tcp->u_arg[3]);
print_timespec(tcp, tcp->u_arg[4]);
print_timespec(tcp, tcp->u_arg[4], true);
return RVAL_DECODED;
}
@ -76,7 +76,7 @@ SYS_FUNC(mq_timedreceive)
* whether the syscall has failed or not.
*/
temporarily_clear_syserror(tcp);
print_timespec(tcp, tcp->u_arg[4]);
print_timespec(tcp, tcp->u_arg[4], true);
restore_cleared_syserror(tcp);
}
return 0;

View File

@ -103,21 +103,21 @@ static void
print_scm_timestamp(struct tcb *tcp, const void *cmsg_data,
const unsigned int data_len)
{
print_struct_timeval_data_size(cmsg_data, data_len);
print_struct_timeval_data_size(cmsg_data, data_len, true);
}
static void
print_scm_timestampns(struct tcb *tcp, const void *cmsg_data,
const unsigned int data_len)
{
print_struct_timespec_data_size(cmsg_data, data_len);
print_struct_timespec_data_size(cmsg_data, data_len, true);
}
static void
print_scm_timestamping(struct tcb *tcp, const void *cmsg_data,
const unsigned int data_len)
{
print_struct_timespec_array_data_size(cmsg_data, 3, data_len);
print_struct_timespec_array_data_size(cmsg_data, 3, data_len, true);
}
static void

2
poll.c
View File

@ -169,7 +169,7 @@ SYS_FUNC(ppoll)
if (entering(tcp)) {
decode_poll_entering(tcp);
print_timespec(tcp, tcp->u_arg[2]);
print_timespec(tcp, tcp->u_arg[2], false);
tprints(", ");
/* NB: kernel requires arg[4] == NSIG_BYTES */
print_sigset_addr_len(tcp, tcp->u_arg[3], tcp->u_arg[4]);

View File

@ -32,16 +32,22 @@
#include MPERS_DEFS
static void
print_time_t(struct tcb *tcp, const kernel_ulong_t addr)
{
time_t t;
if (!umove_or_printaddr(tcp, addr, &t)) {
tprintf("[%lld", (long long) t);
tprints_comment(sprinttime(t));
tprints("]");
}
}
SYS_FUNC(time)
{
if (exiting(tcp)) {
time_t t;
if (!umove_or_printaddr(tcp, tcp->u_arg[0], &t)) {
tprintf("[%lld", (long long) t);
tprints_comment(sprinttime(t));
tprints("]");
}
print_time_t(tcp, tcp->u_arg[0]);
if (!syserror(tcp)) {
tcp->auxstr = sprinttime((time_t) tcp->u_rval);
@ -52,3 +58,10 @@ SYS_FUNC(time)
return 0;
}
SYS_FUNC(stime)
{
print_time_t(tcp, tcp->u_arg[0]);
return RVAL_DECODED;
}

View File

@ -46,10 +46,13 @@ typedef struct timespec timespec_t;
static const char timespec_fmt[] = "{tv_sec=%lld, tv_nsec=%llu}";
static void
print_timespec_t(const timespec_t *t)
print_timespec_t(const timespec_t *t, bool rtc)
{
tprintf(timespec_fmt, (long long) t->tv_sec,
zero_extend_signed_to_ull(t->tv_nsec));
if (rtc)
tprints_comment(sprinttime_nsec(t->tv_sec,
zero_extend_signed_to_ull(t->tv_nsec)));
}
static void
@ -59,7 +62,7 @@ print_timespec_t_utime(const timespec_t *t)
case UTIME_NOW:
case UTIME_OMIT:
if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
print_timespec_t(t);
print_timespec_t(t, false);
if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
break;
@ -68,28 +71,26 @@ print_timespec_t_utime(const timespec_t *t)
? "UTIME_NOW" : "UTIME_OMIT");
break;
default:
print_timespec_t(t);
tprints_comment(sprinttime_nsec(t->tv_sec,
zero_extend_signed_to_ull(t->tv_nsec)));
print_timespec_t(t, true);
break;
}
}
MPERS_PRINTER_DECL(bool, print_struct_timespec_data_size,
const void *arg, const size_t size)
const void *arg, const size_t size, bool rtc)
{
if (size < sizeof(timespec_t)) {
tprints("?");
return false;
}
print_timespec_t(arg);
print_timespec_t(arg, rtc);
return true;
}
MPERS_PRINTER_DECL(bool, print_struct_timespec_array_data_size,
const void *arg, const unsigned int nmemb,
const size_t size)
const size_t size, bool rtc)
{
const timespec_t *ts = arg;
unsigned int i;
@ -104,7 +105,7 @@ MPERS_PRINTER_DECL(bool, print_struct_timespec_array_data_size,
for (i = 0; i < nmemb; i++) {
if (i)
tprints(", ");
print_timespec_t(&ts[i]);
print_timespec_t(&ts[i], rtc);
}
tprints("]");
@ -112,14 +113,14 @@ MPERS_PRINTER_DECL(bool, print_struct_timespec_array_data_size,
}
MPERS_PRINTER_DECL(void, print_timespec,
struct tcb *const tcp, const kernel_ulong_t addr)
struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
timespec_t t;
if (umove_or_printaddr(tcp, addr, &t))
return;
print_timespec_t(&t);
print_timespec_t(&t, rtc);
}
MPERS_PRINTER_DECL(const char *, sprint_timespec,
@ -166,8 +167,8 @@ MPERS_PRINTER_DECL(void, print_itimerspec,
return;
tprints("{it_interval=");
print_timespec_t(&t[0]);
print_timespec_t(&t[0], false);
tprints(", it_value=");
print_timespec_t(&t[1]);
print_timespec_t(&t[1], false);
tprints("}");
}

View File

@ -39,46 +39,41 @@ typedef struct timeval timeval_t;
static const char timeval_fmt[] = "{tv_sec=%lld, tv_usec=%llu}";
static void
print_timeval_t(const timeval_t *t)
print_timeval_t(const timeval_t *t, bool rtc)
{
tprintf(timeval_fmt, (long long) t->tv_sec,
zero_extend_signed_to_ull(t->tv_usec));
if (rtc)
tprints_comment(sprinttime_usec(t->tv_sec,
zero_extend_signed_to_ull(t->tv_usec)));
}
static void
print_timeval_t_utime(const timeval_t *t)
MPERS_PRINTER_DECL(void, print_struct_timeval, const void *arg, bool rtc)
{
print_timeval_t(t);
tprints_comment(sprinttime_usec(t->tv_sec,
zero_extend_signed_to_ull(t->tv_usec)));
}
MPERS_PRINTER_DECL(void, print_struct_timeval, const void *arg)
{
print_timeval_t(arg);
print_timeval_t(arg, rtc);
}
MPERS_PRINTER_DECL(bool, print_struct_timeval_data_size,
const void *arg, const size_t size)
const void *arg, const size_t size, bool rtc)
{
if (size < sizeof(timeval_t)) {
tprints("?");
return false;
}
print_timeval_t(arg);
print_timeval_t(arg, rtc);
return true;
}
MPERS_PRINTER_DECL(void, print_timeval,
struct tcb *const tcp, const kernel_ulong_t addr)
struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
timeval_t t;
if (umove_or_printaddr(tcp, addr, &t))
return;
print_timeval_t(&t);
print_timeval_t(&t, rtc);
}
MPERS_PRINTER_DECL(void, print_timeval_utimes,
@ -90,9 +85,9 @@ MPERS_PRINTER_DECL(void, print_timeval_utimes,
return;
tprints("[");
print_timeval_t_utime(&t[0]);
print_timeval_t(&t[0], true);
tprints(", ");
print_timeval_t_utime(&t[1]);
print_timeval_t(&t[1], true);
tprints("]");
}
@ -117,7 +112,7 @@ MPERS_PRINTER_DECL(const char *, sprint_timeval,
}
MPERS_PRINTER_DECL(void, print_itimerval,
struct tcb *const tcp, const kernel_ulong_t addr)
struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
timeval_t t[2];
@ -125,38 +120,33 @@ MPERS_PRINTER_DECL(void, print_itimerval,
return;
tprints("{it_interval=");
print_timeval_t(&t[0]);
print_timeval_t(&t[0], false);
tprints(", it_value=");
print_timeval_t(&t[1]);
print_timeval_t(&t[1], rtc);
tprints("}");
}
#ifdef ALPHA
void
print_timeval32_t(const timeval32_t *t)
print_timeval32_t(const timeval32_t *t, bool rtc)
{
tprintf(timeval_fmt, (long long) t->tv_sec,
zero_extend_signed_to_ull(t->tv_usec));
}
static void
print_timeval32_t_utime(const timeval32_t *t)
{
print_timeval32_t(t);
tprints_comment(sprinttime_usec(t->tv_sec,
zero_extend_signed_to_ull(t->tv_usec)));
if (rtc)
tprints_comment(sprinttime_usec(t->tv_sec,
zero_extend_signed_to_ull(t->tv_usec)));
}
void
print_timeval32(struct tcb *const tcp, const kernel_ulong_t addr)
print_timeval32(struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
timeval32_t t;
if (umove_or_printaddr(tcp, addr, &t))
return;
print_timeval32_t(&t);
print_timeval32_t(&t, rtc);
}
void
@ -168,14 +158,14 @@ print_timeval32_utimes(struct tcb *const tcp, const kernel_ulong_t addr)
return;
tprints("[");
print_timeval32_t_utime(&t[0]);
print_timeval32_t(&t[0], true);
tprints(", ");
print_timeval32_t_utime(&t[1]);
print_timeval32_t(&t[1], true);
tprints("]");
}
void
print_itimerval32(struct tcb *const tcp, const kernel_ulong_t addr)
print_itimerval32(struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
timeval32_t t[2];
@ -183,9 +173,9 @@ print_itimerval32(struct tcb *const tcp, const kernel_ulong_t addr)
return;
tprints("{it_interval=");
print_timeval32_t(&t[0]);
print_timeval32_t(&t[0], false);
tprints(", it_value=");
print_timeval32_t(&t[1]);
print_timeval32_t(&t[1], rtc);
tprints("}");
}

View File

@ -42,7 +42,7 @@ typedef struct timex struct_timex;
#include "xlat/adjtimex_status.h"
MPERS_PRINTER_DECL(int, print_timex,
struct tcb *const tcp, const kernel_ulong_t addr)
struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
struct_timex tx;
@ -58,7 +58,7 @@ MPERS_PRINTER_DECL(int, print_timex,
tprintf(", constant=%jd, precision=%ju, tolerance=%jd, time=",
(intmax_t) tx.constant, (uintmax_t) tx.precision,
(intmax_t) tx.tolerance);
MPERS_FUNC_NAME(print_struct_timeval)(&tx.time);
MPERS_FUNC_NAME(print_struct_timeval)(&tx.time, true);
tprintf(", tick=%jd, ppsfreq=%jd, jitter=%jd",
(intmax_t) tx.tick, (intmax_t) tx.ppsfreq, (intmax_t) tx.jitter);
tprintf(", shift=%d, stabil=%jd, jitcnt=%jd",

View File

@ -47,9 +47,9 @@ MPERS_PRINTER_DECL(void, printrusage,
return;
tprints("{ru_utime=");
MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_utime);
MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_utime, false);
tprints(", ru_stime=");
MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_stime);
MPERS_FUNC_NAME(print_struct_timeval)(&ru.ru_stime, false);
if (abbrev(tcp))
tprints(", ...");
else {

View File

@ -89,7 +89,7 @@ SYS_FUNC(sched_rr_get_interval)
if (syserror(tcp))
printaddr(tcp->u_arg[1]);
else
print_timespec(tcp, tcp->u_arg[1]);
print_timespec(tcp, tcp->u_arg[1], false);
}
return 0;
}

View File

@ -669,7 +669,7 @@ SYS_FUNC(rt_sigtimedwait)
*/
printaddr(tcp->u_arg[1]);
tprints(", ");
print_timespec(tcp, tcp->u_arg[2]);
print_timespec(tcp, tcp->u_arg[2], false);
tprintf(", %" PRI_klu, tcp->u_arg[3]);
} else {
char *sts = xstrdup(sprint_timespec(tcp, tcp->u_arg[2]));

View File

@ -61,18 +61,19 @@ main(void)
else
putchar('0');
printf(", constant=%jd, precision=%jd"
", tolerance=%jd, time={tv_sec=%lld, tv_usec=%llu}, tick=%jd"
", ppsfreq=%jd, jitter=%jd, shift=%d, stabil=%jd, jitcnt=%jd"
", calcnt=%jd, errcnt=%jd, stbcnt=%jd"
#ifdef HAVE_STRUCT_TIMEX_TAI
", tai=%d"
#endif
"}) = %d (",
", tolerance=%jd, time={tv_sec=%lld, tv_usec=%llu}",
(intmax_t) tx->constant,
(intmax_t) tx->precision,
(intmax_t) tx->tolerance,
(long long) tx->time.tv_sec,
zero_extend_signed_to_ull(tx->time.tv_usec),
zero_extend_signed_to_ull(tx->time.tv_usec));
print_time_t_usec(tx->time.tv_sec, tx->time.tv_usec, true);
printf(", tick=%jd, ppsfreq=%jd, jitter=%jd, shift=%d, stabil=%jd"
", jitcnt=%jd, calcnt=%jd, errcnt=%jd, stbcnt=%jd"
#ifdef HAVE_STRUCT_TIMEX_TAI
", tai=%d"
#endif
"}) = %d (",
(intmax_t) tx->tick,
(intmax_t) tx->ppsfreq,
(intmax_t) tx->jitter,

View File

@ -128,9 +128,11 @@ main(void)
puts("--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---");
assert(syscall(__NR_clock_gettime, CLOCK_REALTIME, &req.ts) == 0);
printf("clock_gettime(CLOCK_REALTIME, {tv_sec=%lld, tv_nsec=%llu}) = 0\n",
printf("clock_gettime(CLOCK_REALTIME, {tv_sec=%lld, tv_nsec=%llu}",
(long long) req.ts.tv_sec,
zero_extend_signed_to_ull(req.ts.tv_nsec));
print_time_t_nsec(req.ts.tv_sec, req.ts.tv_nsec, true);
puts(") = 0");
++req.ts.tv_sec;
rem.ts.tv_sec = 0xc0de4;
@ -138,10 +140,12 @@ main(void)
assert(syscall(__NR_clock_nanosleep, CLOCK_REALTIME, TIMER_ABSTIME,
&req.ts, &rem.ts) == -1);
printf("clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME"
", {tv_sec=%lld, tv_nsec=%llu}, %p)"
" = ? ERESTARTNOHAND (To be restarted if no handler)\n",
", {tv_sec=%lld, tv_nsec=%llu}",
(long long) req.ts.tv_sec,
zero_extend_signed_to_ull(req.ts.tv_nsec), &rem.ts);
zero_extend_signed_to_ull(req.ts.tv_nsec));
print_time_t_nsec(req.ts.tv_sec, req.ts.tv_nsec, true);
printf(", %p) = ? ERESTARTNOHAND (To be restarted if no handler)\n",
&rem.ts);
puts("--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL} ---");
puts("+++ exited with 0 +++");

91
time.c
View File

@ -33,6 +33,10 @@
#include <signal.h>
#include <sys/timex.h>
#define XLAT_MACROS_ONLY
# include "xlat/clocknames.h"
#undef XLAT_MACROS_ONLY
static void
print_timezone(struct tcb *const tcp, const kernel_ulong_t addr)
{
@ -48,7 +52,7 @@ print_timezone(struct tcb *const tcp, const kernel_ulong_t addr)
SYS_FUNC(gettimeofday)
{
if (exiting(tcp)) {
print_timeval(tcp, tcp->u_arg[0]);
print_timeval(tcp, tcp->u_arg[0], true);
tprints(", ");
print_timezone(tcp, tcp->u_arg[1]);
}
@ -59,7 +63,7 @@ SYS_FUNC(gettimeofday)
SYS_FUNC(osf_gettimeofday)
{
if (exiting(tcp)) {
print_timeval32(tcp, tcp->u_arg[0]);
print_timeval32(tcp, tcp->u_arg[0], true);
tprints(", ");
print_timezone(tcp, tcp->u_arg[1]);
}
@ -69,7 +73,7 @@ SYS_FUNC(osf_gettimeofday)
SYS_FUNC(settimeofday)
{
print_timeval(tcp, tcp->u_arg[0]);
print_timeval(tcp, tcp->u_arg[0], true);
tprints(", ");
print_timezone(tcp, tcp->u_arg[1]);
@ -79,7 +83,7 @@ SYS_FUNC(settimeofday)
#ifdef ALPHA
SYS_FUNC(osf_settimeofday)
{
print_timeval32(tcp, tcp->u_arg[0]);
print_timeval32(tcp, tcp->u_arg[0], true);
tprints(", ");
print_timezone(tcp, tcp->u_arg[1]);
@ -90,7 +94,7 @@ SYS_FUNC(osf_settimeofday)
SYS_FUNC(nanosleep)
{
if (entering(tcp)) {
print_timespec(tcp, tcp->u_arg[0]);
print_timespec(tcp, tcp->u_arg[0], false);
tprints(", ");
} else {
@ -102,7 +106,7 @@ SYS_FUNC(nanosleep)
*/
if (is_erestart(tcp)) {
temporarily_clear_syserror(tcp);
print_timespec(tcp, tcp->u_arg[1]);
print_timespec(tcp, tcp->u_arg[1], false);
restore_cleared_syserror(tcp);
} else {
printaddr(tcp->u_arg[1]);
@ -115,12 +119,13 @@ SYS_FUNC(nanosleep)
SYS_FUNC(getitimer)
{
unsigned int tid = tcp->u_arg[0];
if (entering(tcp)) {
printxval(itimer_which, (unsigned int) tcp->u_arg[0],
"ITIMER_???");
printxval(itimer_which, tid, "ITIMER_???");
tprints(", ");
} else {
print_itimerval(tcp, tcp->u_arg[1]);
print_itimerval(tcp, tcp->u_arg[1], false);
}
return 0;
}
@ -128,12 +133,13 @@ SYS_FUNC(getitimer)
#ifdef ALPHA
SYS_FUNC(osf_getitimer)
{
unsigned int tid = tcp->u_arg[0];
if (entering(tcp)) {
printxval(itimer_which, (unsigned int) tcp->u_arg[0],
"ITIMER_???");
printxval(itimer_which, tid, "ITIMER_???");
tprints(", ");
} else {
print_itimerval32(tcp, tcp->u_arg[1]);
print_itimerval32(tcp, tcp->u_arg[1], false);
}
return 0;
}
@ -141,14 +147,15 @@ SYS_FUNC(osf_getitimer)
SYS_FUNC(setitimer)
{
unsigned int tid = tcp->u_arg[0];
if (entering(tcp)) {
printxval(itimer_which, (unsigned int) tcp->u_arg[0],
"ITIMER_???");
printxval(itimer_which, tid, "ITIMER_???");
tprints(", ");
print_itimerval(tcp, tcp->u_arg[1]);
print_itimerval(tcp, tcp->u_arg[1], false);
tprints(", ");
} else {
print_itimerval(tcp, tcp->u_arg[2]);
print_itimerval(tcp, tcp->u_arg[2], false);
}
return 0;
}
@ -156,14 +163,15 @@ SYS_FUNC(setitimer)
#ifdef ALPHA
SYS_FUNC(osf_setitimer)
{
unsigned int tid = tcp->u_arg[0];
if (entering(tcp)) {
printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
"ITIMER_???");
printxval_index(itimer_which, tid, "ITIMER_???");
tprints(", ");
print_itimerval32(tcp, tcp->u_arg[1]);
print_itimerval32(tcp, tcp->u_arg[1], false);
tprints(", ");
} else {
print_itimerval32(tcp, tcp->u_arg[2]);
print_itimerval32(tcp, tcp->u_arg[2], false);
}
return 0;
}
@ -172,9 +180,9 @@ SYS_FUNC(osf_setitimer)
#include "xlat/adjtimex_state.h"
static int
do_adjtimex(struct tcb *const tcp, const kernel_ulong_t addr)
do_adjtimex(struct tcb *const tcp, const kernel_ulong_t addr, bool rtc)
{
if (print_timex(tcp, addr))
if (print_timex(tcp, addr, rtc))
return 0;
tcp->auxstr = xlookup(adjtimex_state, (kernel_ulong_t) tcp->u_rval);
return RVAL_STR;
@ -183,7 +191,7 @@ do_adjtimex(struct tcb *const tcp, const kernel_ulong_t addr)
SYS_FUNC(adjtimex)
{
if (exiting(tcp))
return do_adjtimex(tcp, tcp->u_arg[0]);
return do_adjtimex(tcp, tcp->u_arg[0], true);
return 0;
}
@ -227,11 +235,26 @@ printclockname(int clockid)
printxval(clocknames, clockid, "CLOCK_???");
}
static bool
is_rtcid(int clk)
{
switch (clk) {
case CLOCK_REALTIME:
case CLOCK_REALTIME_COARSE:
case CLOCK_REALTIME_ALARM:
case CLOCK_TAI:
return true;
}
return false;
}
SYS_FUNC(clock_settime)
{
printclockname(tcp->u_arg[0]);
tprints(", ");
print_timespec(tcp, tcp->u_arg[1]);
print_timespec(tcp, tcp->u_arg[1], is_rtcid(tcp->u_arg[0]));
return RVAL_DECODED;
}
@ -242,7 +265,18 @@ SYS_FUNC(clock_gettime)
printclockname(tcp->u_arg[0]);
tprints(", ");
} else {
print_timespec(tcp, tcp->u_arg[1]);
print_timespec(tcp, tcp->u_arg[1], is_rtcid(tcp->u_arg[0]));
}
return 0;
}
SYS_FUNC(clock_getres)
{
if (entering(tcp)) {
printclockname(tcp->u_arg[0]);
tprints(", ");
} else {
print_timespec(tcp, tcp->u_arg[1], false);
}
return 0;
}
@ -254,7 +288,8 @@ SYS_FUNC(clock_nanosleep)
tprints(", ");
printflags(clockflags, tcp->u_arg[1], "TIMER_???");
tprints(", ");
print_timespec(tcp, tcp->u_arg[2]);
print_timespec(tcp, tcp->u_arg[2], is_rtcid(tcp->u_arg[0])
&& (tcp->u_arg[1] & TIMER_ABSTIME));
tprints(", ");
} else {
/*
@ -263,7 +298,7 @@ SYS_FUNC(clock_nanosleep)
*/
if (!tcp->u_arg[1] && is_erestart(tcp)) {
temporarily_clear_syserror(tcp);
print_timespec(tcp, tcp->u_arg[3]);
print_timespec(tcp, tcp->u_arg[3], false);
restore_cleared_syserror(tcp);
} else {
printaddr(tcp->u_arg[3]);
@ -275,7 +310,7 @@ SYS_FUNC(clock_nanosleep)
SYS_FUNC(clock_adjtime)
{
if (exiting(tcp))
return do_adjtimex(tcp, tcp->u_arg[1]);
return do_adjtimex(tcp, tcp->u_arg[1], is_rtcid(tcp->u_arg[0]));
printclockname(tcp->u_arg[0]);
tprints(", ");
return 0;