]> granicus.if.org Git - strace/blobdiff - proc.c
Add argument to tprint_iov() specifying whether to decode each iovec
[strace] / proc.c
diff --git a/proc.c b/proc.c
index d4969a6cbff2f8bcb2c3f7498a9dd315487142d0..1fe4890952f7bdbee7e7cc9651c0042b3fe53bcc 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -32,7 +32,7 @@
 #ifdef SVR4
 #ifndef HAVE_MP_PROCFS
 
-static struct xlat proc_status_flags[] = {
+static const struct xlat proc_status_flags[] = {
        { PR_STOPPED,   "PR_STOPPED"    },
        { PR_ISTOP,     "PR_ISTOP"      },
        { PR_DSTOP,     "PR_DSTOP"      },
@@ -57,7 +57,7 @@ static struct xlat proc_status_flags[] = {
        { 0,            NULL            },
 };
 
-static struct xlat proc_status_why[] = {
+static const struct xlat proc_status_why[] = {
        { PR_REQUESTED, "PR_REQUESTED"  },
        { PR_SIGNALLED, "PR_SIGNALLED"  },
        { PR_SYSENTRY,  "PR_SYSENTRY"   },
@@ -73,7 +73,7 @@ static struct xlat proc_status_why[] = {
        { 0,            NULL            },
 };
 
-static struct xlat proc_run_flags[] = {
+static const struct xlat proc_run_flags[] = {
        { PRCSIG,       "PRCSIG"        },
        { PRCFAULT,     "PRCFAULT"      },
        { PRSTRACE,     "PRSTRACE"      },
@@ -87,9 +87,7 @@ static struct xlat proc_run_flags[] = {
 };
 
 int
-proc_ioctl(tcp, code, arg)
-struct tcb *tcp;
-int code, arg;
+proc_ioctl(struct tcb *tcp, int code, int arg)
 {
        int val;
        prstatus_t status;
@@ -110,8 +108,7 @@ int code, arg;
                        tprintf(", {...}");
                else {
                        tprintf(", {pr_flags=");
-                       if (!printflags(proc_status_flags, status.pr_flags))
-                               tprintf("0");
+                       printflags(proc_status_flags, status.pr_flags, "PR_???");
                        if (status.pr_why) {
                                tprintf(", pr_why=");
                                printxval(proc_status_why, status.pr_why,
@@ -142,8 +139,7 @@ int code, arg;
                        tprintf(", {...}");
                else {
                        tprintf(", {pr_flags=");
-                       if (!printflags(proc_run_flags, run.pr_flags))
-                               tprintf("0");
+                       printflags(proc_run_flags, run.pr_flags, "PR???");
                        tprintf(", ...}");
                }
                return 1;
@@ -154,8 +150,7 @@ int code, arg;
                        tprintf(", [?]");
                else {
                        tprintf(", [");
-                       if (!printflags(proc_status_flags, val))
-                               tprintf("0");
+                       printflags(proc_status_flags, val, "PR_???");
                        tprintf("]");
                }
                return 1;
@@ -186,3 +181,76 @@ int code, arg;
 #endif /* HAVE_MP_PROCFS */
 #endif /* SVR4 */
 
+#ifdef FREEBSD
+#include <sys/pioctl.h>
+
+static const struct xlat proc_status_why[] = {
+       { S_EXEC,       "S_EXEC"        },
+       { S_SIG,        "S_SIG"         },
+       { S_SCE,        "S_SCE"         },
+       { S_SCX,        "S_SCX"         },
+       { S_CORE,       "S_CORE"        },
+       { S_EXIT,       "S_EXIT"        },
+       { 0,            NULL            }
+};
+
+static const struct xlat proc_status_flags[] = {
+       { PF_LINGER,    "PF_LINGER"     },
+       { PF_ISUGID,    "PF_ISUGID"     },
+       { 0,            NULL            }
+};
+
+int
+proc_ioctl(struct tcb *tcp, int code, int arg)
+{
+       int val;
+       struct procfs_status status;
+
+       if (entering(tcp))
+               return 0;
+
+       switch (code) {
+       case PIOCSTATUS:
+       case PIOCWAIT:
+               if (arg == 0)
+                       tprintf(", NULL");
+               else if (syserror(tcp))
+                       tprintf(", %x", arg);
+               else if (umove(tcp, arg, &status) < 0)
+                       tprintf(", {...}");
+               else {
+                       tprintf(", {state=%d, flags=", status.state);
+                       printflags(proc_status_flags, status.flags, "PF_???");
+                       tprintf(", events=");
+                       printflags(proc_status_why, status.events, "S_???");
+                       tprintf(", why=");
+                       printxval(proc_status_why, status.why, "S_???");
+                       tprintf(", val=%lu}", status.val);
+               }
+               return 1;
+       case PIOCBIS:
+               tprintf(", ");
+               printflags(proc_status_why, arg, "S_???");
+               return 1;
+               return 1;
+       case PIOCSFL:
+               tprintf(", ");
+               printflags(proc_status_flags, arg, "PF_???");
+               return 1;
+       case PIOCGFL:
+               if (syserror(tcp))
+                       tprintf(", %#x", arg);
+               else if (umove(tcp, arg, &val) < 0)
+                       tprintf(", {...}");
+               else {
+                       tprintf(", [");
+                       printflags(proc_status_flags, val, "PF_???");
+                       tprintf("]");
+               }
+               return 1;
+       default:
+               /* ad naseum */
+               return 0;
+       }
+}
+#endif