]> granicus.if.org Git - strace/blobdiff - syscall.c
ioctl: print unrecognized ioctl codes in _IOC(dir,type,nr,size) format
[strace] / syscall.c
index e74881d5e1ce4a38d144739ce529cf3d515b83c0..a50910ffa072917e4b15cfcd0fae5dd84181586c 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -37,7 +37,9 @@
 
 #ifdef HAVE_SYS_REG_H
 # include <sys/reg.h>
-#elif defined(HAVE_LINUX_PTRACE_H)
+#endif
+
+#ifdef HAVE_LINUX_PTRACE_H
 # undef PTRACE_SYSCALL
 # ifdef HAVE_STRUCT_IA64_FPREG
 #  define ia64_fpreg XXX_ia64_fpreg
@@ -928,34 +930,35 @@ print_pc(struct tcb *tcp)
 #endif /* architecture */
 }
 
-/* Shuffle syscall numbers so that we don't have huge gaps in syscall table.
- * The shuffling should be reversible: shuffle_scno(shuffle_scno(n)) == n.
+/*
+ * Shuffle syscall numbers so that we don't have huge gaps in syscall table.
+ * The shuffling should be an involution: shuffle_scno(shuffle_scno(n)) == n.
  */
 #if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
 static long
 shuffle_scno(unsigned long scno)
 {
-       if (scno <= ARM_LAST_ORDINARY_SYSCALL)
+       if (scno < ARM_FIRST_SHUFFLED_SYSCALL)
                return scno;
 
        /* __ARM_NR_cmpxchg? Swap with LAST_ORDINARY+1 */
-       if (scno == 0x000ffff0)
-               return ARM_LAST_ORDINARY_SYSCALL+1;
-       if (scno == ARM_LAST_ORDINARY_SYSCALL+1)
+       if (scno == ARM_FIRST_SHUFFLED_SYSCALL)
                return 0x000ffff0;
+       if (scno == 0x000ffff0)
+               return ARM_FIRST_SHUFFLED_SYSCALL;
 
-       /* Is it ARM specific syscall?
-        * Swap with [LAST_ORDINARY+2, LAST_ORDINARY+2 + LAST_SPECIAL] range.
+#define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
+       /*
+        * Is it ARM specific syscall?
+        * Swap [0x000f0000, 0x000f0000 + LAST_SPECIAL] range
+        * with [SECOND_SHUFFLED, SECOND_SHUFFLED + LAST_SPECIAL] range.
         */
-       if (scno >= 0x000f0000
-        && scno <= 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL
-       ) {
-               return scno - 0x000f0000 + (ARM_LAST_ORDINARY_SYSCALL+2);
+       if (scno >= 0x000f0000 &&
+           scno <= 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL) {
+               return scno - 0x000f0000 + ARM_SECOND_SHUFFLED_SYSCALL;
        }
-       if (/* scno >= ARM_LAST_ORDINARY_SYSCALL+2 - always true */ 1
-        && scno <= (ARM_LAST_ORDINARY_SYSCALL+2) + ARM_LAST_SPECIAL_SYSCALL
-       ) {
-               return scno + 0x000f0000 - (ARM_LAST_ORDINARY_SYSCALL+2);
+       if (scno <= ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL) {
+               return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL;
        }
 
        return scno;
@@ -1376,7 +1379,7 @@ get_scno(struct tcb *tcp)
        if (errno)
                return -1;
        /* EABI syscall convention? */
-       if (scno != 0xef000000) {
+       if ((unsigned long) scno != 0xef000000) {
                /* No, it's OABI */
                if ((scno & 0x0ff00000) != 0x0f900000) {
                        fprintf(stderr, "pid %d unknown syscall trap 0x%08lx\n",
@@ -2495,6 +2498,12 @@ dumpio(struct tcb *tcp)
                        dumpstr(tcp, tcp->u_arg[1], tcp->u_rval);
                else if (func == sys_readv)
                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+#if HAVE_SENDMSG
+               else if (func == sys_recvmsg)
+                       dumpiov_in_msghdr(tcp, tcp->u_arg[1]);
+               else if (func == sys_recvmmsg)
+                       dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
+#endif
                return;
        }
        if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE) {
@@ -2505,6 +2514,12 @@ dumpio(struct tcb *tcp)
                        dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
                else if (func == sys_writev)
                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+#if HAVE_SENDMSG
+               else if (func == sys_sendmsg)
+                       dumpiov_in_msghdr(tcp, tcp->u_arg[1]);
+               else if (func == sys_sendmmsg)
+                       dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
+#endif
                return;
        }
 }