]> granicus.if.org Git - strace/commitdiff
pipe, pipe2, socketpair: print returned descriptors using printfd
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 2 Aug 2015 01:54:48 +0000 (01:54 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Aug 2015 09:09:26 +0000 (09:09 +0000)
* net.c (printpair_fd, decode_pair_fd): New functions.
(do_pipe, sys_socketpair): Use them.

net.c

diff --git a/net.c b/net.c
index 6b6f0424ddb8c49df2bd0bd2c798a8f78d6b9e98..7e735288b16e9e86198edb5d3f74a0953e8c80e7 100644 (file)
--- a/net.c
+++ b/net.c
@@ -920,6 +920,27 @@ SYS_FUNC(getsockname)
        return do_sockname(tcp, -1);
 }
 
+static void
+printpair_fd(struct tcb *tcp, const int i0, const int i1)
+{
+       tprints("[");
+       printfd(tcp, i0);
+       tprints(", ");
+       printfd(tcp, i1);
+       tprints("]");
+}
+
+static void
+decode_pair_fd(struct tcb *tcp, const long addr)
+{
+       int pair[2];
+
+       if (umove_or_printaddr(tcp, addr, &pair))
+               return;
+
+       printpair_fd(tcp, pair[0], pair[1]);
+}
+
 static int
 do_pipe(struct tcb *tcp, int flags_arg)
 {
@@ -928,11 +949,11 @@ do_pipe(struct tcb *tcp, int flags_arg)
                        printaddr(tcp->u_arg[0]);
                } else {
 #ifdef HAVE_GETRVAL2
-                       if (flags_arg < 0)
-                               tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp));
-                       else
+                       if (flags_arg < 0) {
+                               printpair_fd(tcp, tcp->u_rval, getrval2(tcp));
+                       else
 #endif
-                               printpair_int(tcp, tcp->u_arg[0], "%u");
+                               decode_pair_fd(tcp, tcp->u_arg[0]);
                }
                if (flags_arg >= 0) {
                        tprints(", ");
@@ -961,7 +982,7 @@ SYS_FUNC(socketpair)
                tprintf(", %lu", tcp->u_arg[2]);
        } else {
                tprints(", ");
-               printpair_int(tcp, tcp->u_arg[3], "%u");
+               decode_pair_fd(tcp, tcp->u_arg[3]);
        }
        return 0;
 }