]> granicus.if.org Git - strace/commitdiff
Fix decoding of file descriptors
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 4 Mar 2011 02:08:02 +0000 (05:08 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 4 Mar 2011 02:08:02 +0000 (02:08 +0000)
* defs.h (printfd): New function prototype.
* util.c (printfd): New function.
* file.c (print_dirfd): Update prototype to use printfd().
(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
sys_fallocate): Use printfd() for decoding of file descriptors.
* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
decoding of file descriptors.
* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
sys_ioctl): Likewise.
* mem.c (print_mmap, sys_mmap64): Likewise.
* signal.c (do_signalfd): Likewise.
* stream.c (decode_poll): Likewise.
* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.

defs.h
desc.c
file.c
io.c
mem.c
signal.c
stream.c
time.c
util.c

diff --git a/defs.h b/defs.h
index bccffbc3e5e5643bf8ccd00c1724b1dce68df49b..7271280ca2046617ac81ab084c676bc45af20281 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -550,6 +550,7 @@ extern void sprint_timespec(char *, struct tcb *, long);
 #ifdef HAVE_SIGINFO_T
 extern void printsiginfo(siginfo_t *, int);
 #endif
+extern void printfd(struct tcb *, int);
 extern void printsock(struct tcb *, long, int);
 extern void print_sock_optmgmt(struct tcb *, long, int);
 extern void printrusage(struct tcb *, long);
diff --git a/desc.c b/desc.c
index 2b9f30a44b82a27c385424a5bbeab069091cf338..790b10bb1e5cbfc1c508dfaf17756e60d0f7c7ac 100644 (file)
--- a/desc.c
+++ b/desc.c
@@ -309,7 +309,8 @@ int
 sys_fcntl(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printxval(fcntlcmds, tcp->u_arg[1], "F_???");
                switch (tcp->u_arg[1]) {
                case F_SETFD:
@@ -422,7 +423,8 @@ int
 sys_flock(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printflags(flockcmds, tcp->u_arg[1], "LOCK_???");
        }
        return 0;
@@ -433,7 +435,7 @@ int
 sys_close(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
        }
        return 0;
 }
@@ -442,7 +444,7 @@ int
 sys_dup(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
        }
        return 0;
 }
