2008-04-19  Dmitry V. Levin <[EMAIL PROTECTED]>

        * desc.c (sys_fcntl): Do not initialize auxstr for failed syscall.
        * process.c (sys_fork, sys_rfork) [USE_PROCFS]: Likewise.
        * signal.c (sys_signal): Likewise.
        * stream.c (internal_stream_ioctl): Likewise.
        * time.c (sys_adjtimex): Likewise.
        * syscall.c (trace_syscall): If RVAL_STR is set, then
        print auxstr for failed syscall as well.
---
 strace/desc.c    |    4 +++-
 strace/process.c |    4 ++--
 strace/signal.c  |    3 ++-
 strace/stream.c  |    2 +-
 strace/syscall.c |    2 ++
 strace/time.c    |    2 ++
 6 files changed, 12 insertions(+), 5 deletions(-)

--- a/strace/desc.c
+++ b/strace/desc.c
@@ -332,12 +332,14 @@ sys_fcntl(struct tcb *tcp)
                case F_SETOWN: case F_GETOWN:
                        break;
                case F_GETFD:
-                       if (tcp->u_rval == 0)
+                       if (syserror(tcp) || tcp->u_rval == 0)
                                return 0;
                        tcp->auxstr =
                                sprintflags("flags ", fdflags, tcp->u_rval);
                        return RVAL_HEX|RVAL_STR;
                case F_GETFL:
+                       if (syserror(tcp))
+                               return 0;
                        tcp->auxstr = sprint_open_modes(tcp->u_rval);
                        return RVAL_HEX|RVAL_STR;
                case F_GETLK:
--- a/strace/process.c
+++ b/strace/process.c
@@ -466,7 +466,7 @@ int
 sys_fork(tcp)
 struct tcb *tcp;
 {
-       if (exiting(tcp)) {
+       if (exiting(tcp) && !syserror(tcp)) {
                if (getrval2(tcp)) {
                        tcp->auxstr = "child process";
                        return RVAL_UDECIMAL | RVAL_STR;
@@ -484,7 +484,7 @@ struct tcb *tcp;
        if (entering(tcp)) {
                tprintf ("%ld", tcp->u_arg[0]);
        }
-       else {
+       else if (!syserror(tcp)) {
                if (getrval2(tcp)) {
                        tcp->auxstr = "child process";
                        return RVAL_UDECIMAL | RVAL_STR;
--- a/strace/signal.c
+++ b/strace/signal.c
@@ -1202,7 +1202,7 @@ struct tcb *tcp;
                }
                return 0;
        }
-       else {
+       else if (!syserror(tcp)) {
                switch (tcp->u_rval) {
                    case (int) SIG_ERR:
                        tcp->auxstr = "SIG_ERR"; break;
@@ -1215,6 +1215,7 @@ struct tcb *tcp;
                }
                return RVAL_HEX | RVAL_STR;
        }
+       return 0;
 }
 
 #ifdef SVR4
--- a/strace/stream.c
+++ b/strace/stream.c
@@ -1177,7 +1177,7 @@ int arg;
        }
        if (exiting(tcp)) {
                tprintf("}");
-               if (timod && tcp->u_rval) {
+               if (timod && tcp->u_rval && !syserror(tcp)) {
                        tcp->auxstr = xlookup (tli_errors, tcp->u_rval);
                        return RVAL_STR + 1;
                }
--- a/strace/syscall.c
+++ b/strace/syscall.c
@@ -2368,6 +2368,8 @@ trace_syscall(struct tcb *tcp)
                                                strerror(u_error));
                                break;
                        }
+                       if ((sys_res & RVAL_STR) && tcp->auxstr)
+                               tprintf(" (%s)", tcp->auxstr);
                }
                else {
                        if (sys_res & RVAL_NONE)
--- a/strace/time.c
+++ b/strace/time.c
@@ -674,6 +674,8 @@ sys_adjtimex(struct tcb *tcp)
                        tprintf("%#lx", tcp->u_arg[0]);
                else if (tprint_timex(tcp, tcp->u_arg[0]) < 0)
                        tprintf("{...}");
+               if (syserror(tcp))
+                       return 0;
                tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
                if (tcp->auxstr)
                        return RVAL_STR;

-- 
ldv

Attachment: pgpMVycsWlS3E.pgp
Description: PGP signature

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to