strace: Fix issues with a few syscalls
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 27 Jul 2018 19:52:37 +0000 (15:52 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Jul 2018 20:05:46 +0000 (16:05 -0400)
SYS_getcwd wasn't part of the file set.  We were tracing the wrong
arguments for SYS_chdir and SYS_rmdir.  SYS_readlink had an unnecessary
check on retval.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/syscall.c
tests/strace.c

index d02a94a..0641d5e 100644 (file)
@@ -344,8 +344,6 @@ static void systrace_start_trace(struct kthread *kthread, struct syscall *sysc)
                copy_tracedata_from_user(trace, sysc->arg1, sysc->arg2);
                break;
        case SYS_openat:
-       case SYS_chdir:
-       case SYS_rmdir:
        case SYS_nmount:
                copy_tracedata_from_user(trace, sysc->arg1, sysc->arg2);
                break;
@@ -353,7 +351,9 @@ static void systrace_start_trace(struct kthread *kthread, struct syscall *sysc)
        case SYS_lstat:
        case SYS_access:
        case SYS_unlink:
+       case SYS_chdir:
        case SYS_mkdir:
+       case SYS_rmdir:
        case SYS_wstat:
                copy_tracedata_from_user(trace, sysc->arg0, sysc->arg1);
                break;
@@ -441,9 +441,7 @@ static void systrace_finish_trace(struct kthread *kthread, long retval)
                                break;
                        copy_tracedata_from_user(trace, trace->arg0, trace->arg1);
                        snprintf_to_trace(trace, " -> ");
-                       copy_tracedata_from_user(trace, trace->arg2,
-                                                (int)trace->retval < 0 ? 0
-                                                                                               : trace->retval);
+                       copy_tracedata_from_user(trace, trace->arg2, retval);
                        break;
                }
        }
index f9aa624..40a56e7 100644 (file)
@@ -84,6 +84,7 @@ static struct trace_set path_trace_set = { "path",
         SYS_symlink,
         SYS_readlink,
         SYS_chdir,
+        SYS_getcwd,
         SYS_mkdir,
         SYS_rmdir,
         SYS_nbind,
@@ -132,6 +133,7 @@ static struct trace_set file_trace_set = { "file",
         SYS_symlink,
         SYS_readlink,
         SYS_chdir,
+        SYS_getcwd,
         SYS_mkdir,
         SYS_rmdir,
         SYS_nbind,