@@ -451,7 +453,9 @@ static int
 do_dup2(struct tcb *tcp, int flags_arg)
 {
        if (entering(tcp)) {
-               tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[1]);
                if (flags_arg >= 0) {
                        tprintf(", ");
                        printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???");
@@ -516,7 +520,8 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
                        tprintf(", [");
                        for (j = 0, sep = ""; j < nfds; j++) {
                                if (FD_ISSET(j, fds)) {
-                                       tprintf("%s%u", sep, j);
+                                       tprintf("%s", sep);
+                                       printfd(tcp, j);
                                        sep = " ";
                                }
                        }
@@ -703,9 +708,12 @@ int
 sys_epoll_ctl(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printxval(epollctls, tcp->u_arg[1], "EPOLL_CTL_???");
-               tprintf(", %ld, ", tcp->u_arg[2]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[2]);
+               tprintf(", ");
                if (tcp->u_arg[3] == 0)
                        tprintf("NULL");
                else {
@@ -724,9 +732,10 @@ sys_epoll_ctl(struct tcb *tcp)
 static void
 epoll_wait_common(struct tcb *tcp)
 {
-       if (entering(tcp))
-               tprintf("%ld, ", tcp->u_arg[0]);
-       else {
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+       } else {
                if (syserror(tcp))
                        tprintf("%lx", tcp->u_arg[1]);
                else if (tcp->u_rval == 0)
diff --git a/file.c b/file.c
index a0f53f9ef5bf2f1faae66845b43f4e6863aeda43..346f1e70558d3cbc0f27898ffbdb72f522a404b7 100644 (file)
--- a/file.c
+++ b/file.c
@@ -331,12 +331,15 @@ const struct xlat open_mode_flags[] = {
  * extension to get the right value.  We do this by declaring fd as int here.
  */
 static void
-print_dirfd(int fd)
+print_dirfd(struct tcb *tcp, int fd)
 {
        if (fd == AT_FDCWD)
                tprintf("AT_FDCWD, ");
        else
-               tprintf("%d, ", fd);
+       {
+               printfd(tcp, fd);
+               tprintf(", ");
+       }
 }
 #endif
 
@@ -425,7 +428,7 @@ int
 sys_openat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_open(tcp, 1);
 }
 #endif
@@ -513,7 +516,7 @@ int
 sys_faccessat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_access(tcp, 1);
 }
 #endif
@@ -543,7 +546,8 @@ sys_lseek(struct tcb *tcp)
        int _whence;
 
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                offset = tcp->ext_arg[1];
                _whence = tcp->u_arg[2];
                if (_whence == SEEK_SET)
@@ -562,7 +566,8 @@ sys_lseek(struct tcb *tcp)
        int _whence;
 
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                offset = tcp->u_arg[1];
                _whence = tcp->u_arg[2];
                if (_whence == SEEK_SET)
@@ -581,19 +586,20 @@ int
 sys_llseek(struct tcb *tcp)
 {
        if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
                /*
                 * This one call takes explicitly two 32-bit arguments hi, lo,
                 * rather than one 64-bit argument for which LONG_LONG works
                 * appropriate for the native byte order.
                 */
                if (tcp->u_arg[4] == SEEK_SET)
-                       tprintf("%ld, %llu, ", tcp->u_arg[0],
-                               (((long long int) tcp->u_arg[1]) << 32
-                                | (unsigned long long) (unsigned) tcp->u_arg[2]));
+                       tprintf(", %llu, ",
+                               ((long long int) tcp->u_arg[1]) << 32 |
+                               (unsigned long long) (unsigned) tcp->u_arg[2]);
                else
-                       tprintf("%ld, %lld, ", tcp->u_arg[0],
-                               (((long long int) tcp->u_arg[1]) << 32
-                                | (unsigned long long) (unsigned) tcp->u_arg[2]));
+                       tprintf(", %lld, ",
+                               ((long long int) tcp->u_arg[1]) << 32 |
+                               (unsigned long long) (unsigned) tcp->u_arg[2]);
        }
        else {
                long long int off;
@@ -611,7 +617,8 @@ sys_readahead(struct tcb *tcp)
 {
        if (entering(tcp)) {
                int argn;
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                argn = printllval(tcp, "%lld", 1);
                tprintf(", %ld", tcp->u_arg[argn]);
        }
@@ -625,7 +632,8 @@ sys_lseek64(struct tcb *tcp)
 {
        if (entering(tcp)) {
                int argn;
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                if (tcp->u_arg[3] == SEEK_SET)
                        argn = printllval(tcp, "%llu, ", 1);
                else
@@ -665,7 +673,8 @@ int
 sys_ftruncate(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, %lu", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", %lu", tcp->u_arg[1]);
        }
        return 0;
 }
@@ -676,7 +685,8 @@ int
 sys_ftruncate64(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printllval(tcp, "%llu", 1);
        }
        return 0;
@@ -1327,7 +1337,7 @@ int
 sys_newfstatat(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
                printpath(tcp, tcp->u_arg[1]);
                tprintf(", ");
        } else {
@@ -1366,9 +1376,10 @@ sys_oldstat(struct tcb *tcp)
 int
 sys_fstat(struct tcb *tcp)
 {
-       if (entering(tcp))
-               tprintf("%ld, ", tcp->u_arg[0]);
-       else {
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+       } else {
                printstat(tcp, tcp->u_arg[1]);
        }
        return 0;
@@ -1379,9 +1390,10 @@ int
 sys_fstat64(struct tcb *tcp)
 {
 #ifdef HAVE_STAT64
-       if (entering(tcp))
-               tprintf("%ld, ", tcp->u_arg[0]);
-       else {
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+       } else {
                printstat64(tcp, tcp->u_arg[1]);
        }
        return 0;
@@ -1394,9 +1406,10 @@ sys_fstat64(struct tcb *tcp)
 int
 sys_oldfstat(struct tcb *tcp)
 {
-       if (entering(tcp))
-               tprintf("%ld, ", tcp->u_arg[0]);
-       else {
+       if (entering(tcp)) {
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+       } else {
                printoldstat(tcp, tcp->u_arg[1]);
        }
        return 0;
@@ -1750,7 +1763,8 @@ int
 sys_fstatfs(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%lu, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                printstatfs(tcp, tcp->u_arg[1]);
        }
@@ -1807,7 +1821,8 @@ int
 sys_fstatfs64(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", %lu, ", tcp->u_arg[1]);
        } else {
                if (tcp->u_arg[1] == sizeof (struct statfs64))
                        printstatfs64(tcp, tcp->u_arg[2]);
@@ -1922,7 +1937,7 @@ int
 sys_mkdirat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_mkdir(tcp, 1);
 }
 #endif
@@ -1940,7 +1955,7 @@ int
 sys_fchdir(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
        }
        return 0;
 }
@@ -1959,7 +1974,7 @@ int
 sys_fchroot(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
        }
        return 0;
 }
@@ -1981,12 +1996,13 @@ int
 sys_linkat(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
                printpath(tcp, tcp->u_arg[1]);
                tprintf(", ");
-               print_dirfd(tcp->u_arg[2]);
+               print_dirfd(tcp, tcp->u_arg[2]);
                printpath(tcp, tcp->u_arg[3]);
-               tprintf(", %ld", tcp->u_arg[4]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[4]);
        }
        return 0;
 }
@@ -2014,7 +2030,7 @@ int
 sys_unlinkat(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
                printpath(tcp, tcp->u_arg[1]);
                tprintf(", ");
                printflags(unlinkatflags, tcp->u_arg[2], "AT_???");
@@ -2041,7 +2057,7 @@ sys_symlinkat(struct tcb *tcp)
        if (entering(tcp)) {
                printpath(tcp, tcp->u_arg[0]);
                tprintf(", ");
-               print_dirfd(tcp->u_arg[1]);
+               print_dirfd(tcp, tcp->u_arg[1]);
                printpath(tcp, tcp->u_arg[2]);
        }
        return 0;
@@ -2075,7 +2091,7 @@ int
 sys_readlinkat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_readlink(tcp, 1);
 }
 #endif
@@ -2096,10 +2112,10 @@ int
 sys_renameat(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
                printpath(tcp, tcp->u_arg[1]);
                tprintf(", ");
-               print_dirfd(tcp->u_arg[2]);
+               print_dirfd(tcp, tcp->u_arg[2]);
                printpath(tcp, tcp->u_arg[3]);
        }
        return 0;
@@ -2122,7 +2138,7 @@ int
 sys_fchownat(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
                printpath(tcp, tcp->u_arg[1]);
                printuid(", ", tcp->u_arg[2]);
                printuid(", ", tcp->u_arg[3]);
@@ -2137,7 +2153,7 @@ int
 sys_fchown(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
                printuid(", ", tcp->u_arg[1]);
                printuid(", ", tcp->u_arg[2]);
        }
@@ -2165,7 +2181,7 @@ int
 sys_fchmodat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_chmod(tcp, 1);
 }
 #endif
@@ -2174,7 +2190,8 @@ int
 sys_fchmod(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, %#lo", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", %#lo", tcp->u_arg[1]);
        }
        return 0;
 }
@@ -2225,7 +2242,7 @@ int
 sys_futimesat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_utimes(tcp, 1, 0);
 }
 
@@ -2233,7 +2250,7 @@ int
 sys_utimensat(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
                decode_utimes(tcp, 1, 1);
                tprintf(", ");
                printflags(utimensatflags, tcp->u_arg[3], "AT_???");
@@ -2316,7 +2333,7 @@ int
 sys_mknodat(struct tcb *tcp)
 {
        if (entering(tcp))
-               print_dirfd(tcp->u_arg[0]);
+               print_dirfd(tcp, tcp->u_arg[0]);
        return decode_mknod(tcp, 1);
 }
 #endif
@@ -2337,7 +2354,7 @@ int
 sys_fsync(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
        }
        return 0;
 }
@@ -2367,7 +2384,8 @@ int
 sys_readdir(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%lu, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                if (syserror(tcp) || tcp->u_rval == 0 || !verbose(tcp))
                        tprintf("%#lx", tcp->u_arg[1]);
@@ -2405,7 +2423,8 @@ sys_getdents(struct tcb *tcp)
        char *buf;
 
        if (entering(tcp)) {
-               tprintf("%lu, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                return 0;
        }
        if (syserror(tcp) || !verbose(tcp)) {
@@ -2489,7 +2508,8 @@ sys_getdents64(struct tcb *tcp)
        char *buf;
 
        if (entering(tcp)) {
-               tprintf("%lu, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                return 0;
        }
        if (syserror(tcp) || !verbose(tcp)) {
@@ -2562,7 +2582,8 @@ sys_getdirentries(struct tcb *tcp)
        char *buf;
 
        if (entering(tcp)) {
-               tprintf("%lu, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                return 0;
        }
        if (syserror(tcp) || !verbose(tcp)) {
@@ -2786,7 +2807,8 @@ int
 sys_fsetxattr(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], -1);
                print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]);
                tprintf(", ");
@@ -2813,7 +2835,8 @@ int
 sys_fgetxattr(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], -1);
        } else {
                print_xattr_val(tcp, syserror(tcp), tcp->u_arg[2], tcp->u_arg[3],
@@ -2838,7 +2861,7 @@ int
 sys_flistxattr(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
        } else {
                /* XXX Print value in format */
                tprintf(", %p, %lu", (void *) tcp->u_arg[1], tcp->u_arg[2]);
@@ -2861,7 +2884,8 @@ int
 sys_fremovexattr(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], -1);
        }
        return 0;
@@ -2885,7 +2909,8 @@ sys_fadvise64(struct tcb *tcp)
 {
        if (entering(tcp)) {
                int argn;
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                argn = printllval(tcp, "%lld", 1);
                tprintf(", %ld, ", tcp->u_arg[argn++]);
                printxval(advise, tcp->u_arg[argn], "POSIX_FADV_???");
@@ -2900,7 +2925,8 @@ sys_fadvise64_64(struct tcb *tcp)
 {
        if (entering(tcp)) {
                int argn;
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
 #if defined ARM || defined POWERPC
                argn = printllval(tcp, "%lld, ", 2);
 #else
@@ -2951,7 +2977,8 @@ int
 sys_inotify_add_watch(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printpath(tcp, tcp->u_arg[1]);
                tprintf(", ");
                printflags(inotify_modes, tcp->u_arg[2], "IN_???");
@@ -2963,7 +2990,8 @@ int
 sys_inotify_rm_watch(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, %ld", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", %ld", tcp->u_arg[1]);
        }
        return 0;
 }
@@ -2981,7 +3009,8 @@ sys_fallocate(struct tcb *tcp)
 {
        if (entering(tcp)) {
                int argn;
-               tprintf("%ld, ", tcp->u_arg[0]);        /* fd */
+               printfd(tcp, tcp->u_arg[0]);            /* fd */
+               tprintf(", ");
                tprintf("%#lo, ", tcp->u_arg[1]);       /* mode */
                argn = printllval(tcp, "%llu, ", 2);    /* offset */
                printllval(tcp, "%llu", argn);          /* len */
diff --git a/io.c b/io.c
index 3d2970c157fdffa99d249d780f63d16e6d444c7e..3f8757c25905784782a591fa14bf5c85ca66382f 100644 (file)
--- a/io.c
+++ b/io.c
 #endif
 
 int
-sys_read(tcp)
-struct tcb *tcp;
+sys_read(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                if (syserror(tcp))
                        tprintf("%#lx", tcp->u_arg[1]);
@@ -63,11 +63,11 @@ struct tcb *tcp;
 }
 
 int
-sys_write(tcp)
-struct tcb *tcp;
+sys_write(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
                tprintf(", %lu", tcp->u_arg[2]);
        }
@@ -147,11 +147,11 @@ unsigned long addr;
 }
 
 int
-sys_readv(tcp)
-struct tcb *tcp;
+sys_readv(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                if (syserror(tcp)) {
                        tprintf("%#lx, %lu",
@@ -165,11 +165,11 @@ struct tcb *tcp;
 }
 
 int
-sys_writev(tcp)
-struct tcb *tcp;
+sys_writev(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
                tprintf(", %lu", tcp->u_arg[2]);
        }
@@ -180,11 +180,11 @@ struct tcb *tcp;
 #if defined(SVR4)
 
 int
-sys_pread(tcp)
-struct tcb *tcp;
+sys_pread(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                if (syserror(tcp))
                        tprintf("%#lx", tcp->u_arg[1]);
@@ -202,11 +202,11 @@ struct tcb *tcp;
 }
 
 int
-sys_pwrite(tcp)
-struct tcb *tcp;
+sys_pwrite(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
 #if UNIXWARE
                /* off_t is signed int */
@@ -225,11 +225,13 @@ struct tcb *tcp;
 #include <sys/socket.h>
 
 int
-sys_sendfile(tcp)
-struct tcb *tcp;
+sys_sendfile(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, %ld, %llu, %lu", tcp->u_arg[0], tcp->u_arg[1],
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[1]);
+               tprintf(", %llu, %lu",
                        LONG_LONG(tcp->u_arg[2], tcp->u_arg[3]),
                        tcp->u_arg[4]);
        } else {
@@ -276,11 +278,11 @@ struct tcb *tcp;
 #endif
 
 int
-sys_pread(tcp)
-struct tcb *tcp;
+sys_pread(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                if (syserror(tcp))
                        tprintf("%#lx", tcp->u_arg[1]);
@@ -293,11 +295,11 @@ struct tcb *tcp;
 }
 
 int
-sys_pwrite(tcp)
-struct tcb *tcp;
+sys_pwrite(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
                tprintf(", %lu, ", tcp->u_arg[2]);
                printllval(tcp, "%llu", PREAD_OFFSET_ARG);
@@ -306,13 +308,15 @@ struct tcb *tcp;
 }
 
 int
-sys_sendfile(tcp)
-struct tcb *tcp;
+sys_sendfile(struct tcb *tcp)
 {
        if (entering(tcp)) {
                off_t offset;
 
-               tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[1]);
+               tprintf(", ");
                if (!tcp->u_arg[2])
                        tprintf("NULL");
                else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
@@ -325,13 +329,15 @@ struct tcb *tcp;
 }
 
 int
-sys_sendfile64(tcp)
-struct tcb *tcp;
+sys_sendfile64(struct tcb *tcp)
 {
        if (entering(tcp)) {
                loff_t offset;
 
-               tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[1]);
+               tprintf(", ");
                if (!tcp->u_arg[2])
                        tprintf("NULL");
                else if (umove(tcp, tcp->u_arg[2], &offset) < 0)
@@ -347,11 +353,11 @@ struct tcb *tcp;
 
 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
 int
-sys_pread64(tcp)
-struct tcb *tcp;
+sys_pread64(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
        } else {
                if (syserror(tcp))
                        tprintf("%#lx", tcp->u_arg[1]);
@@ -364,11 +370,11 @@ struct tcb *tcp;
 }
 
 int
-sys_pwrite64(tcp)
-struct tcb *tcp;
+sys_pwrite64(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
                tprintf(", %lu, ", tcp->u_arg[2]);
                printllval(tcp, "%#llx", 3);
@@ -378,13 +384,13 @@ struct tcb *tcp;
 #endif
 
 int
-sys_ioctl(tcp)
-struct tcb *tcp;
+sys_ioctl(struct tcb *tcp)
 {
        const struct ioctlent *iop;
 
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                iop = ioctl_lookup(tcp->u_arg[1]);
                if (iop) {
                        tprintf("%s", iop->symbol);
diff --git a/mem.c b/mem.c
index ec5707a347ac420cef2a9cf755ca5d9973a463e3..d4c223a4cee51fc11a9c1da702e30ba7512be7d7 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -232,12 +232,8 @@ long flags;
 #endif
 
 #if !HAVE_LONG_LONG_OFF_T
-static
-int
-print_mmap(tcp,u_arg, offset)
-struct tcb *tcp;
-long *u_arg;
-long long offset;
+static int
+print_mmap(struct tcb *tcp, long *u_arg, long long offset)
 {
        if (entering(tcp)) {
                /* addr */
@@ -261,10 +257,11 @@ long long offset;
 #else
                printflags(mmap_flags, u_arg[3], "MAP_???");
 #endif
-               /* fd (is always int, not long) */
-               tprintf(", %d, ", (int)u_arg[4]);
+               /* fd */
+               tprintf(", ");
+               printfd(tcp, u_arg[4]);
                /* offset */
-               tprintf("%#llx", offset);
+               tprintf("%#llx", offset);
        }
        return RVAL_HEX;
 }
@@ -341,8 +338,7 @@ struct tcb *tcp;
 
 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
 int
-sys_mmap64(tcp)
-struct tcb *tcp;
+sys_mmap64(struct tcb *tcp)
 {
 #ifdef linux
 #ifdef ALPHA
@@ -378,9 +374,10 @@ struct tcb *tcp;
                printflags(mmap_flags, u_arg[3], "MAP_???");
 #endif
                /* fd */
-               tprintf(", %ld, ", u_arg[4]);
+               tprintf(", ");
+               printfd(tcp, tcp->u_arg[4]);
                /* offset */
-               printllval(tcp, "%#llx", 5);
+               printllval(tcp, "%#llx", 5);
        }
        return RVAL_HEX;
 }
index eb658d7923ef2a97c1af9b1f8c01a71635863fad..06864d1beb95b5869ad8302db51b3c43abc8730a 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -2132,7 +2132,8 @@ static int
 do_signalfd(struct tcb *tcp, int flags_arg)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                print_sigset(tcp, tcp->u_arg[1], 1);
                tprintf(", %lu", tcp->u_arg[2]);
                if (flags_arg >= 0) {
index e5868c98499b23842273b0539db1be4daac73ea3..eb4e3964b924bd9ae7da2658207f381d9b5588d3 100644 (file)
--- a/stream.c
+++ b/stream.c
@@ -338,7 +338,9 @@ decode_poll(struct tcb *tcp, long pts)
                                tprintf("{fd=%d}", fds.fd);
                                continue;
                        }
-                       tprintf("{fd=%d, events=", fds.fd);
+                       tprintf("{fd=");
+                       printfd(tcp, fds.fd);
+                       tprintf(", events=");
                        printflags(pollflags, fds.events, "POLL???");
                        tprintf("}");
                }
diff --git a/time.c b/time.c
index 0c6deaf1c7053a2077232f1681aff6c9680aff27..b5fdc5233c4f773c56117b6e242b122f2caccb07 100644 (file)
--- a/time.c
+++ b/time.c
@@ -1013,7 +1013,8 @@ int
 sys_timerfd_settime(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
+               tprintf(", ");
                printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
                tprintf(", ");
                printitv(tcp, tcp->u_arg[2]);
@@ -1027,7 +1028,7 @@ int
 sys_timerfd_gettime(struct tcb *tcp)
 {
        if (entering(tcp)) {
-               tprintf("%ld, ", tcp->u_arg[0]);
+               printfd(tcp, tcp->u_arg[0]);
                tprintf(", ");
                printitv(tcp, tcp->u_arg[1]);
        }
diff --git a/util.c b/util.c
index c28edf3be538de233a2c21b5c2268f7bb09987fa..711e61441d421f7013c58b71cb4951469b57a658 100644 (file)
--- a/util.c
+++ b/util.c
@@ -415,6 +415,12 @@ printnum_int(struct tcb *tcp, long addr, const char *fmt)
        tprintf("]");
 }
 
+void
+printfd(struct tcb *tcp, int fd)
+{
+       tprintf("%d", fd);
+}
+
 void
 printuid(text, uid)
 const char *text;