2 * Copyright (c) 1993, 1994, 1995 Rick Sladkey <jrs@world.std.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef HAVE_MP_PROCFS
35 static const struct xlat proc_status_flags[] = {
36 { PR_STOPPED, "PR_STOPPED" },
37 { PR_ISTOP, "PR_ISTOP" },
38 { PR_DSTOP, "PR_DSTOP" },
39 { PR_ASLEEP, "PR_ASLEEP" },
40 { PR_FORK, "PR_FORK" },
42 { PR_PTRACE, "PR_PTRACE" },
43 { PR_PCINVAL, "PR_PCINVAL" },
44 { PR_ISSYS, "PR_ISSYS" },
46 { PR_STEP, "PR_STEP" },
52 { PR_ASYNC, "PR_ASYNC" },
55 { PR_PCOMPAT, "PR_PCOMPAT" },
60 static const struct xlat proc_status_why[] = {
61 { PR_REQUESTED, "PR_REQUESTED" },
62 { PR_SIGNALLED, "PR_SIGNALLED" },
63 { PR_SYSENTRY, "PR_SYSENTRY" },
64 { PR_SYSEXIT, "PR_SYSEXIT" },
65 { PR_JOBCONTROL,"PR_JOBCONTROL" },
66 { PR_FAULTED, "PR_FAULTED" },
68 { PR_SUSPENDED, "PR_SUSPENDED" },
71 { PR_CHECKPOINT,"PR_CHECKPOINT" },
76 static const struct xlat proc_run_flags[] = {
78 { PRCFAULT, "PRCFAULT" },
79 { PRSTRACE, "PRSTRACE" },
80 { PRSHOLD, "PRSHOLD" },
81 { PRSFAULT, "PRSFAULT" },
82 { PRSVADDR, "PRSVADDR" },
84 { PRSABORT, "PRSABORT" },
90 proc_ioctl(struct tcb *tcp, int code, int arg)
105 else if (syserror(tcp))
106 tprintf(", %#x", arg);
107 else if (umove(tcp, arg, &status) < 0)
110 tprintf(", {pr_flags=");
111 printflags(proc_status_flags, status.pr_flags, "PR_???");
113 tprintf(", pr_why=");
114 printxval(proc_status_why, status.pr_why,
117 switch (status.pr_why) {
120 tprintf(", pr_what=");
121 printsignal(status.pr_what);
124 tprintf(", pr_what=%d", status.pr_what);
128 tprintf(", pr_what=SYS_%s",
129 sysent[status.pr_what].sys_name);
138 else if (umove(tcp, arg, &run) < 0)
141 tprintf(", {pr_flags=");
142 printflags(proc_run_flags, run.pr_flags, "PR???");
149 if (umove(tcp, arg, &val) < 0)
153 printflags(proc_status_flags, val, "PR_???");
160 /* takes a pointer to a signal */
161 if (umove(tcp, arg, &val) < 0)
173 /* doesn't take an arg */
181 #endif /* HAVE_MP_PROCFS */
185 #include <sys/pioctl.h>
187 static const struct xlat proc_status_why[] = {
188 { S_EXEC, "S_EXEC" },
192 { S_CORE, "S_CORE" },
193 { S_EXIT, "S_EXIT" },
197 static const struct xlat proc_status_flags[] = {
198 { PF_LINGER, "PF_LINGER" },
199 { PF_ISUGID, "PF_ISUGID" },
204 proc_ioctl(struct tcb *tcp, int code, int arg)
207 struct procfs_status status;
217 else if (syserror(tcp))
218 tprintf(", %x", arg);
219 else if (umove(tcp, arg, &status) < 0)
222 tprintf(", {state=%d, flags=", status.state);
223 printflags(proc_status_flags, status.flags, "PF_???");
224 tprintf(", events=");
225 printflags(proc_status_why, status.events, "S_???");
227 printxval(proc_status_why, status.why, "S_???");
228 tprintf(", val=%lu}", status.val);
233 printflags(proc_status_why, arg, "S_???");
238 printflags(proc_status_flags, arg, "PF_???");
242 tprintf(", %#x", arg);
243 else if (umove(tcp, arg, &val) < 0)
247 printflags(proc_status_flags, val, "PF_???");