process.c: move prctl and arch_prctl parsers to a separate file
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Dec 2014 19:25:02 +0000 (19:25 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Dec 2014 21:40:44 +0000 (21:40 +0000)
* prctl.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c: Move sys_prctl, sys_arch_prctl, and related code to prctl.c.

Makefile.am
prctl.c [new file with mode: 0644]
process.c

index cd097a45fec102cf5910dcccb0e2013e1f9b0c17..2f5a8bff95af341c272546272c173649a186fc5e 100644 (file)
@@ -55,6 +55,7 @@ strace_SOURCES =      \
        or1k_atomic.c   \
        pathtrace.c     \
        personality.c   \
+       prctl.c         \
        printmode.c     \
        process.c       \
        process_vm.c    \
diff --git a/prctl.c b/prctl.c
new file mode 100644 (file)
index 0000000..71f26c0
--- /dev/null
+++ b/prctl.c
@@ -0,0 +1,143 @@
+#include "defs.h"
+
+#ifdef HAVE_PRCTL
+#include <sys/prctl.h>
+
+#include "xlat/prctl_options.h"
+
+static const char *
+unalignctl_string(unsigned int ctl)
+{
+       static char buf[sizeof(int)*2 + 2];
+
+       switch (ctl) {
+#ifdef PR_UNALIGN_NOPRINT
+               case PR_UNALIGN_NOPRINT:
+                       return "NOPRINT";
+#endif
+#ifdef PR_UNALIGN_SIGBUS
+               case PR_UNALIGN_SIGBUS:
+                       return "SIGBUS";
+#endif
+               default:
+                       break;
+       }
+       sprintf(buf, "%x", ctl);
+       return buf;
+}
+
+int
+sys_prctl(struct tcb *tcp)
+{
+       unsigned int i;
+
+       if (entering(tcp)) {
+               printxval(prctl_options, tcp->u_arg[0], "PR_???");
+               switch (tcp->u_arg[0]) {
+#ifdef PR_GETNSHARE
+               case PR_GETNSHARE:
+                       break;
+#endif
+#ifdef PR_SET_PDEATHSIG
+               case PR_SET_PDEATHSIG:
+                       tprintf(", %lu", tcp->u_arg[1]);
+                       break;
+#endif
+#ifdef PR_GET_PDEATHSIG
+               case PR_GET_PDEATHSIG:
+                       break;
+#endif
+#ifdef PR_SET_DUMPABLE
+               case PR_SET_DUMPABLE:
+                       tprintf(", %lu", tcp->u_arg[1]);
+                       break;
+#endif
+#ifdef PR_GET_DUMPABLE
+               case PR_GET_DUMPABLE:
+                       break;
+#endif
+#ifdef PR_SET_UNALIGN
+               case PR_SET_UNALIGN:
+                       tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
+                       break;
+#endif
+#ifdef PR_GET_UNALIGN
+               case PR_GET_UNALIGN:
+                       tprintf(", %#lx", tcp->u_arg[1]);
+                       break;
+#endif
+#ifdef PR_SET_KEEPCAPS
+               case PR_SET_KEEPCAPS:
+                       tprintf(", %lu", tcp->u_arg[1]);
+                       break;
+#endif
+#ifdef PR_GET_KEEPCAPS
+               case PR_GET_KEEPCAPS:
+                       break;
+#endif
+               default:
+                       for (i = 1; i < tcp->s_ent->nargs; i++)
+                               tprintf(", %#lx", tcp->u_arg[i]);
+                       break;
+               }
+       } else {
+               switch (tcp->u_arg[0]) {
+#ifdef PR_GET_PDEATHSIG
+               case PR_GET_PDEATHSIG:
+                       if (umove(tcp, tcp->u_arg[1], &i) < 0)
+                               tprintf(", %#lx", tcp->u_arg[1]);
+                       else
+                               tprintf(", {%u}", i);
+                       break;
+#endif
+#ifdef PR_GET_DUMPABLE
+               case PR_GET_DUMPABLE:
+                       return RVAL_UDECIMAL;
+#endif
+#ifdef PR_GET_UNALIGN
+               case PR_GET_UNALIGN:
+                       if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
+                               break;
+                       tcp->auxstr = unalignctl_string(i);
+                       return RVAL_STR;
+#endif
+#ifdef PR_GET_KEEPCAPS
+               case PR_GET_KEEPCAPS:
+                       return RVAL_UDECIMAL;
+#endif
+               default:
+                       break;
+               }
+       }
+       return 0;
+}
+#endif /* HAVE_PRCTL */
+
+#if defined X86_64 || defined X32
+# include <asm/prctl.h>
+# include "xlat/archvals.h"
+
+int
+sys_arch_prctl(struct tcb *tcp)
+{
+       if (entering(tcp)) {
+               printxval(archvals, tcp->u_arg[0], "ARCH_???");
+               if (tcp->u_arg[0] == ARCH_SET_GS
+                || tcp->u_arg[0] == ARCH_SET_FS
+               ) {
+                       tprintf(", %#lx", tcp->u_arg[1]);
+               }
+       } else {
+               if (tcp->u_arg[0] == ARCH_GET_GS
+                || tcp->u_arg[0] == ARCH_GET_FS
+               ) {
+                       long int v;
+                       if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
+                               tprintf(", [%#lx]", v);
+                       else
+                               tprintf(", %#lx", tcp->u_arg[1]);
+               }
+       }
+       return 0;
+}
+#endif /* X86_64 || X32 */
index 648d9ba213ad09e579ae5cd78f13b165a6837036..28fbd42b26948f268f9325aa024ff83e9a2db9ef 100644 (file)
--- a/process.c
+++ b/process.c
 # include <asm/rse.h>
 #endif
 
-#ifdef HAVE_PRCTL
-# include <sys/prctl.h>
-
-#include "xlat/prctl_options.h"
-
-static const char *
-unalignctl_string(unsigned int ctl)
-{
-       static char buf[sizeof(int)*2 + 2];
-
-       switch (ctl) {
-#ifdef PR_UNALIGN_NOPRINT
-               case PR_UNALIGN_NOPRINT:
-                       return "NOPRINT";
-#endif
-#ifdef PR_UNALIGN_SIGBUS
-               case PR_UNALIGN_SIGBUS:
-                       return "SIGBUS";
-#endif
-               default:
-                       break;
-       }
-       sprintf(buf, "%x", ctl);
-       return buf;
-}
-
-int
-sys_prctl(struct tcb *tcp)
-{
-       unsigned int i;
-
-       if (entering(tcp)) {
-               printxval(prctl_options, tcp->u_arg[0], "PR_???");
-               switch (tcp->u_arg[0]) {
-#ifdef PR_GETNSHARE
-               case PR_GETNSHARE:
-                       break;
-#endif
-#ifdef PR_SET_PDEATHSIG
-               case PR_SET_PDEATHSIG:
-                       tprintf(", %lu", tcp->u_arg[1]);
-                       break;
-#endif
-#ifdef PR_GET_PDEATHSIG
-               case PR_GET_PDEATHSIG:
-                       break;
-#endif
-#ifdef PR_SET_DUMPABLE
-               case PR_SET_DUMPABLE:
-                       tprintf(", %lu", tcp->u_arg[1]);
-                       break;
-#endif
-#ifdef PR_GET_DUMPABLE
-               case PR_GET_DUMPABLE:
-                       break;
-#endif
-#ifdef PR_SET_UNALIGN
-               case PR_SET_UNALIGN:
-                       tprintf(", %s", unalignctl_string(tcp->u_arg[1]));
-                       break;
-#endif
-#ifdef PR_GET_UNALIGN
-               case PR_GET_UNALIGN:
-                       tprintf(", %#lx", tcp->u_arg[1]);
-                       break;
-#endif
-#ifdef PR_SET_KEEPCAPS
-               case PR_SET_KEEPCAPS:
-                       tprintf(", %lu", tcp->u_arg[1]);
-                       break;
-#endif
-#ifdef PR_GET_KEEPCAPS
-               case PR_GET_KEEPCAPS:
-                       break;
-#endif
-               default:
-                       for (i = 1; i < tcp->s_ent->nargs; i++)
-                               tprintf(", %#lx", tcp->u_arg[i]);
-                       break;
-               }
-       } else {
-               switch (tcp->u_arg[0]) {
-#ifdef PR_GET_PDEATHSIG
-               case PR_GET_PDEATHSIG:
-                       if (umove(tcp, tcp->u_arg[1], &i) < 0)
-                               tprintf(", %#lx", tcp->u_arg[1]);
-                       else
-                               tprintf(", {%u}", i);
-                       break;
-#endif
-#ifdef PR_GET_DUMPABLE
-               case PR_GET_DUMPABLE:
-                       return RVAL_UDECIMAL;
-#endif
-#ifdef PR_GET_UNALIGN
-               case PR_GET_UNALIGN:
-                       if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
-                               break;
-                       tcp->auxstr = unalignctl_string(i);
-                       return RVAL_STR;
-#endif
-#ifdef PR_GET_KEEPCAPS
-               case PR_GET_KEEPCAPS:
-                       return RVAL_UDECIMAL;
-#endif
-               default:
-                       break;
-               }
-       }
-       return 0;
-}
-#endif /* HAVE_PRCTL */
-
 int
 sys_sethostname(struct tcb *tcp)
 {
@@ -2480,33 +2367,3 @@ sys_sched_rr_get_interval(struct tcb *tcp)
        }
        return 0;
 }
-
-#if defined X86_64 || defined X32
-# include <asm/prctl.h>
-
-#include "xlat/archvals.h"
-
-int
-sys_arch_prctl(struct tcb *tcp)
-{
-       if (entering(tcp)) {
-               printxval(archvals, tcp->u_arg[0], "ARCH_???");
-               if (tcp->u_arg[0] == ARCH_SET_GS
-                || tcp->u_arg[0] == ARCH_SET_FS
-               ) {
-                       tprintf(", %#lx", tcp->u_arg[1]);
-               }
-       } else {
-               if (tcp->u_arg[0] == ARCH_GET_GS
-                || tcp->u_arg[0] == ARCH_GET_FS
-               ) {
-                       long int v;
-                       if (!syserror(tcp) && umove(tcp, tcp->u_arg[1], &v) != -1)
-                               tprintf(", [%#lx]", v);
-                       else
-                               tprintf(", %#lx", tcp->u_arg[1]);
-               }
-       }
-       return 0;
-}
-#endif /* X86_64 || X32 */