]> granicus.if.org Git - strace/commitdiff
2007-09-22 Dmitry V. Levin <ldv@altlinux.org>
authorRoland McGrath <roland@redhat.com>
Thu, 1 Nov 2007 21:50:54 +0000 (21:50 +0000)
committerRoland McGrath <roland@redhat.com>
Thu, 1 Nov 2007 21:50:54 +0000 (21:50 +0000)
* time.c (print_timespec, sprint_timespec): New functions.
* defs.h (print_timespec, sprint_timespec): Declare them.
* desc.c (sys_io_getevents): Use print_timespec.
* stream.c (sys_ppoll): Likewise.
(decode_poll): Use sprint_timespec.

defs.h
desc.c
stream.c
time.c

diff --git a/defs.h b/defs.h
index 2905a33ca70689cffe34dbd9eba5bd5b3dcc01b0..d8c1710bd44818d9bbd5b505755dca14b3ee15a6 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -457,6 +457,8 @@ extern void printpath P((struct tcb *, long));
 extern void printpathn P((struct tcb *, long, int));
 extern void printtv_bitness P((struct tcb *, long, enum bitness_t, int));
 extern void sprinttv P((struct tcb *, long, enum bitness_t, char *));
+extern void print_timespec P((struct tcb *, long));
+extern void sprint_timespec P((char *, struct tcb *, long));
 #ifdef HAVE_SIGINFO_T
 extern void printsiginfo P((siginfo_t *, int));
 #endif
diff --git a/desc.c b/desc.c
index 47aa92c8709581e4dd86768efc070f1bd9f9fe2d..43bab6487a03134a10e65c963b56507257fb09ce 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -816,8 +816,7 @@ struct tcb *tcp;
 }
 
 int
-sys_io_getevents(tcp)
-struct tcb *tcp;
+sys_io_getevents(struct tcb * tcp)
 {
        if (entering(tcp)) {
                tprintf("%ld, %ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1],
@@ -851,15 +850,7 @@ struct tcb *tcp;
 #endif
                }
 
-               if (tcp->u_arg[4] == 0)
-                       tprintf("NULL");
-               else {
-                       struct timespec to;
-                       if (umove(tcp, tcp->u_arg[4], &to) == 0)
-                               tprintf("{%lu, %lu}", to.tv_sec, to.tv_nsec);
-                       else
-                               tprintf("{...}");
-               }
+               print_timespec(tcp, tcp->u_arg[4]);
        }
        return 0;
 }
index dfdfdb2f57d7f4f8929e8d2056845352e3d8c956..e97392cc53d2ffa5d9f38217ccd661334ee61145 100644 (file)
--- a/stream.c
+++ b/stream.c
@@ -417,15 +417,10 @@ decode_poll(struct tcb *tcp, long pts)
                        strcat(outstr, "]");
 
                if (pts) {
-                       struct timespec ts;
                        char str[128];
 
                        sprintf(str, "%sleft ", cumlen ? ", " : "");
-                       if (umove(tcp, pts, &ts) == 0)
-                               sprintf(str + strlen(str), "{%lu, %lu}",
-                                       ts.tv_sec, ts.tv_nsec);
-                       else
-                               strcat(str, "{...}");
+                       sprint_timespec(str + strlen(str), tcp, pts);
                        if ((cumlen += strlen(str)) < sizeof(outstr))
                                strcat(outstr, str);
                }
@@ -459,11 +454,8 @@ sys_ppoll(struct tcb *tcp)
 {
        int rc = decode_poll(tcp, tcp->u_arg[2]);
        if (entering(tcp)) {
-               struct timespec ts;
-               if (umove(tcp, tcp->u_arg[2], &ts) == 0)
-                       tprintf("{%lu, %lu}, ", ts.tv_sec, ts.tv_nsec);
-               else
-                       tprintf("{...}, ");
+               print_timespec(tcp, tcp->u_arg[2]);
+               tprintf(", ");
                print_sigset(tcp, tcp->u_arg[3], 0);
                tprintf(", %lu", tcp->u_arg[4]);
        }
diff --git a/time.c b/time.c
index ce309b68c4ef5fd231708ccfd5d167436b4f6e1a..676aace4818c55c53f344b183d9a5988f296e20b 100644 (file)
--- a/time.c
+++ b/time.c
@@ -150,6 +150,76 @@ sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
        }
 }
 
+void print_timespec (struct tcb *tcp, long addr)
+{
+       if (addr == 0)
+               tprintf("NULL");
+       else if (!verbose(tcp))
+               tprintf("%#lx", addr);
+       else {
+               int     rc;
+
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+               if (personality_wordsize[current_personality] == 4)
+               {
+                       struct timeval32 tv;
+
+                       if ((rc = umove(tcp, addr, &tv)) >= 0)
+                               tprintf("{%u, %u}",
+                                       tv.tv_sec, tv.tv_usec);
+               } else
+               {
+#endif
+                       struct timespec ts;
+
+                       if ((rc = umove(tcp, addr, &ts)) >= 0)
+                               tprintf("{%lu, %lu}",
+                                       (unsigned long) ts.tv_sec,
+                                       (unsigned long) ts.tv_nsec);
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+               }
+#endif
+
+               if (rc < 0)
+                       tprintf("{...}");
+       }
+}
+
+void sprint_timespec (char *buf, struct tcb *tcp, long addr)
+{
+       if (addr == 0)
+               strcpy(buf, "NULL");
+       else if (!verbose(tcp))
+               sprintf(buf, "%#lx", addr);
+       else {
+               int     rc;
+
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+               if (personality_wordsize[current_personality] == 4)
+               {
+                       struct timeval32 tv;
+
+                       if ((rc = umove(tcp, addr, &tv)) >= 0)
+                               sprintf(buf, "{%u, %u}",
+                                       tv.tv_sec, tv.tv_usec);
+               } else
+               {
+#endif
+                       struct timespec ts;
+
+                       if ((rc = umove(tcp, addr, &ts)) >= 0)
+                               sprintf(buf, "{%lu, %lu}",
+                                       (unsigned long) ts.tv_sec,
+                                       (unsigned long) ts.tv_nsec);
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+               }
+#endif
+
+               if (rc < 0)
+                       strcpy(buf, "{...}");
+       }
+}
+
 int
 sys_time(tcp)
 struct tcb *tcp;