]> granicus.if.org Git - strace/commitdiff
Print time in ISO 8601 format in time syscall decoder
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 23 Apr 2017 19:51:27 +0000 (21:51 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 24 Apr 2017 23:14:57 +0000 (23:14 +0000)
* 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
tests/time.c

index 82d64fa20324962669c8b1fc04b3567ecc8e2b82..45ed251453cd6c9997b34522b31e6bcac9f78728 100644 (file)
@@ -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;
index fc71619ae58381e2aea4c3c95b0a90eaa22cb637..baa7e3e843de5cf8b445bfe7818b44273495fbf9 100644 (file)
@@ -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;