]> granicus.if.org Git - strace/commitdiff
2006-12-10 Dmitry V. Levin <ldv@altlinux.org>
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 13 Dec 2006 17:10:11 +0000 (17:10 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 13 Dec 2006 17:10:11 +0000 (17:10 +0000)
Add biarch support for "struct timeval".
* defs.h (bitness_t): New enum type.
(printtv_bitness, sprinttv): New function prototypes.
(printtv): Convert to macro wrapper around printtv_bitness().
(printtv32): Remove.
* desc.c (decode_select): Use printtv_bitness() and sprinttv().
(sys_oldselect, sys_osf_select, sys_select, sys_pselect6):
Update decode_select() use.
* file.c [ALPHA] (sys_osf_utimes): Use printtv_bitness().
* time.c (printtv_bitness, sprinttv): New functions.
(printtv, printtv32): Remove.
[ALPHA] (sys_osf_settimeofday, sys_osf_settimeofday):
Use printtv_bitness().
Fixes RH#171626, RH#173050.

defs.h
desc.c
file.c
time.c

diff --git a/defs.h b/defs.h
index 344e4e1a2613987aec3fb5e7593b86246db7a27e..0396b11cbb53cf06a5abd2bb93fcec135400b100 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -421,6 +421,8 @@ extern struct tcb *tcp_last;
 #define P(args) ()
 #endif
 
+enum bitness_t { BITNESS_CURRENT = 0, BITNESS_32 };
+
 extern int set_personality P((int personality));
 extern char *xlookup P((const struct xlat *, int));
 extern struct tcb *alloctcb P((int));
@@ -449,7 +451,8 @@ extern void printnum P((struct tcb *, long, char *));
 extern void printnum_int P((struct tcb *, long, char *));
 extern void printpath P((struct tcb *, long));
 extern void printpathn P((struct tcb *, long, int));
-extern void printtv P((struct tcb *, long));
+extern void printtv_bitness P((struct tcb *, long, enum bitness_t));
+extern void sprinttv P((struct tcb *, long, enum bitness_t, char *));
 #ifdef HAVE_SIGINFO_T
 extern void printsiginfo P((siginfo_t *, int));
 #endif
@@ -468,7 +471,6 @@ extern void printleader P((struct tcb *));
 extern void printtrailer P((struct tcb *));
 extern void tabto P((int));
 extern void call_summary P((FILE *));
-extern void printtv32 P((struct tcb*, long));
 extern void tprint_iov P((struct tcb *, unsigned long, unsigned long));
 
 #ifdef LINUX
@@ -512,6 +514,9 @@ extern int proc_open P((struct tcb *tcp, int attaching));
 #define umove(pid, addr, objp) \
        umoven((pid), (addr), sizeof *(objp), (char *) (objp))
 
+#define printtv(tcp, addr)     \
+       printtv_bitness((tcp), (addr), BITNESS_CURRENT)
+
 #ifdef __STDC__
 #ifdef __GNUC__
 extern void tprintf(const char *fmt, ...)
diff --git a/desc.c b/desc.c
index c3a7e6ccf86e8e50668fae08e80469d36705c80c..6e534daeb36c888d53381c8c78ae77ac4be0e82a 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -401,22 +401,12 @@ struct tcb *tcp;
 #endif /* ALPHA || FREEBSD || SUNOS4 */
 
 static int
-decode_select(tcp, args, bitness)
-struct tcb *tcp;
-long *args;
-int bitness;
+decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
 {
        int i, j, nfds;
        unsigned int fdsize = ((((args[0] + 7) / 8) + sizeof(long) - 1)
                               & -sizeof(long));
        fd_set *fds;
-       struct timeval tv;
-#ifdef ALPHA
-       struct timeval32 {
-               unsigned tv_sec;
-               unsigned tv_usec;
-       } *tv32;
-#endif
        static char outstr[1024];
        char *sep;
        long arg;
@@ -451,22 +441,8 @@ int bitness;
                        tprintf("]");
                }
                free(fds);
-               if (!args[4])
-                       tprintf(", NULL");
-               else if (!verbose(tcp))
-                       tprintf(", %#lx", args[4]);
-               else if (umove(tcp, args[4], &tv) < 0)
-                       tprintf(", {...}");
-               else {
-#ifdef ALPHA
-                       if (bitness) {
-                               tv32=(struct timeval32*)&tv;
-                               tprintf(", {%u, %u}", tv32->tv_sec, tv32->tv_usec);
-                       } else
-#endif
-                               tprintf(", {%lu, %lu}",
-                                       (long) tv.tv_sec, (long) tv.tv_usec);
-               }
+               tprintf(", ");
+               printtv_bitness(tcp, args[4], bitness);
        }
        else
        {
@@ -522,22 +498,12 @@ int bitness;
 #ifdef LINUX
                /* This contains no useful information on SunOS.  */
                if (args[4]) {
-                       char str[64];
+                       char str[128];
 
-                       if (umove(tcp, args[4], &tv) >= 0) {
-#ifdef ALPHA
-                               if (bitness) {
-                                       tv32=(struct timeval32*)&tv;
-                                       sprintf(str, "%sleft {%u, %u}", sep,
-                                               tv32->tv_sec, tv32->tv_usec);
-                               } else
-#endif
-                                       sprintf(str, "%sleft {%lu, %lu}", sep,
-                                               (long) tv.tv_sec, (long) tv.tv_usec);
-
-                               if ((cumlen += strlen(str)) < sizeof(outstr))
-                                       strcat(outstr, str);
-                       }
+                       sprintf(str, "%sleft ", sep);
+                       sprinttv(tcp, args[4], bitness, str + strlen(str));
+                       if ((cumlen += strlen(str)) < sizeof(outstr))
+                               strcat(outstr, str);
                }
 #endif /* LINUX */
                return RVAL_STR;
@@ -557,7 +523,7 @@ struct tcb *tcp;
                tprintf("[...]");
                return 0;
        }
