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