aboutsummaryrefslogtreecommitdiff
path: root/gdb/proc-flags.c
blob: c5c03f513a1cca46df733716de8a056cc91e55fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/* Machine independent support for SVR4 /proc (process file system) for GDB.
   Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
   Written by Michael Snyder at Cygnus Solutions.
   Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.

This file is part of GDB.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, 
Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.  */

/*
 * Pretty-print the prstatus flags.
 * 
 * Arguments: unsigned long flags, int verbose
 *
 */

#include "defs.h"

#if defined (NEW_PROC_API)
#define _STRUCTURED_PROC 1
#endif

#include <stdio.h>
#include <sys/types.h>
#include <sys/procfs.h>

/*  Much of the information used in the /proc interface, particularly for
    printing status information, is kept as tables of structures of the
    following form.  These tables can be used to map numeric values to
    their symbolic names and to a string that describes their specific use. */

struct trans {
  int value;                    /* The numeric value */
  char *name;                   /* The equivalent symbolic value */
  char *desc;                   /* Short description of value */
};

/* Translate bits in the pr_flags member of the prstatus structure,
   into the names and desc information. */

static struct trans pr_flag_table[] =
{
#if defined (PR_STOPPED)
  /* Sol2.5: lwp is stopped
   * Sol2.6: lwp is stopped
   * Sol2.7: lwp is stopped
   * IRIX6:  process is stopped
   * OSF:    task/thread is stopped
   * UW:     LWP is stopped
   */
  { PR_STOPPED, "PR_STOPPED", "Process (LWP) is stopped" },
#endif
#if defined (PR_ISTOP)
  /* Sol2.5: lwp is stopped on an event of interest
   * Sol2.6: lwp is stopped on an event of interest
   * Sol2.7: lwp is stopped on an event of interest
   * IRIX6:  process is stopped on event of interest
   * OSF:    task/thread stopped on event of interest
   * UW:     LWP stopped on an event of interest
   */
  { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" },
#endif
#if defined (PR_DSTOP)
  /* Sol2.5: lwp has a stop directive in effect
   * Sol2.6: lwp has a stop directive in effect
   * Sol2.7: lwp has a stop directive in effect
   * IRIX6:  process has stop directive in effect
   * OSF:    task/thread has stop directive in effect
   * UW:     A stop directive is in effect
   */
  { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" },
#endif
#if defined (PR_STEP)
  /* Sol2.5: lwp has a single-step directive in effect
   * Sol2.6: lwp has a single-step directive in effect
   * Sol2.7: lwp has a single-step directive in effect
   * IRIX6:  process has single step pending
   */
  { PR_STEP, "PR_STEP", "A single step directive is in effect" },
#endif
#if defined (PR_ASLEEP)
  /* Sol2.5: lwp is sleeping in a system call
   * Sol2.6: lwp is sleeping in a system call
   * Sol2.7: lwp is sleeping in a system call
   * IRIX6:  process is in an interruptible sleep
   * OSF:    task/thread is asleep within a system call
   * UW:     LWP is sleep()ing in a system call
   */
  { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an (interruptible) system call" },
#endif
#if defined (PR_PCINVAL)
  /* Sol2.5: contents of pr_instr undefined
   * Sol2.6: contents of pr_instr undefined
   * Sol2.7: contents of pr_instr undefined
   * IRIX6:  current pc is invalid
   * OSF:    program counter contains invalid address
   * UW:     %pc refers to an invalid virtual address
   */
  { PR_PCINVAL, "PR_PCINVAL", "PC (pr_instr) is invalid" },
#endif
#if defined (PR_ASLWP)
  /* Sol2.5: this lwp is the aslwp
   * Sol2.6: this lwp is the aslwp
   * Sol2.7: this lwp is the aslwp
   */
  { PR_ASLWP, "PR_ASLWP", "This is the asynchronous signal LWP" },
#endif
#if defined (PR_AGENT)
  /* Sol2.6: this lwp is the /proc agent lwp
   * Sol2.7: this lwp is the /proc agent lwp
   */
  { PR_AGENT, "PR_AGENT", "This is the /proc agent LWP" },
#endif
#if defined (PR_ISSYS)
  /* Sol2.5: system process
   * Sol2.6: this is a system process
   * Sol2.7: this is a system process
   * IRIX6:  process is a system process
   * OSF:    task/thread is a system task/thread
   * UW:     System process
   */
  { PR_ISSYS, "PR_ISSYS", "Is a system process/thread" },
#endif
#if defined (PR_VFORKP)
  /* Sol2.6: process is the parent of a vfork()d child
   * Sol2.7: process is the parent of a vfork()d child
   */
  { PR_VFORKP, "PR_VFORKP", "Process is the parent of a vforked child" },
#endif
#ifdef PR_ORPHAN
  /* Sol2.6: process's process group is orphaned
   * Sol2.7: process's process group is orphaned
   */
  { PR_ORPHAN, "PR_ORPHAN", "Process's process group is orphaned" },
#endif
#if defined (PR_FORK)
  /* Sol2.5: inherit-on-fork is in effect
   * Sol2.6: inherit-on-fork is in effect
   * Sol2.7: inherit-on-fork is in effect
   * IRIX6:  process has inherit-on-fork flag set
   * OSF:    task/thread has inherit-on-fork flag set
   * UW:     inherit-on-fork is in effect
   */
  { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" },
#endif
#if defined (PR_RLC)
  /* Sol2.5: run-on-last-close is in effect
   * Sol2.6: run-on-last-close is in effect
   * Sol2.7: run-on-last-close is in effect
   * IRIX6:  process has run-on-last-close flag set
   * OSF:    task/thread has run-on-last-close flag set
   * UW:     Run-on-last-close is in effect
   */
  { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" },
#endif
#if defined (PR_KLC)
  /* Sol2.5: kill-on-last-close is in effect
   * Sol2.6: kill-on-last-close is in effect
   * Sol2.7: kill-on-last-close is in effect
   * IRIX6:  process has kill-on-last-close flag set
   * OSF:    kill-on-last-close, superceeds RLC
   * UW:     kill-on-last-close is in effect
   */
  { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" },
#endif
#if defined (PR_ASYNC)
  /* Sol2.5: asynchronous-stop is in effect
   * Sol2.6: asynchronous-stop is in effect
   * Sol2.7: asynchronous-stop is in effect
   * OSF:    asynchronous stop mode is in effect
   * UW:     asynchronous stop mode is in effect
   */
  { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" },
#endif
#if defined (PR_MSACCT)
  /* Sol2.5: micro-state usage accounting is in effect
   * Sol2.6: micro-state usage accounting is in effect
   * Sol2.7: micro-state usage accounting is in effect
   */
  { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" },
#endif
#if defined (PR_BPTADJ)
  /* Sol2.5: breakpoint trap pc adjustment is in effect
   * Sol2.6: breakpoint trap pc adjustment is in effect
   * Sol2.7: breakpoint trap pc adjustment is in effect
   */
  { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" },
#endif
#if defined (PR_PTRACE)
  /* Note: different meanings on Solaris and Irix 6
   * Sol2.5: obsolete, never set in SunOS5.0
   * Sol2.6: ptrace-compatibility mode is in effect
   * Sol2.7: ptrace-compatibility mode is in effect
   * IRIX6:  process is traced with ptrace() too
   * OSF:    task/thread is being traced by ptrace
   * UW:     Process is being controlled by ptrace(2)
   */
  { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" },
#endif
#if defined (PR_PCOMPAT)
  /* Note: PCOMPAT on Sol2.5 means same thing as PTRACE on Sol2.6
   * Sol2.5 (only): ptrace-compatibility mode is in effect
   */
  { PR_PCOMPAT, "PR_PCOMPAT", "Ptrace compatibility mode in effect" },
#endif
#ifdef PR_MSFORK
  /* Sol2.6: micro-state accounting inherited on fork
   * Sol2.7: micro-state accounting inherited on fork
   */
  { PR_MSFORK, "PR_PCOMPAT", "Micro-state accounting inherited on fork" },
#endif

#ifdef PR_ISKTHREAD
  /* Irix6: process is a kernel thread */
  { PR_ISKTHREAD, "PR_KTHREAD", "Process is a kernel thread" },
#endif

#ifdef PR_ABORT
  /* OSF (only): abort the current stop condition */
  { PR_ABORT, "PR_ABORT", "Abort the current stop condition" },
#endif

#ifdef PR_TRACING
  /* OSF: task is traced */
  { PR_TRACING, "PR_TRACING", "Task is traced" },
#endif

#ifdef PR_STOPFORK
  /* OSF: stop child on fork */
  { PR_STOPFORK, "PR_STOPFORK", "Stop child on fork" },
#endif

#ifdef PR_STOPEXEC
  /* OSF: stop on exec */
  { PR_STOPEXEC, "PR_STOPEXEC", "Stop on exec" },
#endif

#ifdef PR_STOPTERM
  /* OSF: stop on task exit */
  { PR_STOPTERM, "PR_STOPTERM", "Stop on task exit" },
#endif

#ifdef PR_STOPTCR
  /* OSF: stop on thread creation */
  { PR_STOPTCR, "PR_STOPTCR", "Stop on thread creation" },
#endif

#ifdef PR_STOPTTERM
  /* OSF: stop on thread exit */
  { PR_STOPTTERM, "PR_STOPTTERM", "Stop on thread exit" },
#endif

#ifdef PR_USCHED
  /* OSF: user level scheduling is in effect */
  { PR_USCHED, "PR_USCHED", "User level scheduling is in effect" },
#endif
};

void
proc_prettyfprint_flags (FILE *file, unsigned long flags, int verbose)
{
  int i;

  for (i = 0; i < sizeof (pr_flag_table) / sizeof (pr_flag_table[0]); i++)
    if (flags & pr_flag_table[i].value)
      {
	fprintf (file, "%s ", pr_flag_table[i].name);
	if (verbose)
	  fprintf (file, "%s\n", pr_flag_table[i].desc);
      }
  if (!verbose)
    fprintf (file, "\n");
}

void
proc_prettyprint_flags (unsigned long flags, int verbose)
{
  proc_prettyfprint_flags (stdout, flags, verbose);
}