]> granicus.if.org Git - strace/commitdiff
mips o32: decode indirect syscall
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 17 Apr 2015 09:14:19 +0000 (09:14 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 17 Apr 2015 23:02:15 +0000 (23:02 +0000)
Implement decoding of MIPS O32 specific indirect syscall.

* syscall.c [LINUX_MIPSO32] (decode_mips_subcall, sys_syscall):
New functions.
(trace_syscall_entering) [LINUX_MIPSO32]: Use decode_mips_subcall.
* linux/mips/syscallent-o32.h (4000): Change sys_func to sys_syscall.

Reported-and-tested-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
linux/mips/syscallent-o32.h
syscall.c

index cb4c288522c3b9c43b21f0be9f87ede11c708c86..83d003f2efea542dd74d25476d008140fc0250f2 100644 (file)
@@ -1,6 +1,6 @@
 #if defined LINUX_MIPSO32
 /* For an O32 strace, decode the o32 syscalls.  */
-[4000] = { MA, 0,              printargs,                      "syscall"               }, /* start of Linux o32 */
+[4000] = { MA, 0,              sys_syscall,                    "syscall"               }, /* start of Linux o32 */
 [4001] = { 1,  TP|SE,          sys_exit,                       "exit"                  },
 [4002] = { 0,  TP,             sys_fork,                       "fork"                  },
 [4003] = { 3,  TD,             sys_read,                       "read"                  },
index 1e19eb554d6d069637320c95bc28da4c1782eb9a..b63a5280ffc6c5db3cc209cdc0a98e81d7f3ac4b 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -602,6 +602,30 @@ decode_ipc_subcall(struct tcb *tcp)
 }
 #endif
 
+#ifdef LINUX_MIPSO32
+static void
+decode_mips_subcall(struct tcb *tcp)
+{
+       if (!SCNO_IS_VALID(tcp->u_arg[0]))
+               return;
+       tcp->scno = tcp->u_arg[0];
+       tcp->qual_flg = qual_flags[tcp->scno];
+       tcp->s_ent = &sysent[tcp->scno];
+       memmove(&tcp->u_arg[0], &tcp->u_arg[1],
+               sizeof(tcp->u_arg) - sizeof(tcp->u_arg[0]));
+       /*
+        * Fetching the last arg of 7-arg syscalls (fadvise64_64
+        * and sync_file_range) would require additional code,
+        * see linux/mips/get_syscall_args.c
+        */
+}
+
+SYS_FUNC(syscall)
+{
+       return printargs(tcp);
+}
+#endif
+
 int
 printargs(struct tcb *tcp)
 {
@@ -770,6 +794,11 @@ trace_syscall_entering(struct tcb *tcp)
                goto ret;
        }
 
+#ifdef LINUX_MIPSO32
+       if (sys_syscall == tcp->s_ent->sys_func)
+               decode_mips_subcall(tcp);
+#endif
+
        if (   sys_execve == tcp->s_ent->sys_func
 # if defined(SPARC) || defined(SPARC64)
            || sys_execv == tcp->s_ent->sys_func