testsuite, threads: fix LD_LIBRARY_PATH in 'tls-sepdebug.exp'
[binutils-gdb.git] / gdb / proc-why.c
blobec8987ddb73667cbba7b162a17e82286778e00a6
1 /* Machine-independent support for Solaris /proc (process file system)
3 Copyright (C) 1999-2024 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 3 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, see <http://www.gnu.org/licenses/>. */
22 #include <sys/types.h>
23 #include <sys/procfs.h>
25 #include "proc-utils.h"
27 /* Much of the information used in the /proc interface, particularly
28 for printing status information, is kept as tables of structures of
29 the following form. These tables can be used to map numeric values
30 to their symbolic names and to a string that describes their
31 specific use. */
33 struct trans
35 int value; /* The numeric value. */
36 const char *name; /* The equivalent symbolic value. */
37 const char *desc; /* Short description of value. */
40 /* Translate values in the pr_why field of a `struct prstatus' or
41 `struct lwpstatus'. */
43 static struct trans pr_why_table[] =
45 { PR_REQUESTED, "PR_REQUESTED",
46 "Directed to stop by debugger via P(IO)CSTOP or P(IO)CWSTOP" },
47 { PR_SIGNALLED, "PR_SIGNALLED", "Receipt of a traced signal" },
48 { PR_SYSENTRY, "PR_SYSENTRY", "Entry to a traced system call" },
49 { PR_SYSEXIT, "PR_SYSEXIT", "Exit from a traced system call" },
50 { PR_JOBCONTROL, "PR_JOBCONTROL", "Default job control stop signal action" },
51 { PR_FAULTED, "PR_FAULTED", "Incurred a traced hardware fault" },
52 { PR_SUSPENDED, "PR_SUSPENDED", "Process suspended" },
53 { PR_CHECKPOINT, "PR_CHECKPOINT", "Process stopped at checkpoint" },
56 /* Pretty-print the pr_why field of a `struct prstatus' or `struct
57 lwpstatus'. */
59 void
60 proc_prettyfprint_why (FILE *file, unsigned long why, unsigned long what,
61 int verbose)
63 int i;
65 if (why == 0)
66 return;
68 for (i = 0; i < ARRAY_SIZE (pr_why_table); i++)
69 if (why == pr_why_table[i].value)
71 fprintf (file, "%s ", pr_why_table[i].name);
72 if (verbose)
73 fprintf (file, ": %s ", pr_why_table[i].desc);
75 switch (why) {
76 case PR_REQUESTED:
77 break; /* Nothing more to print. */
78 case PR_SIGNALLED:
79 proc_prettyfprint_signal (file, what, verbose);
80 break;
81 case PR_FAULTED:
82 proc_prettyfprint_fault (file, what, verbose);
83 break;
84 case PR_SYSENTRY:
85 fprintf (file, "Entry to ");
86 proc_prettyfprint_syscall (file, what, verbose);
87 break;
88 case PR_SYSEXIT:
89 fprintf (file, "Exit from ");
90 proc_prettyfprint_syscall (file, what, verbose);
91 break;
92 case PR_JOBCONTROL:
93 proc_prettyfprint_signal (file, what, verbose);
94 break;
95 default:
96 fprintf (file, "Unknown why %ld, what %ld\n", why, what);
97 break;
99 fprintf (file, "\n");
101 return;
104 fprintf (file, "Unknown pr_why.\n");
107 void
108 proc_prettyprint_why (unsigned long why, unsigned long what, int verbose)
110 proc_prettyfprint_why (stdout, why, what, verbose);