]>
Commit | Line | Data |
---|---|---|
c3f6f71d JM |
1 | /* |
2 | * Pretty-print the prstatus flags. | |
3 | * | |
4 | * Arguments: unsigned long flags, int verbose | |
5 | * | |
6 | */ | |
7 | ||
8 | #include "defs.h" | |
9 | ||
10 | #if defined (NEW_PROC_API) | |
11 | #define _STRUCTURED_PROC 1 | |
12 | #endif | |
13 | ||
14 | #include <stdio.h> | |
15 | #include <sys/types.h> | |
16 | #include <sys/procfs.h> | |
17 | ||
18 | /* Much of the information used in the /proc interface, particularly for | |
19 | printing status information, is kept as tables of structures of the | |
20 | following form. These tables can be used to map numeric values to | |
21 | their symbolic names and to a string that describes their specific use. */ | |
22 | ||
23 | struct trans { | |
24 | int value; /* The numeric value */ | |
25 | char *name; /* The equivalent symbolic value */ | |
26 | char *desc; /* Short description of value */ | |
27 | }; | |
28 | ||
29 | /* Translate bits in the pr_flags member of the prstatus structure, | |
30 | into the names and desc information. */ | |
31 | ||
32 | static struct trans pr_flag_table[] = | |
33 | { | |
34 | #if defined (PR_STOPPED) | |
35 | /* Sol2.5: lwp is stopped | |
36 | * Sol2.6: lwp is stopped | |
37 | * Sol2.7: lwp is stopped | |
38 | * IRIX6: process is stopped | |
39 | * OSF: task/thread is stopped | |
40 | * UW: LWP is stopped | |
41 | */ | |
42 | { PR_STOPPED, "PR_STOPPED", "Process (LWP) is stopped" }, | |
43 | #endif | |
44 | #if defined (PR_ISTOP) | |
45 | /* Sol2.5: lwp is stopped on an event of interest | |
46 | * Sol2.6: lwp is stopped on an event of interest | |
47 | * Sol2.7: lwp is stopped on an event of interest | |
48 | * IRIX6: process is stopped on event of interest | |
49 | * OSF: task/thread stopped on event of interest | |
50 | * UW: LWP stopped on an event of interest | |
51 | */ | |
52 | { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" }, | |
53 | #endif | |
54 | #if defined (PR_DSTOP) | |
55 | /* Sol2.5: lwp has a stop directive in effect | |
56 | * Sol2.6: lwp has a stop directive in effect | |
57 | * Sol2.7: lwp has a stop directive in effect | |
58 | * IRIX6: process has stop directive in effect | |
59 | * OSF: task/thread has stop directive in effect | |
60 | * UW: A stop directive is in effect | |
61 | */ | |
62 | { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" }, | |
63 | #endif | |
64 | #if defined (PR_STEP) | |
65 | /* Sol2.5: lwp has a single-step directive in effect | |
66 | * Sol2.6: lwp has a single-step directive in effect | |
67 | * Sol2.7: lwp has a single-step directive in effect | |
68 | * IRIX6: process has single step pending | |
69 | */ | |
70 | { PR_STEP, "PR_STEP", "A single step directive is in effect" }, | |
71 | #endif | |
72 | #if defined (PR_ASLEEP) | |
73 | /* Sol2.5: lwp is sleeping in a system call | |
74 | * Sol2.6: lwp is sleeping in a system call | |
75 | * Sol2.7: lwp is sleeping in a system call | |
76 | * IRIX6: process is in an interruptible sleep | |
77 | * OSF: task/thread is asleep within a system call | |
78 | * UW: LWP is sleep()ing in a system call | |
79 | */ | |
80 | { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an (interruptible) system call" }, | |
81 | #endif | |
82 | #if defined (PR_PCINVAL) | |
83 | /* Sol2.5: contents of pr_instr undefined | |
84 | * Sol2.6: contents of pr_instr undefined | |
85 | * Sol2.7: contents of pr_instr undefined | |
86 | * IRIX6: current pc is invalid | |
87 | * OSF: program counter contains invalid address | |
88 | * UW: %pc refers to an invalid virtual address | |
89 | */ | |
90 | { PR_PCINVAL, "PR_PCINVAL", "PC (pr_instr) is invalid" }, | |
91 | #endif | |
92 | #if defined (PR_ASLWP) | |
93 | /* Sol2.5: this lwp is the aslwp | |
94 | * Sol2.6: this lwp is the aslwp | |
95 | * Sol2.7: this lwp is the aslwp | |
96 | */ | |
97 | { PR_ASLWP, "PR_ASLWP", "This is the asynchronous signal LWP" }, | |
98 | #endif | |
99 | #if defined (PR_AGENT) | |
100 | /* Sol2.6: this lwp is the /proc agent lwp | |
101 | * Sol2.7: this lwp is the /proc agent lwp | |
102 | */ | |
103 | { PR_AGENT, "PR_AGENT", "This is the /proc agent LWP" }, | |
104 | #endif | |
105 | #if defined (PR_ISSYS) | |
106 | /* Sol2.5: system process | |
107 | * Sol2.6: this is a system process | |
108 | * Sol2.7: this is a system process | |
109 | * IRIX6: process is a system process | |
110 | * OSF: task/thread is a system task/thread | |
111 | * UW: System process | |
112 | */ | |
113 | { PR_ISSYS, "PR_ISSYS", "Is a system process/thread" }, | |
114 | #endif | |
115 | #if defined (PR_VFORKP) | |
116 | /* Sol2.6: process is the parent of a vfork()d child | |
117 | * Sol2.7: process is the parent of a vfork()d child | |
118 | */ | |
119 | { PR_VFORKP, "PR_VFORKP", "Process is the parent of a vforked child" }, | |
120 | #endif | |
121 | #ifdef PR_ORPHAN | |
122 | /* Sol2.6: process's process group is orphaned | |
123 | * Sol2.7: process's process group is orphaned | |
124 | */ | |
125 | { PR_ORPHAN, "PR_ORPHAN", "Process's process group is orphaned" }, | |
126 | #endif | |
127 | #if defined (PR_FORK) | |
128 | /* Sol2.5: inherit-on-fork is in effect | |
129 | * Sol2.6: inherit-on-fork is in effect | |
130 | * Sol2.7: inherit-on-fork is in effect | |
131 | * IRIX6: process has inherit-on-fork flag set | |
132 | * OSF: task/thread has inherit-on-fork flag set | |
133 | * UW: inherit-on-fork is in effect | |
134 | */ | |
135 | { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" }, | |
136 | #endif | |
137 | #if defined (PR_RLC) | |
138 | /* Sol2.5: run-on-last-close is in effect | |
139 | * Sol2.6: run-on-last-close is in effect | |
140 | * Sol2.7: run-on-last-close is in effect | |
141 | * IRIX6: process has run-on-last-close flag set | |
142 | * OSF: task/thread has run-on-last-close flag set | |
143 | * UW: Run-on-last-close is in effect | |
144 | */ | |
145 | { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" }, | |
146 | #endif | |
147 | #if defined (PR_KLC) | |
148 | /* Sol2.5: kill-on-last-close is in effect | |
149 | * Sol2.6: kill-on-last-close is in effect | |
150 | * Sol2.7: kill-on-last-close is in effect | |
151 | * IRIX6: process has kill-on-last-close flag set | |
152 | * OSF: kill-on-last-close, superceeds RLC | |
153 | * UW: kill-on-last-close is in effect | |
154 | */ | |
155 | { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" }, | |
156 | #endif | |
157 | #if defined (PR_ASYNC) | |
158 | /* Sol2.5: asynchronous-stop is in effect | |
159 | * Sol2.6: asynchronous-stop is in effect | |
160 | * Sol2.7: asynchronous-stop is in effect | |
161 | * OSF: asynchronous stop mode is in effect | |
162 | * UW: asynchronous stop mode is in effect | |
163 | */ | |
164 | { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" }, | |
165 | #endif | |
166 | #if defined (PR_MSACCT) | |
167 | /* Sol2.5: micro-state usage accounting is in effect | |
168 | * Sol2.6: micro-state usage accounting is in effect | |
169 | * Sol2.7: micro-state usage accounting is in effect | |
170 | */ | |
171 | { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" }, | |
172 | #endif | |
173 | #if defined (PR_BPTADJ) | |
174 | /* Sol2.5: breakpoint trap pc adjustment is in effect | |
175 | * Sol2.6: breakpoint trap pc adjustment is in effect | |
176 | * Sol2.7: breakpoint trap pc adjustment is in effect | |
177 | */ | |
178 | { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" }, | |
179 | #endif | |
180 | #if defined (PR_PTRACE) | |
181 | /* Note: different meanings on Solaris and Irix 6 | |
182 | * Sol2.5: obsolete, never set in SunOS5.0 | |
183 | * Sol2.6: ptrace-compatibility mode is in effect | |
184 | * Sol2.7: ptrace-compatibility mode is in effect | |
185 | * IRIX6: process is traced with ptrace() too | |
186 | * OSF: task/thread is being traced by ptrace | |
187 | * UW: Process is being controlled by ptrace(2) | |
188 | */ | |
189 | { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" }, | |
190 | #endif | |
191 | #if defined (PR_PCOMPAT) | |
192 | /* Note: PCOMPAT on Sol2.5 means same thing as PTRACE on Sol2.6 | |
193 | * Sol2.5 (only): ptrace-compatibility mode is in effect | |
194 | */ | |
195 | { PR_PCOMPAT, "PR_PCOMPAT", "Ptrace compatibility mode in effect" }, | |
196 | #endif | |
197 | #ifdef PR_MSFORK | |
198 | /* Sol2.6: micro-state accounting inherited on fork | |
199 | * Sol2.7: micro-state accounting inherited on fork | |
200 | */ | |
201 | { PR_MSFORK, "PR_PCOMPAT", "Micro-state accounting inherited on fork" }, | |
202 | #endif | |
203 | ||
204 | #ifdef PR_ISKTHREAD | |
205 | /* Irix6: process is a kernel thread */ | |
206 | { PR_ISKTHREAD, "PR_KTHREAD", "Process is a kernel thread" }, | |
207 | #endif | |
208 | ||
209 | #ifdef PR_ABORT | |
210 | /* OSF (only): abort the current stop condition */ | |
211 | { PR_ABORT, "PR_ABORT", "Abort the current stop condition" }, | |
212 | #endif | |
213 | ||
214 | #ifdef PR_TRACING | |
215 | /* OSF: task is traced */ | |
216 | { PR_TRACING, "PR_TRACING", "Task is traced" }, | |
217 | #endif | |
218 | ||
219 | #ifdef PR_STOPFORK | |
220 | /* OSF: stop child on fork */ | |
221 | { PR_STOPFORK, "PR_STOPFORK", "Stop child on fork" }, | |
222 | #endif | |
223 | ||
224 | #ifdef PR_STOPEXEC | |
225 | /* OSF: stop on exec */ | |
226 | { PR_STOPEXEC, "PR_STOPEXEC", "Stop on exec" }, | |
227 | #endif | |
228 | ||
229 | #ifdef PR_STOPTERM | |
230 | /* OSF: stop on task exit */ | |
231 | { PR_STOPTERM, "PR_STOPTERM", "Stop on task exit" }, | |
232 | #endif | |
233 | ||
234 | #ifdef PR_STOPTCR | |
235 | /* OSF: stop on thread creation */ | |
236 | { PR_STOPTCR, "PR_STOPTCR", "Stop on thread creation" }, | |
237 | #endif | |
238 | ||
239 | #ifdef PR_STOPTTERM | |
240 | /* OSF: stop on thread exit */ | |
241 | { PR_STOPTTERM, "PR_STOPTTERM", "Stop on thread exit" }, | |
242 | #endif | |
243 | ||
244 | #ifdef PR_USCHED | |
245 | /* OSF: user level scheduling is in effect */ | |
246 | { PR_USCHED, "PR_USCHED", "User level scheduling is in effect" }, | |
247 | #endif | |
248 | }; | |
249 | ||
250 | void | |
251 | proc_prettyfprint_flags (file, flags, verbose) | |
252 | FILE *file; | |
253 | unsigned long flags; | |
254 | int verbose; | |
255 | { | |
256 | int i; | |
257 | ||
258 | for (i = 0; i < sizeof (pr_flag_table) / sizeof (pr_flag_table[0]); i++) | |
259 | if (flags & pr_flag_table[i].value) | |
260 | { | |
261 | fprintf (file, "%s ", pr_flag_table[i].name); | |
262 | if (verbose) | |
263 | fprintf (file, "%s\n", pr_flag_table[i].desc); | |
264 | } | |
265 | if (!verbose) | |
266 | fprintf (file, "\n"); | |
267 | } | |
268 | ||
269 | void | |
270 | proc_prettyprint_flags (flags, verbose) | |
271 | unsigned long flags; | |
272 | int verbose; | |
273 | { | |
274 | proc_prettyfprint_flags (stdout, flags, verbose); | |
275 | } |