]> granicus.if.org Git - strace/blobdiff - ipc_sem.c
nlattr: add unsigned int decoders that print in hex form
[strace] / ipc_sem.c
index 5b36e76b82604646475bb8d6b1634e0f75fd2034..8201a22b5fe7b1c601ba817e9f46e112a475ce6c 100644 (file)
--- a/ipc_sem.c
+++ b/ipc_sem.c
@@ -5,6 +5,7 @@
  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
  * Copyright (c) 2003-2006 Roland McGrath <roland@redhat.com>
  * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2017 The strace developers.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -49,7 +50,7 @@ print_sembuf(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
        const struct sembuf *sb = elem_buf;
 
        tprintf("{%u, %d, ", sb->sem_num, sb->sem_op);
-       printflags(semop_flags, sb->sem_flg, "SEM_???");
+       printflags(semop_flags, (unsigned short) sb->sem_flg, "SEM_???");
        tprints("}");
 
        return true;
@@ -57,21 +58,22 @@ print_sembuf(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
 #endif
 
 static void
-tprint_sembuf_array(struct tcb *tcp, const long addr, const unsigned long count)
+tprint_sembuf_array(struct tcb *const tcp, const kernel_ulong_t addr,
+                   const unsigned int count)
 {
 #if defined HAVE_SYS_SEM_H || defined HAVE_LINUX_SEM_H
        struct sembuf sb;
        print_array(tcp, addr, count, &sb, sizeof(sb),
-                   umoven_or_printaddr, print_sembuf, 0);
+                   tfetch_mem, print_sembuf, 0);
 #else
        printaddr(addr);
 #endif
-       tprintf(", %lu", count);
+       tprintf(", %u", count);
 }
 
 SYS_FUNC(semop)
 {
-       tprintf("%lu, ", tcp->u_arg[0]);
+       tprintf("%d, ", (int) tcp->u_arg[0]);
        if (indirect_ipccall(tcp)) {
                tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
        } else {
@@ -82,7 +84,7 @@ SYS_FUNC(semop)
 
 SYS_FUNC(semtimedop)
 {
-       tprintf("%lu, ", tcp->u_arg[0]);
+       tprintf("%d, ", (int) tcp->u_arg[0]);
        if (indirect_ipccall(tcp)) {
                tprint_sembuf_array(tcp, tcp->u_arg[3], tcp->u_arg[1]);
                tprints(", ");
@@ -101,26 +103,27 @@ SYS_FUNC(semtimedop)
 
 SYS_FUNC(semget)
 {
-       if (tcp->u_arg[0])
-               tprintf("%#lx", tcp->u_arg[0]);
-       else
-               tprints("IPC_PRIVATE");
-       tprintf(", %lu, ", tcp->u_arg[1]);
+       printxval(ipc_private, (unsigned int) tcp->u_arg[0], NULL);
+       tprintf(", %d, ", (int) tcp->u_arg[1]);
        if (printflags(resource_flags, tcp->u_arg[2] & ~0777, NULL) != 0)
                tprints("|");
-       tprintf("%#lo", tcp->u_arg[2] & 0777);
+       print_numeric_umode_t(tcp->u_arg[2] & 0777);
        return RVAL_DECODED;
 }
 
 SYS_FUNC(semctl)
 {
-       tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
+       tprintf("%d, %d, ", (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
        PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
        tprints(", ");
-       if (indirect_ipccall(tcp)) {
+       if (indirect_ipccall(tcp)
+#ifdef SPARC64
+           && current_personality != 0
+#endif
+          ) {
                printnum_ptr(tcp, tcp->u_arg[3]);
        } else {
-               tprintf("%#lx", tcp->u_arg[3]);
+               printaddr(tcp->u_arg[3]);
        }
        return RVAL_DECODED;
 }