readv/writev io dumping support

Richard Kettlewell rkettlewell at zeus.com
Wed Jul 4 16:35:52 UTC 2001


Only tested on Linux 2.2.19.

ttfn/rjk

diff -ruN strace-4.3.orig/syscall.c strace-4.3/syscall.c
--- strace-4.3.orig/syscall.c	Wed Mar 28 21:29:17 2001
+++ strace-4.3/syscall.c	Wed Jul  4 17:17:56 2001
@@ -417,6 +417,18 @@
 		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:
+#endif
+                if (qual_flags[tcp->u_arg[0]] & QUAL_READ)
+                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+                break;
+#ifdef SYS_writev
+        case SYS_writev:
+#endif
+                if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE)
+                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+                break;
 	}
 }
 
diff -ruN strace-4.3.orig/util.c strace-4.3/util.c
--- strace-4.3.orig/util.c	Tue Mar 27 13:17:17 2001
+++ strace-4.3/util.c	Wed Jul  4 17:30:24 2001
@@ -38,6 +38,7 @@
 #include <sys/user.h>
 #include <sys/param.h>
 #include <fcntl.h>
+#include <sys/uio.h>
 #ifdef SUNOS4
 #include <machine/reg.h>
 #include <a.out.h>
@@ -462,6 +463,36 @@
 	}
 	*s = '\0';
 	tprintf("%s", outstr);
+}
+
+void
+dumpiov(tcp, len, addr)
+struct tcb * tcp;
+int len;
+char * addr;
+{
+	struct iovec *iov;
+	int i;
+
+	  
+	if ((iov = (struct iovec *) malloc(len * sizeof *iov)) == NULL) {
+		fprintf(stderr, "dump: No memory");
+		return;
+	}
+	if (umoven(tcp, (int) 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);
+        
 }
 
 void
diff -ruN strace-4.3.orig/defs.h strace-4.3/defs.h
--- strace-4.3.orig/defs.h	Wed Mar 28 09:05:27 2001
+++ strace-4.3/defs.h	Wed Jul  4 17:21:11 2001
@@ -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, char *));
 extern void dumpstr P((struct tcb *, long, int));
 extern void string_quote P((char *str));
 extern void printstr P((struct tcb *, long, int));
diff -ruN strace-4.3.orig/TODO strace-4.3/TODO
--- strace-4.3.orig/TODO	Mon May  1 02:53:59 2000
+++ strace-4.3/TODO	Wed Jul  4 17:29:19 2001
@@ -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




More information about the Strace-devel mailing list