1 /* Machine-independent support for SVR4 /proc (process file system)
3 Copyright 1999, 2000, 2004 Free Software Foundation, Inc.
5 Written by Michael Snyder at Cygnus Solutions.
6 Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
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 2 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 #define _STRUCTURED_PROC 1
30 #include <sys/types.h>
31 #include <sys/procfs.h>
33 #include "proc-utils.h"
35 /* Much of the information used in the /proc interface, particularly
36 for printing status information, is kept as tables of structures of
37 the following form. These tables can be used to map numeric values
38 to their symbolic names and to a string that describes their
43 int value
; /* The numeric value. */
44 char *name
; /* The equivalent symbolic value. */
45 char *desc
; /* Short description of value. */
48 /* Translate values in the pr_why field of a `struct prstatus' or
49 `struct lwpstatus'. */
51 static struct trans pr_why_table
[] =
53 #if defined (PR_REQUESTED)
55 { PR_REQUESTED
, "PR_REQUESTED",
56 "Directed to stop by debugger via P(IO)CSTOP or P(IO)CWSTOP" },
58 #if defined (PR_SIGNALLED)
60 { PR_SIGNALLED
, "PR_SIGNALLED", "Receipt of a traced signal" },
62 #if defined (PR_SYSENTRY)
64 { PR_SYSENTRY
, "PR_SYSENTRY", "Entry to a traced system call" },
66 #if defined (PR_SYSEXIT)
68 { PR_SYSEXIT
, "PR_SYSEXIT", "Exit from a traced system call" },
70 #if defined (PR_JOBCONTROL)
72 { PR_JOBCONTROL
, "PR_JOBCONTROL", "Default job control stop signal action" },
74 #if defined (PR_FAULTED)
76 { PR_FAULTED
, "PR_FAULTED", "Incurred a traced hardware fault" },
78 #if defined (PR_SUSPENDED)
79 /* Solaris and UnixWare. */
80 { PR_SUSPENDED
, "PR_SUSPENDED", "Process suspended" },
82 #if defined (PR_CHECKPOINT)
84 { PR_CHECKPOINT
, "PR_CHECKPOINT", "Process stopped at checkpoint" },
86 #if defined (PR_FORKSTOP)
88 { PR_FORKSTOP
, "PR_FORKSTOP", "Process stopped at end of fork call" },
90 #if defined (PR_TCRSTOP)
92 { PR_TCRSTOP
, "PR_TCRSTOP", "Process stopped on thread creation" },
94 #if defined (PR_TTSTOP)
96 { PR_TTSTOP
, "PR_TTSTOP", "Process stopped on thread termination" },
100 { PR_DEAD
, "PR_DEAD", "Process stopped in exit system call" },
104 /* Pretty-print the pr_why field of a `struct prstatus' or `struct
108 proc_prettyfprint_why (FILE *file
, unsigned long why
, unsigned long what
,
116 for (i
= 0; i
< ARRAY_SIZE (pr_why_table
); i
++)
117 if (why
== pr_why_table
[i
].value
)
119 fprintf (file
, "%s ", pr_why_table
[i
].name
);
121 fprintf (file
, ": %s ", pr_why_table
[i
].desc
);
126 break; /* Nothing more to print. */
130 proc_prettyfprint_signal (file
, what
, verbose
);
135 proc_prettyfprint_fault (file
, what
, verbose
);
140 fprintf (file
, "Entry to ");
141 proc_prettyfprint_syscall (file
, what
, verbose
);
146 fprintf (file
, "Exit from ");
147 proc_prettyfprint_syscall (file
, what
, verbose
);
152 proc_prettyfprint_signal (file
, what
, verbose
);
157 fprintf (file
, "Exit status: %ld\n", what
);
161 fprintf (file
, "Unknown why %ld, what %ld\n", why
, what
);
164 fprintf (file
, "\n");
169 fprintf (file
, "Unknown pr_why.\n");
173 proc_prettyprint_why (unsigned long why
, unsigned long what
, int verbose
)
175 proc_prettyfprint_why (stdout
, why
, what
, verbose
);
This page took 0.03507 seconds and 4 git commands to generate.