blob: 6e110fd483cdd51c78bf77df75b8ca0c498cff4d [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1993, 1994, 1995 Rick Sladkey <jrs@world.std.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
15 *
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.
26 *
27 * $Id$
28 */
29
30#include "defs.h"
31
32#ifdef SVR4
33
34static struct xlat proc_status_flags[] = {
35 { PR_STOPPED, "PR_STOPPED" },
36 { PR_ISTOP, "PR_ISTOP" },
37 { PR_DSTOP, "PR_DSTOP" },
38 { PR_ASLEEP, "PR_ASLEEP" },
39 { PR_FORK, "PR_FORK" },
40 { PR_RLC, "PR_RLC" },
41 { PR_PTRACE, "PR_PTRACE" },
42 { PR_PCINVAL, "PR_PCINVAL" },
43 { PR_ISSYS, "PR_ISSYS" },
44#ifdef PR_STEP
45 { PR_STEP, "PR_STEP" },
46#endif
47#ifdef PR_KLC
48 { PR_KLC, "PR_KLC" },
49#endif
50#ifdef PR_ASYNC
51 { PR_ASYNC, "PR_ASYNC" },
52#endif
53#ifdef PR_PCOMPAT
54 { PR_PCOMPAT, "PR_PCOMPAT" },
55#endif
56 { 0, NULL },
57};
58
59static struct xlat proc_status_why[] = {
60 { PR_REQUESTED, "PR_REQUESTED" },
61 { PR_SIGNALLED, "PR_SIGNALLED" },
62 { PR_SYSENTRY, "PR_SYSENTRY" },
63 { PR_SYSEXIT, "PR_SYSEXIT" },
64 { PR_JOBCONTROL,"PR_JOBCONTROL" },
65 { PR_FAULTED, "PR_FAULTED" },
66#ifdef PR_SUSPENDED
67 { PR_SUSPENDED, "PR_SUSPENDED" },
68#endif
69#ifdef PR_CHECKPOINT
70 { PR_CHECKPOINT,"PR_CHECKPOINT" },
71#endif
72 { 0, NULL },
73};
74
75static struct xlat proc_run_flags[] = {
76 { PRCSIG, "PRCSIG" },
77 { PRCFAULT, "PRCFAULT" },
78 { PRSTRACE, "PRSTRACE" },
79 { PRSHOLD, "PRSHOLD" },
80 { PRSFAULT, "PRSFAULT" },
81 { PRSVADDR, "PRSVADDR" },
82 { PRSTEP, "PRSTEP" },
83 { PRSABORT, "PRSABORT" },
84 { PRSTOP, "PRSTOP" },
85 { 0, NULL },
86};
87
88#if 0
89
90static struct xlat proc_map_flags[] = {
91 { MA_READ, "MA_READ" },
92 { MA_WRITE, "MA_WRITE" },
93 { MA_EXEC, "MA_EXEC" },
94 { MA_SHARED, "MA_SHARED" },
95 { MA_BREAK, "MA_BREAK" },
96 { MA_STACK, "MA_STACK" },
97 { 0, NULL },
98};
99
100static struct xlat proc_page_flags[] = {
101 { PG_REFERENCED,"PG_REFERENCED" },
102 { PG_MODIFIED, "PG_MODIFIED" },
103 { PG_HWMAPPED, "PG_HWMAPPED" },
104 { 0, NULL },
105};
106
107#ifdef SPARC
108
109static struct xlat proc_regs[] = {
110 { R_G0, "R_G0" },
111 { R_G1, "R_G1" },
112 { R_G2, "R_G2" },
113 { R_G3, "R_G3" },
114 { R_G4, "R_G4" },
115 { R_G5, "R_G5" },
116 { R_G6, "R_G6" },
117 { R_G7, "R_G7" },
118 { R_O0, "R_O0" },
119 { R_O1, "R_O1" },
120 { R_O2, "R_O2" },
121 { R_O3, "R_O3" },
122 { R_O4, "R_O4" },
123 { R_O5, "R_O5" },
124 { R_O6, "R_O6" },
125 { R_O7, "R_O7" },
126 { R_L0, "R_L0" },
127 { R_L1, "R_L1" },
128 { R_L2, "R_L2" },
129 { R_L3, "R_L3" },
130 { R_L4, "R_L4" },
131 { R_L5, "R_L5" },
132 { R_L6, "R_L6" },
133 { R_L7, "R_L7" },
134 { R_I0, "R_I0" },
135 { R_I1, "R_I1" },
136 { R_I2, "R_I2" },
137 { R_I3, "R_I3" },
138 { R_I4, "R_I4" },
139 { R_I5, "R_I5" },
140 { R_I6, "R_I6" },
141 { R_I7, "R_I7" },
142 { R_PSR, "R_PSR" },
143 { R_PC, "R_PC" },
144 { R_nPC, "R_nPC" },
145 { R_Y, "R_Y" },
146 { R_WIM, "R_WIM" },
147 { R_TBR, "R_TBR" },
148 { 0, NULL },
149};
150
151#endif /* SPARC */
152
153#endif /* 0 */
154
155int
156proc_ioctl(tcp, code, arg)
157struct tcb *tcp;
158int code, arg;
159{
160 int val;
161 prstatus_t status;
162 prrun_t run;
163
164 if (entering(tcp))
165 return 0;
166
167 switch (code) {
168 case PIOCSTATUS:
169 case PIOCSTOP:
170 case PIOCWSTOP:
171 if (arg == 0)
172 tprintf(", NULL");
173 else if (syserror(tcp))
174 tprintf(", %#x", arg);
175 else if (umove(tcp, arg, &status) < 0)
176 tprintf(", {...}");
177 else {
178 tprintf(", {pr_flags=");
179 if (!printflags(proc_status_flags, status.pr_flags))
180 tprintf("0");
181 if (status.pr_why) {
182 tprintf(", pr_why=");
183 printxval(proc_status_why, status.pr_why,
184 "PR_???");
185 }
186 switch (status.pr_why) {
187 case PR_SIGNALLED:
188 case PR_JOBCONTROL:
189 tprintf(", pr_what=");
190 printsignal(status.pr_what);
191 break;
192 case PR_FAULTED:
193 tprintf(", pr_what=%d", status.pr_what);
194 break;
195 case PR_SYSENTRY:
196 case PR_SYSEXIT:
197 tprintf(", pr_what=SYS_%s",
198 sysent[status.pr_what].sys_name);
199 break;
200 }
201 tprintf(", ...}");
202 }
203 return 1;
204 case PIOCRUN:
205 if (arg == 0)
206 tprintf(", NULL");
207 else if (umove(tcp, arg, &run) < 0)
208 tprintf(", {...}");
209 else {
210 tprintf(", {pr_flags=");
211 if (!printflags(proc_run_flags, run.pr_flags))
212 tprintf("0");
213 tprintf(", ...}");
214 }
215 return 1;
216#ifdef PIOCSET
217 case PIOCSET:
218 case PIOCRESET:
219 if (umove(tcp, arg, &val) < 0)
220 tprintf(", [?]");
221 else {
222 tprintf(", [");
223 if (!printflags(proc_status_flags, val))
224 tprintf("0");
225 tprintf("]");
226 }
227 return 1;
228#endif /* PIOCSET */
229 case PIOCKILL:
230 case PIOCUNKILL:
231 /* takes a pointer to a signal */
232 if (umove(tcp, arg, &val) < 0)
233 tprintf(", [?]");
234 else {
235 tprintf(", [");
236 printsignal(val);
237 tprintf("]");
238 }
239 return 1;
240 case PIOCSFORK:
241 case PIOCRFORK:
242 case PIOCSRLC:
243 case PIOCRRLC:
244 /* doesn't take an arg */
245 return 1;
246 default:
247 /* ad naseum */
248 return 0;
249 }
250}
251
252#endif /* SVR4 */