-       return decode_select(tcp, args, 0);
+       return decode_select(tcp, args, BITNESS_CURRENT);
 }
 
 #ifdef ALPHA
@@ -566,7 +532,7 @@ sys_osf_select(tcp)
 struct tcb *tcp;
 {
        long *args = tcp->u_arg;
-       return decode_select(tcp, args, 1);
+       return decode_select(tcp, args, BITNESS_32);
 }
 #endif
 
@@ -873,14 +839,14 @@ int
 sys_select(tcp)
 struct tcb *tcp;
 {
-       return decode_select(tcp, tcp->u_arg, 0);
+       return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
 }
 
 #ifdef LINUX
 int
 sys_pselect6(struct tcb *tcp)
 {
-       int rc = decode_select(tcp, tcp->u_arg, 0);
+       int rc = decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
        if (exiting(tcp)) {
                struct {
                        void *ss;
diff --git a/file.c b/file.c
index dbd16618c9070ea57ab29869108daf84d057c7fb..d03e5f45771ec20dd83b27446d6c773ee7b36fa0 100644 (file)
--- a/file.c
+++ b/file.c
@@ -2065,7 +2065,7 @@ struct tcb *tcp;
     if (entering(tcp)) {
        printpath(tcp, tcp->u_arg[0]);
        tprintf(", ");
-       printtv32(tcp, tcp->u_arg[1]);
+       printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
     }
     return 0;
 }
diff --git a/time.c b/time.c
index ebd788f36cc31c476761def7ce0c00d7f03c5abf..cbfa5568fa5a200ae3df455a98820d33b5be6ee8 100644 (file)
--- a/time.c
+++ b/time.c
 #include <linux/rtc.h>
 #endif /* LINUX */
 
-void
-printtv(tcp, addr)
-struct tcb *tcp;
-long addr;
+struct timeval32
 {
-       struct timeval tv;
+       u_int32_t tv_sec, tv_usec;
+};
 
+void
+printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
+{
        if (addr == 0)
                tprintf("NULL");
        else if (!verbose(tcp))
                tprintf("%#lx", addr);
-       else if (umove(tcp, addr, &tv) < 0)
-               tprintf("{...}");
        else
-               tprintf("{%lu, %lu}", (long) tv.tv_sec, (long) tv.tv_usec);
-}
+       {
+               int     rc;
 
-#ifdef ALPHA
-struct timeval32
-{
-    unsigned tv_sec;
-    unsigned tv_usec;
-};
+               if (bitness == BITNESS_32
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+                   || personality_wordsize[current_personality] == 4
+#endif
+                       )
+               {
+                       struct timeval32 tv;
+
+                       if ((rc = umove(tcp, addr, &tv)) >= 0)
+                               tprintf("{%u, %u}",
+                                       tv.tv_sec, tv.tv_usec);
+               } else
+               {
+                       struct timeval tv;
+
+                       if ((rc = umove(tcp, addr, &tv)) >= 0)
+                               tprintf("{%lu, %lu}",
+                                       (unsigned long) tv.tv_sec,
+                                       (unsigned long) tv.tv_usec);
+               }
+
+               if (rc < 0)
+                       tprintf("{...}");
+       }
+}
 
 void
-printtv32(tcp, addr)
-struct tcb *tcp;
-long addr;
+sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
 {
-    struct timeval32  tv;
+       if (addr == 0)
+               strcpy(buf, "NULL");
+       else if (!verbose(tcp))
+               sprintf(buf, "%#lx", addr);
+       else
+       {
+               int     rc;
 
-    if (addr == 0)
-       tprintf("NULL");
-    else if (!verbose(tcp))
-       tprintf("%#lx", addr);
-    else if (umove(tcp, addr, &tv) < 0)
-       tprintf("{...}");
-    else
-       tprintf("{%u, %u}", tv.tv_sec, tv.tv_usec);
-}
+               if (bitness == BITNESS_32
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+                   || personality_wordsize[current_personality] == 4
 #endif
+                       )
+               {
+                       struct timeval32 tv;
+
+                       if ((rc = umove(tcp, addr, &tv)) >= 0)
+                               sprintf(buf, "{%u, %u}",
+                                       tv.tv_sec, tv.tv_usec);
+               } else
+               {
+                       struct timeval tv;
+
+                       if ((rc = umove(tcp, addr, &tv)) >= 0)
+                               sprintf(buf, "{%lu, %lu}",
+                                       (unsigned long) tv.tv_sec,
+                                       (unsigned long) tv.tv_usec);
+               }
 
+               if (rc < 0)
+                       strcpy(buf, "{...}");
+       }
+}
 
 int
 sys_time(tcp)
@@ -134,10 +170,10 @@ struct tcb *tcp;
                    tcp->u_arg[0], tcp->u_arg[1]);
            return 0;
        }
-       printtv32(tcp, tcp->u_arg[0]);
+       printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
 #ifndef SVR4
        tprintf(", ");
-       printtv32(tcp, tcp->u_arg[1]);
+       printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
 #endif /* !SVR4 */
     }
     return 0;
@@ -164,10 +200,10 @@ sys_osf_settimeofday(tcp)
 struct tcb *tcp;
 {
     if (entering(tcp)) {
-       printtv32(tcp, tcp->u_arg[0]);
+       printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
 #ifndef SVR4
        tprintf(", ");
-       printtv32(tcp, tcp->u_arg[1]);
+       printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
 #endif /* !SVR4 */
     }
     return 0;