From 1d08dcf46dd4b2cfe3e27723c05b0aec9955c591 Mon Sep 17 00:00:00 2001 From: John Hughes Date: Tue, 10 Jul 2001 13:48:44 +0000 Subject: [PATCH] Merge iov fixes from Richard Kettlewell --- ChangeLog | 7 +++++++ TODO | 1 - defs.h | 2 ++ io.c | 8 ++++++-- net.c | 34 +--------------------------------- strace.c | 2 ++ syscall.c | 13 +++++++++++++ util.c | 35 +++++++++++++++++++++++++++++++++++ 8 files changed, 66 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d24585c6..fb9a604e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-07-10 John Hughes + + * TODO, defs.h, io.h, net.c, strace.c, syscall.c, util.c: Merge fixes + from Richard Kettlewell 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 * config.{guess,sub}: updated diff --git a/TODO b/TODO index 65b882a9..1d6a8e8f 100644 --- 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 41be06bf..07b1a1af 100644 --- 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 d38d1fe3..823f9c37 100644 --- a/io.c +++ b/io.c @@ -33,7 +33,9 @@ #include "defs.h" #include +#if HAVE_SYS_UIO_H #include +#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 e22056b3..2e312f23 100644 --- 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); diff --git a/strace.c b/strace.c index de2d5665..083e850c 100644 --- a/strace.c +++ b/strace.c @@ -51,9 +51,11 @@ #ifdef SVR4 #include #ifdef HAVE_MP_PROCFS +#ifdef HAVE_SYS_UIO_H #include #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 be988dfd..dcd35044 100644 --- 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 52911424..5aedec6f 100644 --- a/util.c +++ b/util.c @@ -38,6 +38,9 @@ #include #include #include +#if HAVE_SYS_UIO_H +#include +#endif #ifdef SUNOS4 #include #include @@ -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;