Merge iov fixes from Richard Kettlewell
diff --git a/ChangeLog b/ChangeLog
index d24585c..fb9a604 100644
--- 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 65b882a..1d6a8e8 100644
--- a/TODO
+++ b/TODO
@@ -18,7 +18,6 @@
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 41be06b..07b1a1a 100644
--- a/defs.h
+++ b/defs.h
@@ -376,6 +376,7 @@
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 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 d38d1fe..823f9c3 100644
--- 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 @@
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 @@
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 @@
}
return 0;
}
+#endif
#if defined(SVR4)
diff --git a/net.c b/net.c
index e22056b..2e312f2 100644
--- a/net.c
+++ b/net.c
@@ -714,38 +714,6 @@
#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;
long addr;
@@ -760,7 +728,7 @@
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);
diff --git a/strace.c b/strace.c
index de2d566..083e850 100644
--- a/strace.c
+++ b/strace.c
@@ -51,9 +51,11 @@
#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;
diff --git a/syscall.c b/syscall.c
index be988df..dcd3504 100644
--- a/syscall.c
+++ b/syscall.c
@@ -417,6 +417,19 @@
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 5291142..5aedec6 100644
--- 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 @@
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;