]> granicus.if.org Git - strace/commitdiff
Merge iov fixes from Richard Kettlewell
authorJohn Hughes <john@Calva.COM>
Tue, 10 Jul 2001 13:48:44 +0000 (13:48 +0000)
committerJohn Hughes <john@Calva.COM>
Tue, 10 Jul 2001 13:48:44 +0000 (13:48 +0000)
ChangeLog
TODO
defs.h
io.c
net.c
strace.c
syscall.c
util.c

index d24585c6303168dc4d24d5eff1f36d48691f2f0a..fb9a604e90f4ac353295a0bc349eef42b3ab592d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-07-10  John Hughes <john@Calva.COM>
+
+  * TODO, defs.h, io.h, net.c, strace.c, syscall.c, util.c: Merge fixes
+    from Richard Kettlewell <rkettlewell@zeus.com> which add I/O dumping
+    of args to readv/writev.  Also gets rid of redundant printiovec
+    routine from net.c (duplicate of tprint_iov in util.c).
+
 2001-07-02  Wichert Akkerman <wakkerma@debian.org>
 
   * config.{guess,sub}: updated
diff --git a/TODO b/TODO
index 65b882a9905fe1a2df41965acf3e237ca95a3f51..1d6a8e8fdf0998b75333f17cb8d6069143555a16 100644 (file)
--- a/TODO
+++ b/TODO
@@ -18,7 +18,6 @@ I don't like run on last close, change it?
 parse long options?
 count signals too with -c
 treat attach, detach messages like signals
-add readv, writev to I/O dumping
 add pread, pwrite to I/O dumping
 add system assist for qualifiers on svr4
 change printcall to getcaller and fix for linux and svr4
diff --git a/defs.h b/defs.h
index 41be06bf3b8a8e4b7feb57faf88fbcf516bfd8a3..07b1a1af8a7c4addc1520960e784d78259ddda07 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -376,6 +376,7 @@ extern int printflags P((struct xlat *, int));
 extern int umoven P((struct tcb *, long, int, char *));
 extern int umovestr P((struct tcb *, long, int, char *));
 extern int upeek P((int, long, long *));
+extern void dumpiov P((struct tcb *, int, long));
 extern void dumpstr P((struct tcb *, long, int));
 extern void string_quote P((char *str));
 extern void printstr P((struct tcb *, long, int));
@@ -397,6 +398,7 @@ extern void tabto P((int));
 extern void call_summary P((FILE *));
 extern void fake_execve P((struct tcb *, char *, char *[], char *[]));
 extern void printtv32 P((struct tcb*, long));
+extern void tprint_iov P((struct tcb *, int, long));
 
 #ifdef LINUX
 extern int internal_clone P((struct tcb *));
diff --git a/io.c b/io.c
index d38d1fe3fb5f62eeadc5e6bdac052adf65dbea80..823f9c3705c349f6e404e7f913d75827355c730e 100644 (file)
--- a/io.c
+++ b/io.c
@@ -33,7 +33,9 @@
 #include "defs.h"
 
 #include <fcntl.h>
+#if HAVE_SYS_UIO_H
 #include <sys/uio.h>
