]> granicus.if.org Git - strace/commitdiff
Consistently use printaddr for printing addresses
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 11 Jun 2016 01:28:21 +0000 (01:28 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 11 Jun 2016 09:26:49 +0000 (09:26 +0000)
* bjm.c (SYS_FUNC(init_module)): Use printaddr.
* clone.c (SYS_FUNC(clone)): Likewise.
* evdev.c (ff_effect_ioctl): Likewise.
* mtd.c (decode_mtd_oob_buf): Likewise.
* net.c (SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg), SYS_FUNC(getsockopt)):
Likewise.
* print_sigevent.c (print_sigevent): Likewise.
* printsiginfo.c (printsigval, print_si_info): Likewise.
* signal.c (decode_new_sigaction): Likewise.
* sysmips.c (SYS_FUNC(sysmips)): Likewise.
* util.c (printpathn, printstr, umoven_or_printaddr): Likewise.
* v4l2.c (print_v4l2_buffer, print_v4l2_framebuffer,
umoven_or_printaddr_ignore_syserror): Likewise.
* tests/net-icmp_filter.c (main): Update.

Based on patch by Eugene Syromyatnikov <evgsyr@gmail.com>.

12 files changed:
bjm.c
clone.c
evdev.c
mtd.c
net.c
print_sigevent.c
printsiginfo.c
signal.c
sysmips.c
tests/net-icmp_filter.c
util.c
v4l2.c

