]> granicus.if.org Git - strace/commitdiff
* file.c (print_dirfd): Use int for file descriptor, not a long.
authorDenys Vlasenko <dvlasenk@redhat.com>
Thu, 16 Apr 2009 12:06:16 +0000 (12:06 +0000)
committerDenys Vlasenko <dvlasenk@redhat.com>
Thu, 16 Apr 2009 12:06:16 +0000 (12:06 +0000)
* process.c (printwaitn): Use int for PID, not a long.

ChangeLog
file.c
process.c

index 6ae08a349f286774c353be4acd49fd7fe2d8d97c..0db8a6309fc2f1a2f2d99bbf54e9994588f95358 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-16  Denys Vlasenko  <dvlasenk@redhat.com>
+
+       * file.c (print_dirfd): Use int for file descriptor, not a long.
+       * process.c (printwaitn): Use int for PID, not a long.
+
 2009-04-15  Denys Vlasenko  <dvlasenk@redhat.com>
 
        * signal (sys_rt_sigtimedwait): Fix sigtimedwait syscall decoding.
@@ -86,7 +91,7 @@
        In some cases, missing error checking is added.
        Error handling for trace_syscall() failures and other cases
        where tcp->ptrace_errno is nonzero is cleaned up a bit
-       and made more verbose if we see error other than ESRC.
+       and made more verbose if we see error other than ESRCH.
        Some comments are added or expanded.
        * defs.h: Declare ptrace_cmds[]. Modify do_ptrace
        declaration (last parameter is long, not void *).
diff --git a/file.c b/file.c
index a8401cfa4bbd9cec4ca5d21b7e159373bafba6d7..080e10b0c45dc4f452e1d358b8e3789a2d0836f9 100644 (file)
--- a/file.c
+++ b/file.c
@@ -327,13 +327,16 @@ const struct xlat open_mode_flags[] = {
 # define AT_FDCWD                -100
 #endif
 
+/* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
+ * extension to get the right value.  We do this by declaring fd as int here.
+ */
 static void
-print_dirfd(long fd)
+print_dirfd(int fd)
 {
        if (fd == AT_FDCWD)
                tprintf("AT_FDCWD, ");
        else
-               tprintf("%ld, ", fd);
+               tprintf("%d, ", fd);
 }
 #endif
 
index 9ddae086069d84d030b6da3d48661d51aa4fe3e0..1ddf2f3218295c0e7a4c9adb740f554a92f61566 100644 (file)
--- a/process.c
+++ b/process.c
@@ -1998,21 +1998,24 @@ printwaitn(struct tcb *tcp, int n, int bitness)
        int exited = 0;
 
        if (entering(tcp)) {
-               /*
-                * Sign-extend a 32-bit value when that's what it is.
-                *
-                * NB: On Linux, kernel-side pid_t is typedef'ed to int
-                * on all arches; also, glibc-2.8 truncates wait3 and wait4
+#ifdef LINUX
+               /* On Linux, kernel-side pid_t is typedef'ed to int
+                * on all arches. Also, glibc-2.8 truncates wait3 and wait4
                 * pid argument to int on 64bit arches, producing,
                 * for example, wait4(4294967295, ...) instead of -1
-                * in strace.
-                * Therefore, maybe it makes sense to *unconditionally*
-                * widen int to long here...
+                * in strace. We have to use int here, not long.
+                */
+               int pid = tcp->u_arg[0];
+               tprintf("%d, ", pid);
+#else
+               /*
+                * Sign-extend a 32-bit value when that's what it is.
                 */
                long pid = tcp->u_arg[0];
                if (personality_wordsize[current_personality] < sizeof pid)
                        pid = (long) (int) pid;
                tprintf("%ld, ", pid);
+#endif
        } else {
                /* status */
                if (!tcp->u_arg[1])