]> granicus.if.org Git - strace/commitdiff
Enhance recvmmsg parser
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 29 Mar 2010 16:45:48 +0000 (20:45 +0400)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 7 Apr 2010 10:19:27 +0000 (10:19 +0000)
* net.c (sys_recvmmsg): Decode mmsghdr structure on exit from the
syscall.  Decode timespec structure both on entrance and on exit.

net.c

diff --git a/net.c b/net.c
index ded21a36e865c7f795b980e42bfa14a206ac28d8..f56664e13c8ec25ed9bbbd1c8feba08939c5e720 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1532,17 +1532,48 @@ struct tcb *tcp;
 int
 sys_recvmmsg(struct tcb *tcp)
 {
+       static char str[128];
        if (entering(tcp)) {
+
                tprintf("%ld, ", tcp->u_arg[0]);
-               printmmsghdr(tcp, tcp->u_arg[1]);
-               tprintf(", %ld, ", tcp->u_arg[2]);
-               /* flags */
-               printflags(msg_flags, tcp->u_arg[3], "MSG_???");
-               /* timeout */
-               tprintf(", ");
-               print_timespec(tcp, tcp->u_arg[4]);
+               if (verbose(tcp)) {
+                       sprint_timespec(str, tcp, tcp->u_arg[4]);
+                       tcp->auxstr = strdup(str);
+               } else {
+                       tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
+                       printflags(msg_flags, tcp->u_arg[3], "MSG_???");
+                       tprintf(", ");
+                       print_timespec(tcp, tcp->u_arg[4]);
+               }
+               return 0;
+       } else {
+               if (verbose(tcp)) {
+                       if (syserror(tcp))
+                               tprintf("%#lx", tcp->u_arg[1]);
+                       else
+                               printmmsghdr(tcp, tcp->u_arg[1]);
+                       tprintf(", %ld, ", tcp->u_arg[2]);
+                       /* flags */
+                       printflags(msg_flags, tcp->u_arg[3], "MSG_???");
+                       /* timeout on entrance */
+                       tprintf(", %s", tcp->auxstr ? tcp->auxstr : "{...}");
+                       free((void *) tcp->auxstr);
+                       tcp->auxstr = NULL;
+               }
+               if (syserror(tcp))
+                       return 0;
+               if (tcp->u_rval == 0) {
+                       tcp->auxstr = "Timeout";
+                       return RVAL_STR;
+               }
+               if (!verbose(tcp))
+                       return 0;
+               /* timeout on exit */
+               strcpy(str, "left ");
+               sprint_timespec(str + strlen(str), tcp, tcp->u_arg[4]);
+               tcp->auxstr = str;
+               return RVAL_STR;
        }
-       return 0;
 }
 #endif