Package: strace
Version: 4.5.15-1
Severity: normal
Tags: patch

-e write=fd doesn't dump data after error return

When you provide the commandline option "-e write=fd", strace still
doesn't dump the full write data in the case where the write system call
returns an error.

Of course, the write that fails is sometimes exactly the one I wanted to
see....

So, reorganize the cases in dumpio() so that all the write-like cases
(where the io is input to the system call) are before all the read-like
cases, and only exit early in the second case.

(You could even wonder whether it makes sense to skip dumping in the
read case.  I tend to suspect the likelihood of there being interesting
data in the read buffer is small in that case, and that it's likely to
confuse the reader into thinking that the dumped data was actually
returned from the read.)

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.19 (PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.utf8)
Shell: /bin/sh linked to /bin/bash

Versions of packages strace depends on:
ii  libc6                         2.6-5      GNU C Library: Shared libraries

strace recommends no packages.

-- no debconf information

diff --git a/syscall.c b/syscall.c
index 06b10e8..781ead0 100644
--- a/syscall.c
+++ b/syscall.c
@@ -505,31 +505,10 @@ static void
 dumpio(tcp)
 struct tcb *tcp;
 {
-       if (syserror(tcp))
-               return;
        if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= MAX_QUALS)
                return;
+
        switch (known_scno(tcp)) {
-       case SYS_read:
-#ifdef SYS_pread64
-       case SYS_pread64:
-#endif
-#if defined SYS_pread && SYS_pread64 != SYS_pread
-       case SYS_pread:
-#endif
-#ifdef SYS_recv
-       case SYS_recv:
-#elif defined SYS_sub_recv
-       case SYS_sub_recv:
-#endif
-#ifdef SYS_recvfrom
-       case SYS_recvfrom:
-#elif defined SYS_sub_recvfrom
-       case SYS_sub_recvfrom:
-#endif
-               if (qual_flags[tcp->u_arg[0]] & QUAL_READ)
-                       dumpstr(tcp, tcp->u_arg[1], tcp->u_rval);
-               break;
        case SYS_write:
 #ifdef SYS_pwrite64
        case SYS_pwrite64:
@@ -550,12 +529,6 @@ 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:
 
@@ -564,6 +537,39 @@ struct tcb *tcp;
                 break;
 #endif
        }
+
+       /* Don't bother dumping output if the sycall returned an error */
+       if (syserror(tcp))
+               return;
+
+       switch (known_scno(tcp)) {
+       case SYS_read:
+#ifdef SYS_pread64
+       case SYS_pread64:
+#endif
+#if defined SYS_pread && SYS_pread64 != SYS_pread
+       case SYS_pread:
+#endif
+#ifdef SYS_recv
+       case SYS_recv:
+#elif defined SYS_sub_recv
+       case SYS_sub_recv:
+#endif
+#ifdef SYS_recvfrom
+       case SYS_recvfrom:
+#elif defined SYS_sub_recvfrom
+       case SYS_sub_recvfrom:
+#endif
+               if (qual_flags[tcp->u_arg[0]] & QUAL_READ)
+                       dumpstr(tcp, tcp->u_arg[1], tcp->u_rval);
+               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
+       }
 }
 
 #ifndef FREEBSD


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to