From 4b8def02befb04a6bedad0bf110adce46ee085c5 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Sun, 23 Apr 2017 21:51:27 +0200 Subject: [PATCH] Print time in ISO 8601 format in time syscall decoder * print_time.c (SYS_FUNC(time)): Print timestamp stringification (via sprinttime) for the value stored in the argument and return value (return RVAL_STR in the latter case). * tests/time.c (main): Update expected output. --- print_time.c | 13 +++++++++++-- tests/time.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/print_time.c b/print_time.c index 82d64fa2..45ed2514 100644 --- a/print_time.c +++ b/print_time.c @@ -36,8 +36,17 @@ SYS_FUNC(time) if (exiting(tcp)) { time_t t; - if (!umove_or_printaddr(tcp, tcp->u_arg[0], &t)) - tprintf("[%jd]", (intmax_t) t); + if (!umove_or_printaddr(tcp, tcp->u_arg[0], &t)) { + tprintf("[%lld", (long long) t); + tprints_comment(sprinttime(t)); + tprints("]"); + } + + if (!syserror(tcp)) { + tcp->auxstr = sprinttime((time_t) tcp->u_rval); + + return RVAL_STR; + } } return 0; diff --git a/tests/time.c b/tests/time.c index fc71619a..baa7e3e8 100644 --- a/tests/time.c +++ b/tests/time.c @@ -45,13 +45,19 @@ main(void) time_t t = syscall(__NR_time, NULL); if ((time_t) -1 == t) perror_msg_and_skip("time"); - printf("time(NULL) = %jd\n", (intmax_t) t); + printf("time(NULL) = %lld (", (long long) t); + print_time_t_nsec(t, 0, 0); + puts(")"); t = syscall(__NR_time, p + 1); printf("time(%p) = %s\n", p + 1, sprintrc(t)); t = syscall(__NR_time, p); - printf("time([%jd]) = %jd\n", (intmax_t) *p, (intmax_t) t); + printf("time([%lld", (long long) *p); + print_time_t_nsec((time_t) *p, 0, 1), + printf("]) = %lld (", (long long) t); + print_time_t_nsec(t, 0, 0); + puts(")"); puts("+++ exited with 0 +++"); return 0; -- 2.40.0