]> granicus.if.org Git - strace/blobdiff - io.c
struct tcb: make types of syscall arguments unsigned
[strace] / io.c
diff --git a/io.c b/io.c
index da8b9d25fe8c83cfeb763b87b447afb897b70785..3d2425b9ff2ec692c6716a6daf160d97c5b1315c 100644 (file)
--- a/io.c
+++ b/io.c
@@ -77,7 +77,7 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
                iov = elem_buf;
        }
 
-       tprints("{");
+       tprints("{iov_base=");
 
        len = iov[1];
 
@@ -85,15 +85,23 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
                case IOV_DECODE_STR:
                        if (len > c->data_size)
                                len = c->data_size;
-                       c->data_size -= len;
+                       if (c->data_size != -1UL)
+                               c->data_size -= len;
                        printstr(tcp, iov[0], len);
                        break;
+               case IOV_DECODE_NETLINK:
+                       if (len > c->data_size)
+                               len = c->data_size;
+                       if (c->data_size != -1UL)
+                               c->data_size -= len;
+                       decode_netlink(tcp, iov[0], iov[1]);
+                       break;
                default:
                        printaddr(iov[0]);
                        break;
        }
 
-       tprintf(", %lu}", iov[1]);
+       tprintf(", iov_len=%lu}", iov[1]);
 
        return true;
 }
@@ -111,14 +119,14 @@ tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr,
                { .decode_iov = decode_iov, .data_size = data_size };
 
        print_array(tcp, addr, len, iov, current_wordsize * 2,
-                   umoven_or_printaddr, print_iovec, &config);
+                   umoven_or_printaddr_ignore_syserror, print_iovec, &config);
 }
 
 void
 tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr,
           enum iov_decode decode_iov)
 {
-       tprint_iov_upto(tcp, len, addr, decode_iov, (unsigned long) -1L);
+       tprint_iov_upto(tcp, len, addr, decode_iov, -1UL);
 }
 
 SYS_FUNC(readv)
@@ -128,6 +136,7 @@ SYS_FUNC(readv)
                tprints(", ");
        } else {
                tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1],
+                               syserror(tcp) ? IOV_DECODE_ADDR :
                                IOV_DECODE_STR, tcp->u_rval);
                tprintf(", %lu", tcp->u_arg[2]);
        }
@@ -144,17 +153,6 @@ SYS_FUNC(writev)
        return RVAL_DECODED;
 }
 
-/* The SH4 ABI does allow long longs in odd-numbered registers, but
-   does not allow them to be split between registers and memory - and
-   there are only four argument registers for normal functions.  As a
-   result pread takes an extra padding argument before the offset.  This
-   was changed late in the 2.4 series (around 2.4.20).  */
-#if defined(SH)
-#define PREAD_OFFSET_ARG 4
-#else
-#define PREAD_OFFSET_ARG 3
-#endif
-
 SYS_FUNC(pread)
 {
        if (entering(tcp)) {
@@ -166,7 +164,7 @@ SYS_FUNC(pread)
                else
                        printstr(tcp, tcp->u_arg[1], tcp->u_rval);
                tprintf(", %lu, ", tcp->u_arg[2]);
-               printllval(tcp, "%lld", PREAD_OFFSET_ARG);
+               printllval(tcp, "%lld", 3);
        }
        return 0;
 }
@@ -177,7 +175,7 @@ SYS_FUNC(pwrite)
        tprints(", ");
        printstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
        tprintf(", %lu, ", tcp->u_arg[2]);
-       printllval(tcp, "%lld", PREAD_OFFSET_ARG);
+       printllval(tcp, "%lld", 3);
 
        return RVAL_DECODED;
 }
@@ -196,9 +194,8 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg)
                tprintf("%ld", tcp->u_arg[arg]);
 # if SUPPORTED_PERSONALITIES > 1
        else
-               tprintf("%ld",
-                       ((unsigned long) tcp->u_arg[arg + 1] << current_wordsize * 8)
-                       | (unsigned long) tcp->u_arg[arg]);
+               tprintf("%ld", (tcp->u_arg[arg + 1] << current_wordsize * 8)
+                              | tcp->u_arg[arg]);
 # endif
 #elif SIZEOF_LONG > 4
 # error Unsupported configuration: SIZEOF_LONG > 4 && SIZEOF_LONG_LONG > SIZEOF_LONG
@@ -206,8 +203,8 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg)
 # if SUPPORTED_PERSONALITIES > 1
        if (current_personality == 1) {
                tprintf("%lld",
-                       (widen_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
-                       | widen_to_ull(tcp->u_arg[arg]));
+                       (zero_extend_signed_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
+                       | zero_extend_signed_to_ull(tcp->u_arg[arg]));
        } else
 # endif
        {
@@ -215,8 +212,8 @@ print_lld_from_low_high_val(struct tcb *tcp, int arg)
        }
 #else /* SIZEOF_LONG_LONG > SIZEOF_LONG && !HAVE_STRUCT_TCB_EXT_ARG */
        tprintf("%lld",
-               (widen_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
-               | widen_to_ull(tcp->u_arg[arg]));
+               (zero_extend_signed_to_ull(tcp->u_arg[arg + 1]) << sizeof(long) * 8)
+               | zero_extend_signed_to_ull(tcp->u_arg[arg]));
 #endif
 }
 
@@ -229,8 +226,9 @@ do_preadv(struct tcb *tcp, const int flags_arg)
                printfd(tcp, tcp->u_arg[0]);
                tprints(", ");
        } else {
-               tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR,
-                               tcp->u_rval);
+               tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1],
+                               syserror(tcp) ? IOV_DECODE_ADDR :
+                               IOV_DECODE_STR, tcp->u_rval);
                tprintf(", %lu, ", tcp->u_arg[2]);
                print_lld_from_low_high_val(tcp, 3);
                if (flags_arg >= 0) {