]> granicus.if.org Git - strace/blobdiff - ipc_msg.c
tprint_iov*: change address argument type from unsigned long to kernel_ureg_t
[strace] / ipc_msg.c
index 5052eacea8b73c100d9abc5b40a76666079630eb..7ef5cda93f426a44abd41dc510b469840b11a93e 100644 (file)
--- a/ipc_msg.c
+++ b/ipc_msg.c
  */
 
 #include "defs.h"
+#include "ipc_defs.h"
 
-#include <sys/ipc.h>
-#include <sys/msg.h>
+#ifdef HAVE_SYS_MSG_H
+# include <sys/msg.h>
+#elif defined HAVE_LINUX_MSG_H
+# include <linux/msg.h>
+#endif
 
 #include "xlat/ipc_msg_flags.h"
 #include "xlat/resource_flags.h"
 
-extern void tprint_msgbuf(struct tcb *tcp, const long addr, const unsigned long count);
-
 SYS_FUNC(msgget)
 {
-       if (tcp->u_arg[0])
-               tprintf("%#lx, ", tcp->u_arg[0]);
+       const int key = (int) tcp->u_arg[0];
+       if (key)
+               tprintf("%#x", key);
        else
-               tprints("IPC_PRIVATE, ");
+               tprints("IPC_PRIVATE");
+       tprints(", ");
        if (printflags(resource_flags, tcp->u_arg[1] & ~0777, NULL) != 0)
                tprints("|");
-       tprintf("%#lo", tcp->u_arg[1] & 0777);
+       print_numeric_umode_t(tcp->u_arg[1] & 0777);
        return RVAL_DECODED;
 }
 
@@ -82,10 +86,10 @@ tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count,
 }
 
 static int
-fetch_msgrcv_args(struct tcb *tcp, const long addr, long *pair)
+fetch_msgrcv_args(struct tcb *tcp, const long addr, unsigned long *pair)
 {
-       if (current_wordsize == sizeof(long)) {
-               if (umoven_or_printaddr(tcp, addr, 2 * sizeof(long), pair))
+       if (current_wordsize == sizeof(*pair)) {
+               if (umoven_or_printaddr(tcp, addr, 2 * sizeof(*pair), pair))
                        return -1;
        } else {
                unsigned int tmp[2];
@@ -104,12 +108,23 @@ SYS_FUNC(msgrcv)
                tprintf("%d, ", (int) tcp->u_arg[0]);
        } else {
                if (indirect_ipccall(tcp)) {
-                       long pair[2];
+                       const bool direct =
+#ifdef SPARC64
+                               current_wordsize == 8 ||
+#endif
+                               get_tcb_priv_ulong(tcp) != 0;
+                       if (direct) {
+                               tprint_msgrcv(tcp, tcp->u_arg[3],
+                                             tcp->u_arg[1], tcp->u_arg[4]);
+                       } else {
+                               unsigned long pair[2];
 
-                       if (fetch_msgrcv_args(tcp, tcp->u_arg[3], pair))
-                               tprintf(", %lu, ", tcp->u_arg[1]);
-                       else
-                               tprint_msgrcv(tcp, pair[0], tcp->u_arg[1], pair[1]);
+                               if (fetch_msgrcv_args(tcp, tcp->u_arg[3], pair))
+                                       tprintf(", %lu, ", tcp->u_arg[1]);
+                               else
+                                       tprint_msgrcv(tcp, pair[0],
+                                                     tcp->u_arg[1], pair[1]);
+                       }
                        printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
                } else {
                        tprint_msgrcv(tcp, tcp->u_arg[1],