]> granicus.if.org Git - strace/commitdiff
Change comparisons with function pointers to comparisons with SENs
authorElvira Khabirova <lineprinter0@gmail.com>
Fri, 10 Jul 2015 19:24:58 +0000 (22:24 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 12 Jul 2015 22:31:49 +0000 (22:31 +0000)
* pathtrace.c (pathtrace_match): Change all comparisons with function
pointers to a single SEN based switch.
* syscall.c (dumpio, trace_syscall_entering): Change all comparisons
with function pointers to comparisons with SENs.
* ipc.c (sys_ipc): Remove.
* sock.c (sys_socketcall): Likewise.
* linux/dummy.h (sys_ipc, sys_socketcall): New aliases.

ipc.c
linux/dummy.h
pathtrace.c
sock.c
syscall.c

diff --git a/ipc.c b/ipc.c
index f2c064b2090c99cf38da972880c133f4acb0d195..3db527c0d820fbda68444994df918cf7f6ab5977 100644 (file)
--- a/ipc.c
+++ b/ipc.c
@@ -451,8 +451,3 @@ SYS_FUNC(mq_getsetattr)
                printmqattr(tcp, tcp->u_arg[2]);
        return 0;
 }
-
-SYS_FUNC(ipc)
-{
-       return printargs(tcp);
-}
index a831d40532242f836973c35082628ab6a6078c73..cc898b133718d9fe7caa7a5b7b6a64660353136f 100644 (file)
 #define        sys_gettid              printargs
 #define        sys_idle                printargs
 #define        sys_inotify_init        printargs
+#define        sys_ipc                 printargs
 #define        sys_munlockall          printargs
 #define        sys_pause               printargs
 #define        sys_printargs           printargs
 #define        sys_setsid              printargs
 #define        sys_set_tid_address     printargs
 #define        sys_setup               printargs
+#define        sys_socketcall          printargs
 #define        sys_sync                printargs
 #define        sys_timer_delete        printargs
 #define        sys_timer_getoverrun    printargs
index 6b3a20909d3d5dd67de88fcfbdd848ae0952273a..4ca031cb449d45087442f574c8837d43fa1b120a 100644 (file)
@@ -164,100 +164,87 @@ pathtrace_match(struct tcb *tcp)
         * other than test arg[0].
         */
 
