Commit | Line | Data |
---|---|---|
44122162 | 1 | /* Machine-independent support for Solaris /proc (process file system) |
0fda6bd2 | 2 | |
b811d2c2 | 3 | Copyright (C) 1999-2020 Free Software Foundation, Inc. |
0fda6bd2 | 4 | |
7a952542 MK |
5 | Written by Michael Snyder at Cygnus Solutions. |
6 | Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others. | |
0fda6bd2 | 7 | |
7a952542 MK |
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 | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
7a952542 | 11 | (at your option) any later version. |
0fda6bd2 | 12 | |
7a952542 MK |
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. | |
0fda6bd2 | 17 | |
7a952542 | 18 | You should have received a copy of the GNU General Public License |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0fda6bd2 JM |
20 | |
21 | #include "defs.h" | |
22 | ||
0fda6bd2 JM |
23 | #include <sys/types.h> |
24 | #include <sys/procfs.h> | |
25 | ||
26 | #include "proc-utils.h" | |
27 | ||
7a952542 MK |
28 | /* Much of the information used in the /proc interface, particularly |
29 | for printing status information, is kept as tables of structures of | |
30 | the following form. These tables can be used to map numeric values | |
31 | to their symbolic names and to a string that describes their | |
32 | specific use. */ | |
0fda6bd2 | 33 | |
7a952542 MK |
34 | struct trans |
35 | { | |
36 | int value; /* The numeric value. */ | |
995816ba PA |
37 | const char *name; /* The equivalent symbolic value. */ |
38 | const char *desc; /* Short description of value. */ | |
0fda6bd2 JM |
39 | }; |
40 | ||
7a952542 MK |
41 | /* Translate values in the pr_why field of a `struct prstatus' or |
42 | `struct lwpstatus'. */ | |
0fda6bd2 JM |
43 | |
44 | static struct trans pr_why_table[] = | |
45 | { | |
0fda6bd2 JM |
46 | { PR_REQUESTED, "PR_REQUESTED", |
47 | "Directed to stop by debugger via P(IO)CSTOP or P(IO)CWSTOP" }, | |
0fda6bd2 | 48 | { PR_SIGNALLED, "PR_SIGNALLED", "Receipt of a traced signal" }, |
0fda6bd2 | 49 | { PR_SYSENTRY, "PR_SYSENTRY", "Entry to a traced system call" }, |
0fda6bd2 | 50 | { PR_SYSEXIT, "PR_SYSEXIT", "Exit from a traced system call" }, |
0fda6bd2 | 51 | { PR_JOBCONTROL, "PR_JOBCONTROL", "Default job control stop signal action" }, |
0fda6bd2 | 52 | { PR_FAULTED, "PR_FAULTED", "Incurred a traced hardware fault" }, |
0fda6bd2 | 53 | { PR_SUSPENDED, "PR_SUSPENDED", "Process suspended" }, |
0fda6bd2 | 54 | { PR_CHECKPOINT, "PR_CHECKPOINT", "Process stopped at checkpoint" }, |
0fda6bd2 JM |
55 | }; |
56 | ||
7a952542 MK |
57 | /* Pretty-print the pr_why field of a `struct prstatus' or `struct |
58 | lwpstatus'. */ | |
59 | ||
0fda6bd2 | 60 | void |
fba45db2 KB |
61 | proc_prettyfprint_why (FILE *file, unsigned long why, unsigned long what, |
62 | int verbose) | |
0fda6bd2 JM |
63 | { |
64 | int i; | |
65 | ||
66 | if (why == 0) | |
67 | return; | |
68 | ||
7a952542 | 69 | for (i = 0; i < ARRAY_SIZE (pr_why_table); i++) |
0fda6bd2 JM |
70 | if (why == pr_why_table[i].value) |
71 | { | |
72 | fprintf (file, "%s ", pr_why_table[i].name); | |
73 | if (verbose) | |
74 | fprintf (file, ": %s ", pr_why_table[i].desc); | |
75 | ||
76 | switch (why) { | |
0fda6bd2 | 77 | case PR_REQUESTED: |
7a952542 | 78 | break; /* Nothing more to print. */ |
0fda6bd2 JM |
79 | case PR_SIGNALLED: |
80 | proc_prettyfprint_signal (file, what, verbose); | |
81 | break; | |
0fda6bd2 JM |
82 | case PR_FAULTED: |
83 | proc_prettyfprint_fault (file, what, verbose); | |
84 | break; | |
0fda6bd2 JM |
85 | case PR_SYSENTRY: |
86 | fprintf (file, "Entry to "); | |
87 | proc_prettyfprint_syscall (file, what, verbose); | |
88 | break; | |
0fda6bd2 JM |
89 | case PR_SYSEXIT: |
90 | fprintf (file, "Exit from "); | |
91 | proc_prettyfprint_syscall (file, what, verbose); | |
92 | break; | |
0fda6bd2 JM |
93 | case PR_JOBCONTROL: |
94 | proc_prettyfprint_signal (file, what, verbose); | |
95 | break; | |
0fda6bd2 JM |
96 | default: |
97 | fprintf (file, "Unknown why %ld, what %ld\n", why, what); | |
98 | break; | |
99 | } | |
100 | fprintf (file, "\n"); | |
101 | ||
102 | return; | |
103 | } | |
7a952542 | 104 | |
0fda6bd2 JM |
105 | fprintf (file, "Unknown pr_why.\n"); |
106 | } | |
107 | ||
108 | void | |
fba45db2 | 109 | proc_prettyprint_why (unsigned long why, unsigned long what, int verbose) |
0fda6bd2 JM |
110 | { |
111 | proc_prettyfprint_why (stdout, why, what, verbose); | |
112 | } |