diff --git a/bjm.c b/bjm.c
index 7ba14982b20d1421bfe8f748130a1c8c5cdc7a79..7a72809a1ab4fe6f4a57a08e6c2b0c16e7975366 100644 (file)
--- a/bjm.c
+++ b/bjm.c
@@ -52,7 +52,8 @@ SYS_FUNC(delete_module)
 
 SYS_FUNC(init_module)
 {
-       tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
+       printaddr(tcp->u_arg[0]);
+       tprintf(", %lu, ", tcp->u_arg[1]);
        printstr(tcp, tcp->u_arg[2], -1);
 
        return RVAL_DECODED;
diff --git a/clone.c b/clone.c
index 2fad0b8d0bff3d315e4e47ea1d8e86dcd09c7413..99d0da7f0ce960b73f15ffea5da497276d08ec85 100644 (file)
--- a/clone.c
+++ b/clone.c
@@ -82,7 +82,9 @@ SYS_FUNC(clone)
        if (exiting(tcp)) {
                const char *sep = "|";
                unsigned long flags = tcp->u_arg[ARG_FLAGS];
-               tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
+               tprints("child_stack=");
+               printaddr(tcp->u_arg[ARG_STACK]);
+               tprints(", ");
 #ifdef ARG_STACKSIZE
                if (ARG_STACKSIZE != -1)
                        tprintf("stack_size=%#lx, ",
@@ -96,8 +98,10 @@ SYS_FUNC(clone)
                if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
                              |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
                        return 0;
-               if (flags & CLONE_PARENT_SETTID)
-                       tprintf(", parent_tidptr=%#lx", tcp->u_arg[ARG_PTID]);
+               if (flags & CLONE_PARENT_SETTID) {
+                       tprints(", parent_tidptr=");
+                       printaddr(tcp->u_arg[ARG_PTID]);
+               }
                if (flags & CLONE_SETTLS) {
 #if defined I386 || defined X86_64 || defined X32
 # ifndef I386
@@ -111,10 +115,15 @@ SYS_FUNC(clone)
                        else
 # endif
 #endif /* I386 || X86_64 || X32 */
-                               tprintf(", tls=%#lx", tcp->u_arg[ARG_TLS]);
+                       {
+                               tprints(", tls=");
+                               printaddr(tcp->u_arg[ARG_TLS]);
+                       }
+               }
+               if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID)) {
+                       tprints(", child_tidptr=");
+                       printaddr(tcp->u_arg[ARG_CTID]);
                }
-               if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID))
-                       tprintf(", child_tidptr=%#lx", tcp->u_arg[ARG_CTID]);
        }
        /* TODO on syscall entry:
         * We can clear CLONE_PTRACE here since it is an ancient hack
diff --git a/evdev.c b/evdev.c
index 2e436d6e8a2910a30ea05e33a27b227f26feefc6..b7b64024d480504cd115efa21eee35265bc6f83c 100644 (file)
--- a/evdev.c
+++ b/evdev.c
@@ -133,10 +133,10 @@ ff_effect_ioctl(struct tcb *tcp, long arg)
                                ffe.u.periodic.offset,
                                ffe.u.periodic.phase);
                        decode_envelope(&ffe.u.periodic.envelope);
-                       tprintf(", custom_len=%u"
-                               ", custom_data=%#lx}",
-                               ffe.u.periodic.custom_len,
-                               (unsigned long) ffe.u.periodic.custom_data);
+                       tprintf(", custom_len=%u, custom_data=",
+                               ffe.u.periodic.custom_len);
+                       printaddr((unsigned long) ffe.u.periodic.custom_data);
+                       tprints("}");
                        break;
                case FF_RUMBLE:
                        tprintf(", rumble={strong_magnitude=%" PRIu16
diff --git a/mtd.c b/mtd.c
index 52714ae3c848612a0290a1a8095ee19fe5c3615f..4442b1cc70ce69b9c664a7fa5f3e309d3e3c9378 100644 (file)
--- a/mtd.c
+++ b/mtd.c
@@ -83,8 +83,9 @@ decode_mtd_oob_buf(struct tcb *tcp, const long addr)
        if (umove_or_printaddr(tcp, addr, &mbuf))
                return;
 
-       tprintf("{start=%#x, length=%#x, ptr=%#lx}",
-               mbuf.start, mbuf.length, (unsigned long) mbuf.ptr);
+       tprintf("{start=%#x, length=%#x, ptr=", mbuf.start, mbuf.length);
+       printaddr((unsigned long) mbuf.ptr);
+       tprints("}");
 }
 
 static void
diff --git a/net.c b/net.c
index 3349758e3503a250860e5c911accfc10f69ea46d..8cc97da1c3e2adcb3e7d0f3eb53ea55f55ef7f8d 100644 (file)
--- a/net.c
+++ b/net.c
@@ -930,8 +930,8 @@ SYS_FUNC(sendmmsg)
                printfd(tcp, tcp->u_arg[0]);
                tprints(", ");
                if (!verbose(tcp)) {
-                       tprintf("%#lx, %u, ",
-                               tcp->u_arg[1], (unsigned int) tcp->u_arg[2]);
+                       printaddr(tcp->u_arg[1]);
+                       tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
                        printflags(msg_flags, tcp->u_arg[3], "MSG_???");
                }
        } else {
@@ -1023,7 +1023,8 @@ SYS_FUNC(recvmmsg)
                         */
                        tcp->auxstr = sprint_timespec(tcp, tcp->u_arg[4]);
                } else {
-                       tprintf("%#lx, %ld, ", tcp->u_arg[1], tcp->u_arg[2]);
+                       printaddr(tcp->u_arg[1]);
+                       tprintf(", %u, ", (unsigned int) tcp->u_arg[2]);
                        printflags(msg_flags, tcp->u_arg[3], "MSG_???");
                        tprints(", ");
                        print_timespec(tcp, tcp->u_arg[4]);
@@ -1335,8 +1336,9 @@ SYS_FUNC(getsockopt)
                int len;
 
                if (syserror(tcp) || umove(tcp, tcp->u_arg[4], &len) < 0) {
-                       tprintf("%#lx, %#lx",
-                               tcp->u_arg[3], tcp->u_arg[4]);
+                       printaddr(tcp->u_arg[3]);
+                       tprints(", ");
+                       printaddr(tcp->u_arg[4]);
                } else {
                        print_getsockopt(tcp, tcp->u_arg[1], tcp->u_arg[2],
                                         tcp->u_arg[3], len);
index 1c2b17486b2073d86d36c43f8113b3e88a1bac68..caf1fdfe29843973b35468bd1fdbc2c2dc47de80 100644 (file)
@@ -43,10 +43,12 @@ MPERS_PRINTER_DECL(void, print_sigevent, struct tcb *tcp, const long addr)
                return;
 
        tprints("{");
-       if (sev.sigev_value.sival_ptr)
-               tprintf("sigev_value={int=%d, ptr=%#lx}, ",
-                       sev.sigev_value.sival_int,
-                       (unsigned long) sev.sigev_value.sival_ptr);
+       if (sev.sigev_value.sival_ptr) {
+               tprintf("sigev_value={int=%d, ptr=",
+                       sev.sigev_value.sival_int);
+               printaddr((unsigned long) sev.sigev_value.sival_ptr);
+               tprints("}, ");
+       }
 
        tprints("sigev_signo=");
        switch (sev.sigev_notify) {
index 98755b28fec33b5c26acb29620315001d61f706f..699460f3f25ce6352e801ac084d6b60ead1b4d4f 100644 (file)
@@ -76,8 +76,9 @@ printsigsource(const siginfo_t *sip)
 static void
 printsigval(const siginfo_t *sip)
 {
-       tprintf(", si_value={int=%d, ptr=%#lx}",
-               sip->si_int, (unsigned long) sip->si_ptr);
+       tprintf(", si_value={int=%d, ptr=", sip->si_int);
+       printaddr((unsigned long) sip->si_ptr);
+       tprints("}");
 }
 
 static void
@@ -176,8 +177,8 @@ print_si_info(const siginfo_t *sip)
                        break;
                case SIGILL: case SIGFPE:
                case SIGSEGV: case SIGBUS:
-                       tprintf(", si_addr=%#lx",
-                               (unsigned long) sip->si_addr);
+                       tprints(", si_addr=");
+                       printaddr((unsigned long) sip->si_addr);
                        break;
                case SIGPOLL:
                        switch (sip->si_code) {
@@ -189,8 +190,9 @@ print_si_info(const siginfo_t *sip)
                        break;
 #ifdef HAVE_SIGINFO_T_SI_SYSCALL
                case SIGSYS:
-                       tprintf(", si_call_addr=%#lx, si_syscall=__NR_%s, si_arch=",
-                               (unsigned long) sip->si_call_addr,
+                       tprints(", si_call_addr=");
+                       printaddr((unsigned long) sip->si_call_addr);
+                       tprintf(", si_syscall=__NR_%s, si_arch=",
                                syscall_name((unsigned) sip->si_syscall));
                        printxval(audit_arch, sip->si_arch, "AUDIT_ARCH_???");
                        break;
index f08905054cdc2b5af12e2ea74558c71c8d94c434..8d36675ad355890ac876f9682894209f7deb182b 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -559,14 +559,16 @@ decode_new_sigaction(struct tcb *tcp, long addr)
         * be manipulated by strace. In order to prevent the
         * compiler from generating code to manipulate
         * __sa_handler we cast the function pointers to long. */
+       tprints("{");
        if ((long)sa.__sa_handler == (long)SIG_ERR)
-               tprints("{SIG_ERR, ");
+               tprints("SIG_ERR");
        else if ((long)sa.__sa_handler == (long)SIG_DFL)
-               tprints("{SIG_DFL, ");
+               tprints("SIG_DFL");
        else if ((long)sa.__sa_handler == (long)SIG_IGN)
-               tprints("{SIG_IGN, ");
+               tprints("SIG_IGN");
        else
-               tprintf("{%#lx, ", (long) sa.__sa_handler);
+               printaddr((unsigned long) sa.__sa_handler);
+       tprints(", ");
        /*
         * Sigset size is in tcp->u_arg[4] (SPARC)
         * or in tcp->u_arg[3] (all other),
index bc3cb8d56d694a3c615d1e4a462450f1df728123..47acfec76c9f3d1f4dd523fac0609b90806a96c3 100644 (file)
--- a/sysmips.c
+++ b/sysmips.c
@@ -64,10 +64,11 @@ SYS_FUNC(sysmips)
                return RVAL_DECODED;
        }
        case MIPS_ATOMIC_SET:
-               tprintf("%#lx, 0x%lx", tcp->u_arg[1], tcp->u_arg[2]);
+               printaddr(tcp->u_arg[1]);
+               tprintf(", %#lx", tcp->u_arg[2]);
                return RVAL_DECODED;
        case MIPS_FIXADE:
-               tprintf("0x%lx", tcp->u_arg[1]);
+               tprintf("%#lx", tcp->u_arg[1]);
                return RVAL_DECODED;
        }
 
index d3f956d3285d75be208c3a93fa67d235dc022bd9..f3f99f142c7b422dfa2bf7de351b5293365456c6 100644 (file)
@@ -36,7 +36,7 @@ int
 main(void)
 {
        getsockopt(-1, SOL_RAW, ICMP_FILTER, 0, 0);
-       printf("getsockopt(-1, SOL_RAW, ICMP_FILTER, 0, 0) = -1 %s (%m)\n",
+       printf("getsockopt(-1, SOL_RAW, ICMP_FILTER, NULL, NULL) = -1 %s (%m)\n",
               errno2name());
 
        setsockopt(-1, SOL_RAW, ICMP_FILTER, NULL, 0);
diff --git a/util.c b/util.c
index 9c8c9781de28a535b948df50fb73cdc7097724a1..de881f41b73405f7e4b789e3fddf2cf9c0b221cf 100644 (file)
--- a/util.c
+++ b/util.c
@@ -761,7 +761,7 @@ printpathn(struct tcb *tcp, long addr, unsigned int n)
        /* Fetch one byte more to find out whether path length > n. */
        nul_seen = umovestr(tcp, addr, n + 1, path);
        if (nul_seen < 0)
-               tprintf("%#lx", addr);
+               printaddr(addr);
        else {
                path[n++] = '\0';
                print_quoted_string(path, n, QUOTE_0_TERMINATED);
@@ -812,7 +812,7 @@ printstr(struct tcb *tcp, long addr, long len)
                 * because string_quote may look one byte ahead.
                 */
                if (umovestr(tcp, addr, size + 1, str) < 0) {
-                       tprintf("%#lx", addr);
+                       printaddr(addr);
                        return;
                }
                style = QUOTE_0_TERMINATED;
@@ -821,7 +821,7 @@ printstr(struct tcb *tcp, long addr, long len)
                if (size > (unsigned long)len)
                        size = (unsigned long)len;
                if (umoven(tcp, addr, size, str) < 0) {
-                       tprintf("%#lx", addr);
+                       printaddr(addr);
                        return;
                }
                style = 0;
@@ -1131,13 +1131,9 @@ int
 umoven_or_printaddr(struct tcb *tcp, const long addr, const unsigned int len,
                    void *our_addr)
 {
-       if (!addr) {
-               tprints("NULL");
-               return -1;
-       }
-       if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
+       if (!addr || !verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
            umoven(tcp, addr, len, our_addr) < 0) {
-               tprintf("%#lx", addr);
+               printaddr(addr);
                return -1;
        }
        return 0;
diff --git a/v4l2.c b/v4l2.c
index c0cda21c4a73a121a24fd6fb6b032db1f5206840..e80de55cc0a4d276aa50ae560a1768d5409d0708 100644 (file)
--- a/v4l2.c
+++ b/v4l2.c
@@ -359,8 +359,8 @@ print_v4l2_buffer(struct tcb *tcp, const unsigned int code, const long arg)
                        if (b.memory == V4L2_MEMORY_MMAP) {
                                tprintf(", m.offset=%#x", b.m.offset);
                        } else if (b.memory == V4L2_MEMORY_USERPTR) {
-                               tprintf(", m.userptr=%#lx",
-                                       (unsigned long) b.m.userptr);
+                               tprints(", m.userptr=");
+                               printaddr((unsigned long) b.m.userptr);
                        }
 
                        tprintf(", length=%u, bytesused=%u, flags=",
@@ -384,8 +384,10 @@ print_v4l2_framebuffer(struct tcb *tcp, const long arg)
 
        tprints(", ");
        if (!umove_or_printaddr(tcp, arg, &b)) {
-               tprintf("{capability=%#x, flags=%#x, base=%#lx}",
-                       b.capability, b.flags, (unsigned long) b.base);
+               tprintf("{capability=%#x, flags=%#x, base=",
+                       b.capability, b.flags);
+               printaddr((unsigned long) b.base);
+               tprints("}");
        }
 
        return RVAL_DECODED | 1;
@@ -676,12 +678,8 @@ static int
 umoven_or_printaddr_ignore_syserror(struct tcb *tcp, const long addr,
                                    const unsigned int len, void *our_addr)
 {
-       if (!addr) {
-               tprints("NULL");
-               return -1;
-       }
-       if (umoven(tcp, addr, len, our_addr) < 0) {
-               tprintf("%#lx", addr);
+       if (!addr || umoven(tcp, addr, len, our_addr) < 0) {
+               printaddr(addr);
                return -1;
        }
        return 0;