-       if (s->sys_func == sys_dup2 ||
-           s->sys_func == sys_dup3 ||
-           s->sys_func == sys_sendfile ||
-           s->sys_func == sys_sendfile64 ||
-           s->sys_func == sys_tee)
-       {
+       switch (s->sen) {
+       case SEN_dup2:
+       case SEN_dup3:
+       case SEN_sendfile:
+       case SEN_sendfile64:
+       case SEN_tee:
                /* fd, fd */
                return fdmatch(tcp, tcp->u_arg[0]) ||
                        fdmatch(tcp, tcp->u_arg[1]);
-       }
 
-       if (s->sys_func == sys_inotify_add_watch ||
-           s->sys_func == sys_faccessat ||
-           s->sys_func == sys_fchmodat ||
-           s->sys_func == sys_futimesat ||
-           s->sys_func == sys_unlinkat ||
-           s->sys_func == sys_newfstatat ||
-           s->sys_func == sys_mknodat ||
-           s->sys_func == sys_openat ||
-           s->sys_func == sys_readlinkat ||
-           s->sys_func == sys_utimensat ||
-           s->sys_func == sys_fchownat ||
-           s->sys_func == sys_pipe2)
-       {
+       case SEN_faccessat:
+       case SEN_fchmodat:
+       case SEN_fchownat:
+       case SEN_futimesat:
+       case SEN_inotify_add_watch:
+       case SEN_mkdirat:
+       case SEN_mknodat:
+       case SEN_newfstatat:
+       case SEN_openat:
+       case SEN_pipe2:
+       case SEN_readlinkat:
+       case SEN_unlinkat:
+       case SEN_utimensat:
                /* fd, path */
                return fdmatch(tcp, tcp->u_arg[0]) ||
                        upathmatch(tcp, tcp->u_arg[1]);
-       }
 
-       if (s->sys_func == sys_link ||
-           s->sys_func == sys_mount)
-       {
+       case SEN_link:
+       case SEN_mount:
+       case SEN_pivotroot:
                /* path, path */
                return upathmatch(tcp, tcp->u_arg[0]) ||
                        upathmatch(tcp, tcp->u_arg[1]);
-       }
 
-       if (s->sys_func == sys_quotactl)
-       {
+       case SEN_quotactl:
                /* x, path */
                return upathmatch(tcp, tcp->u_arg[1]);
-       }
 
-       if (s->sys_func == sys_renameat ||
-           s->sys_func == sys_renameat2 ||
-           s->sys_func == sys_linkat)
-       {
+       case SEN_linkat:
+       case SEN_renameat2:
+       case SEN_renameat:
                /* fd, path, fd, path */
                return fdmatch(tcp, tcp->u_arg[0]) ||
                        fdmatch(tcp, tcp->u_arg[2]) ||
                        upathmatch(tcp, tcp->u_arg[1]) ||
                        upathmatch(tcp, tcp->u_arg[3]);
-       }
 
-       if (
-           s->sys_func == sys_old_mmap ||
+       case SEN_old_mmap:
 #if defined(S390)
-           s->sys_func == sys_old_mmap_pgoff ||
+       case SEN_old_mmap_pgoff:
 #endif
-           s->sys_func == sys_mmap ||
-           s->sys_func == sys_mmap_pgoff ||
-           s->sys_func == sys_mmap_4koff
-       ) {
+       case SEN_mmap:
+       case SEN_mmap_4koff:
+       case SEN_mmap_pgoff:
                /* x, x, x, x, fd */
                return fdmatch(tcp, tcp->u_arg[4]);
-       }
 
-       if (s->sys_func == sys_symlinkat) {
+       case SEN_symlinkat:
                /* path, fd, path */
                return fdmatch(tcp, tcp->u_arg[1]) ||
                        upathmatch(tcp, tcp->u_arg[0]) ||
                        upathmatch(tcp, tcp->u_arg[2]);
-       }
 
-       if (s->sys_func == sys_splice) {
+       case SEN_splice:
                /* fd, x, fd, x, x */
                return fdmatch(tcp, tcp->u_arg[0]) ||
                        fdmatch(tcp, tcp->u_arg[2]);
-       }
 
-       if (s->sys_func == sys_epoll_ctl) {
+       case SEN_epoll_ctl:
                /* x, x, fd, x */
                return fdmatch(tcp, tcp->u_arg[2]);
-       }
 
-       if (s->sys_func == sys_fanotify_mark) {
+
+       case SEN_fanotify_mark:
                /* x, x, x, fd, path */
                return fdmatch(tcp, tcp->u_arg[3]) ||
                        upathmatch(tcp, tcp->u_arg[4]);
-       }
 
-       if (s->sys_func == sys_select ||
-           s->sys_func == sys_oldselect ||
-           s->sys_func == sys_pselect6)
+       case SEN_oldselect:
+       case SEN_pselect6:
+       case SEN_select:
        {
                int     i, j;
                int     nfds;
@@ -266,7 +253,7 @@ pathtrace_match(struct tcb *tcp)
                fd_set *fds;
 
                args = tcp->u_arg;
-               if (s->sys_func == sys_oldselect) {
+               if (SEN_oldselect == s->sen) {
                        if (umoven(tcp, tcp->u_arg[0], sizeof oldargs,
                                   oldargs) < 0)
                        {
@@ -308,8 +295,8 @@ pathtrace_match(struct tcb *tcp)
                return 0;
        }
 
-       if (s->sys_func == sys_poll ||
-           s->sys_func == sys_ppoll)
+       case SEN_poll:
+       case SEN_ppoll:
        {
                struct pollfd fds;
                unsigned nfds;
@@ -331,20 +318,19 @@ pathtrace_match(struct tcb *tcp)
                return 0;
        }
 
-       if (s->sys_func == printargs ||
-           s->sys_func == sys_pipe ||
-           s->sys_func == sys_pipe2 ||
-           s->sys_func == sys_eventfd2 ||
-           s->sys_func == sys_eventfd ||
-           s->sys_func == sys_inotify_init1 ||
-           s->sys_func == sys_timerfd_create ||
-           s->sys_func == sys_timerfd_settime ||
-           s->sys_func == sys_timerfd_gettime ||
-           s->sys_func == sys_epoll_create ||
-           s->sys_func == sys_socket ||
-           s->sys_func == sys_socketpair ||
-           s->sys_func == sys_fanotify_init)
-       {
+       case SEN_epoll_create:
+       case SEN_eventfd2:
+       case SEN_eventfd:
+       case SEN_fanotify_init:
+       case SEN_inotify_init1:
+       case SEN_perf_event_open:
+       case SEN_pipe:
+       case SEN_printargs:
+       case SEN_socket:
+       case SEN_socketpair:
+       case SEN_timerfd_create:
+       case SEN_timerfd_gettime:
+       case SEN_timerfd_settime:
                /*
                 * These have TRACE_FILE or TRACE_DESCRIPTOR or TRACE_NETWORK set,
                 * but they don't have any file descriptor or path args to test.
diff --git a/sock.c b/sock.c
index 97d8afa6ce6514e6efe374ea39150097ca4f4b02..4da53022792f158d9ddcb07c0b4cb72f727387aa 100644 (file)
--- a/sock.c
+++ b/sock.c
@@ -348,8 +348,3 @@ sock_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
 
        return RVAL_DECODED | 1;
 }
-
-SYS_FUNC(socketcall)
-{
-       return printargs(tcp);
-}
index 6753f2dea12d2e3ad7964dcec9468cc848179f7e..6aa1cd2d17c00f801b8208dc7b8ab68e6d823fd5 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -655,49 +655,56 @@ printargs_ld(struct tcb *tcp)
 static void
 dumpio(struct tcb *tcp)
 {
-       int (*func)();
+       int sen;
 
        if (syserror(tcp))
                return;
        if ((unsigned long) tcp->u_arg[0] >= num_quals)
                return;
-       func = tcp->s_ent->sys_func;
-       if (func == printargs)
+       sen = tcp->s_ent->sen;
+       if (SEN_printargs == sen)
                return;
        if (qual_flags[tcp->u_arg[0]] & QUAL_READ) {
-               if (func == sys_read ||
-                   func == sys_pread ||
-                   func == sys_recv ||
-                   func == sys_recvfrom) {
+               switch (sen) {
+               case SEN_read:
+               case SEN_pread:
+               case SEN_recv:
+               case SEN_recvfrom:
                        dumpstr(tcp, tcp->u_arg[1], tcp->u_rval);
                        return;
-               } else if (func == sys_readv) {
+               case SEN_readv:
                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
                        return;
 #ifdef HAVE_SENDMSG
-               } else if (func == sys_recvmsg) {
+               case SEN_recvmsg:
                        dumpiov_in_msghdr(tcp, tcp->u_arg[1]);
                        return;
-               } else if (func == sys_recvmmsg) {
+               case SEN_recvmmsg:
                        dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
                        return;
 #endif
                }
        }
        if (qual_flags[tcp->u_arg[0]] & QUAL_WRITE) {
-               if (func == sys_write ||
-                   func == sys_pwrite ||
-                   func == sys_send ||
-                   func == sys_sendto)
+               switch (sen) {
+               case SEN_write:
+               case SEN_pwrite:
+               case SEN_send:
+               case SEN_sendto:
                        dumpstr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
-               else if (func == sys_writev)
+                       break;
+               case SEN_writev:
                        dumpiov(tcp, tcp->u_arg[2], tcp->u_arg[1]);
+                       break;
 #ifdef HAVE_SENDMSG
-               else if (func == sys_sendmsg)
+               case SEN_sendmsg:
                        dumpiov_in_msghdr(tcp, tcp->u_arg[1]);
-               else if (func == sys_sendmmsg)
+                       break;
+               case SEN_sendmmsg:
                        dumpiov_in_mmsghdr(tcp, tcp->u_arg[1]);
+                       break;
 #endif
+               }
        }
 }
 
@@ -785,33 +792,30 @@ trace_syscall_entering(struct tcb *tcp)
        }
 
 #ifdef LINUX_MIPSO32
-       if (sys_syscall == tcp->s_ent->sys_func)
+       if (SEN_syscall == tcp->s_ent->sen)
                decode_mips_subcall(tcp);
 #endif
 
-       if (   sys_execve == tcp->s_ent->sys_func
+       if (   SEN_execve == tcp->s_ent->sen
 # if defined(SPARC) || defined(SPARC64)
-           || sys_execv == tcp->s_ent->sys_func
+           || SEN_execv == tcp->s_ent->sen
 # endif
           ) {
                hide_log_until_execve = 0;
        }
 
 #if defined(SYS_socket_subcall) || defined(SYS_ipc_subcall)
-       while (1) {
+       switch (tcp->s_ent->sen) {
 # ifdef SYS_socket_subcall
-               if (tcp->s_ent->sys_func == sys_socketcall) {
+               case SEN_socketcall:
                        decode_socket_subcall(tcp);
                        break;
-               }
 # endif
 # ifdef SYS_ipc_subcall
-               if (tcp->s_ent->sys_func == sys_ipc) {
+               case SEN_ipc:
                        decode_ipc_subcall(tcp);
                        break;
-               }
 # endif
-               break;
        }
 #endif
 
@@ -842,7 +846,7 @@ trace_syscall_entering(struct tcb *tcp)
                tprintf("%s(", undefined_scno_name(tcp));
        else
                tprintf("%s(", tcp->s_ent->sys_name);
-       if ((tcp->qual_flg & QUAL_RAW) && tcp->s_ent->sys_func != sys_exit)
+       if ((tcp->qual_flg & QUAL_RAW) && SEN_exit != tcp->s_ent->sen)
                res = printargs(tcp);
        else
                res = tcp->s_ent->sys_func(tcp);