1 /* Machine-independent support for SVR4 /proc (process file system)
3 Copyright (C) 1999, 2000, 2004, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
6 Written by Michael Snyder at Cygnus Solutions.
7 Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #define _STRUCTURED_PROC 1
29 #include <sys/types.h>
30 #include <sys/procfs.h>
32 #include "proc-utils.h"
34 /* Much of the information used in the /proc interface, particularly
35 for printing status information, is kept as tables of structures of
36 the following form. These tables can be used to map numeric values
37 to their symbolic names and to a string that describes their
42 int value
; /* The numeric value. */
43 char *name
; /* The equivalent symbolic value. */
44 char *desc
; /* Short description of value. */
47 /* Translate values in the pr_why field of a `struct prstatus' or
48 `struct lwpstatus'. */
50 static struct trans pr_why_table
[] =
52 #if defined (PR_REQUESTED)
54 { PR_REQUESTED
, "PR_REQUESTED",
55 "Directed to stop by debugger via P(IO)CSTOP or P(IO)CWSTOP" },
57 #if defined (PR_SIGNALLED)
59 { PR_SIGNALLED
, "PR_SIGNALLED", "Receipt of a traced signal" },
61 #if defined (PR_SYSENTRY)
63 { PR_SYSENTRY
, "PR_SYSENTRY", "Entry to a traced system call" },
65 #if defined (PR_SYSEXIT)
67 { PR_SYSEXIT
, "PR_SYSEXIT", "Exit from a traced system call" },
69 #if defined (PR_JOBCONTROL)
71 { PR_JOBCONTROL
, "PR_JOBCONTROL", "Default job control stop signal action" },
73 #if defined (PR_FAULTED)
75 { PR_FAULTED
, "PR_FAULTED", "Incurred a traced hardware fault" },
77 #if defined (PR_SUSPENDED)
78 /* Solaris and UnixWare. */
79 { PR_SUSPENDED
, "PR_SUSPENDED", "Process suspended" },
81 #if defined (PR_CHECKPOINT)
83 { PR_CHECKPOINT
, "PR_CHECKPOINT", "Process stopped at checkpoint" },
85 #if defined (PR_FORKSTOP)
87 { PR_FORKSTOP
, "PR_FORKSTOP", "Process stopped at end of fork call" },
89 #if defined (PR_TCRSTOP)
91 { PR_TCRSTOP
, "PR_TCRSTOP", "Process stopped on thread creation" },
93 #if defined (PR_TTSTOP)
95 { PR_TTSTOP
, "PR_TTSTOP", "Process stopped on thread termination" },
99 { PR_DEAD
, "PR_DEAD", "Process stopped in exit system call" },
103 /* Pretty-print the pr_why field of a `struct prstatus' or `struct
107 proc_prettyfprint_why (FILE *file
, unsigned long why
, unsigned long what
,
115 for (i
= 0; i
< ARRAY_SIZE (pr_why_table
); i
++)
116 if (why
== pr_why_table
[i
].value
)
118 fprintf (file
, "%s ", pr_why_table
[i
].name
);
120 fprintf (file
, ": %s ", pr_why_table
[i
].desc
);
125 break; /* Nothing more to print. */
129 proc_prettyfprint_signal (file
, what
, verbose
);
134 proc_prettyfprint_fault (file
, what
, verbose
);
139 fprintf (file
, "Entry to ");
140 proc_prettyfprint_syscall (file
, what
, verbose
);
145 fprintf (file
, "Exit from ");
146 proc_prettyfprint_syscall (file
, what
, verbose
);
151 proc_prettyfprint_signal (file
, what
, verbose
);
156 fprintf (file
, "Exit status: %ld\n", what
);
160 fprintf (file
, "Unknown why %ld, what %ld\n", why
, what
);
163 fprintf (file
, "\n");
168 fprintf (file
, "Unknown pr_why.\n");
172 proc_prettyprint_why (unsigned long why
, unsigned long what
, int verbose
)
174 proc_prettyfprint_why (stdout
, why
, what
, verbose
);
This page took 0.03451 seconds and 4 git commands to generate.