+#endif
 
 #ifdef HAVE_LONG_LONG_OFF_T
 /*
@@ -72,11 +74,12 @@ struct tcb *tcp;
        return 0;
 }
 
+#if HAVE_SYS_UIO_H
 void
 tprint_iov(tcp, len, addr)
 struct tcb * tcp;
 int len;
-char * addr;
+long addr;
 {
        struct iovec *iov;
        int i;
@@ -91,7 +94,7 @@ char * addr;
                fprintf(stderr, "No memory");
                return;
        }
-       if (umoven(tcp, (int) addr,
+       if (umoven(tcp, addr,
                   len * sizeof *iov, (char *) iov) < 0) {
                tprintf("%#lx", tcp->u_arg[1]);
        } else {
@@ -138,6 +141,7 @@ struct tcb *tcp;
        }
        return 0;
 }
+#endif
 
 #if defined(SVR4)
 
diff --git a/net.c b/net.c
index e22056b35bcd050cec4529203d6246d174df265f..2e312f23a03d7197fb6a3e2a17bf84f5c2e2a991 100644 (file)
--- a/net.c
+++ b/net.c
@@ -713,38 +713,6 @@ int addrlen;
 
 #if HAVE_SENDMSG
 
-static void
-printiovec(tcp, iovec, len)
-struct tcb *tcp;
-struct iovec *iovec;
-long   len;
-{
-       struct iovec *iov;
-       int i;
-
-       iov = (struct iovec *) malloc(len * sizeof *iov);
-       if (iov == NULL) {
-               fprintf(stderr, "No memory");
-               return;
-       }
-       if (umoven(tcp, (long)iovec,
-                               len * sizeof *iov, (char *) iov) < 0) {
-               tprintf("%#lx", (unsigned long)iovec);
-       } else {
-               tprintf("[");
-               for (i = 0; i < len; i++) {
-                       if (i)
-                               tprintf(", ");
-                       tprintf("{");
-                       printstr(tcp, (long) iov[i].iov_base,
-                                       iov[i].iov_len);
-                       tprintf(", %lu}", (unsigned long)iov[i].iov_len);
-               }
-               tprintf("]");
-       }
-       free((char *) iov);
-}
-
 static void
 printmsghdr(tcp, addr)
 struct tcb *tcp;
@@ -760,7 +728,7 @@ long addr;
        printsock(tcp, (long)msg.msg_name, msg.msg_namelen);
 
        tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
-       printiovec(tcp, msg.msg_iov, msg.msg_iovlen);
+       tprint_iov(tcp, msg.msg_iovlen, (long) msg.msg_iov);
 
 #ifdef HAVE_MSG_CONTROL
        tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
index de2d56659a5bee4db15e6ffb764c6cfefc89dd27..083e850c3cdd9a219b66c3ca400340ab391c1162 100644 (file)
--- a/strace.c
+++ b/strace.c
 #ifdef SVR4
 #include <sys/stropts.h>
 #ifdef HAVE_MP_PROCFS
+#ifdef HAVE_SYS_UIO_H
 #include <sys/uio.h>
 #endif
 #endif
+#endif
 
 int debug = 0, followfork = 0, followvfork = 0, interactive = 0;
 int rflag = 0, tflag = 0, dtime = 0, cflag = 0;
index be988dfd25811bfb96eabc039fb69fd4abc5cb1d..dcd3504448c5f321003b2cf573e2a2399ea39e48 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -417,6 +417,19 @@ struct tcb *tcp;
                if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE)
                        dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
                break;
+#ifdef SYS_readv
+        case SYS_readv:
+                if (qual_flags[tcp->u_arg[0]] & QUAL_READ)
+                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+                break;
+#endif
+#ifdef SYS_writev
+        case SYS_writev:
+
+                if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE)
+                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+                break;
+#endif
        }
 }
 
diff --git a/util.c b/util.c
index 529114241e5ca09a2c06cda4ad946b26b0ea9e39..5aedec6fe510ca3629ff404473859ddd6e65553c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -38,6 +38,9 @@
 #include <sys/user.h>
 #include <sys/param.h>
 #include <fcntl.h>
+#if HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
 #ifdef SUNOS4
 #include <machine/reg.h>
 #include <a.out.h>
@@ -464,6 +467,38 @@ int len;
        tprintf("%s", outstr);
 }
 
+#if HAVE_SYS_UIO_H
+void
+dumpiov(tcp, len, addr)
+struct tcb * tcp;
+int len;
+long addr;
+{
+       struct iovec *iov;
+       int i;
+
+         
+       if ((iov = (struct iovec *) malloc(len * sizeof *iov)) == NULL) {
+               fprintf(stderr, "dump: No memory");
+               return;
+       }
+       if (umoven(tcp, addr,
+                  len * sizeof *iov, (char *) iov) >= 0) {
+                
+               for (i = 0; i < len; i++) {
+                        /* include the buffer number to make it easy to
+                         * match up the trace with the source */
+                        tprintf(" * %lu bytes in buffer %d\n",
+                                (unsigned long)iov[i].iov_len, i);
+                        dumpstr(tcp, (long) iov[i].iov_base,
+                                iov[i].iov_len);
+                }
+       }
+       free((char *) iov);
+        
+}
+#endif
+
 void
 dumpstr(tcp, addr, len)
 struct tcb *tcp;