1 /* Convert between signal names and numbers, for GDB.
2 Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* GDB-specific, FIXME. (This is for the SYS_SIGLIST_MISSING define). */
26 init_sig PARAMS ((int, const char *, const char *));
29 init_sigs PARAMS ((void));
31 #if SYS_SIGLIST_MISSING
32 /* There is too much variation in Sys V signal numbers and names, so
33 we must initialize them at runtime. */
35 static const char undoc[] = "unknown signal";
37 /* We'd like to make this const char*[], but whoever's using it might
38 want to assign from it to a char*. */
39 char *sys_siglist[NSIG];
40 #endif /* SYS_SIGLIST_MISSING */
42 /* Table of abbreviations for signals. Note: A given number can
43 appear more than once with different abbreviations. */
49 static num_abbrev sig_table[NSIG*2];
50 /* Number of elements of sig_table used. */
51 static int sig_table_nelts = 0;
53 /* Enter signal number NUMBER into the tables with ABBREV and NAME. */
56 init_sig (number, abbrev, name)
61 #if SYS_SIGLIST_MISSING
62 sys_siglist[number] = (char *) name;
64 sig_table[sig_table_nelts].number = number;
65 sig_table[sig_table_nelts++].abbrev = abbrev;
68 static void init_sigs ()
70 #if SYS_SIGLIST_MISSING
73 /* Initialize signal names. */
74 for (i = 0; i < NSIG; i++)
75 sys_siglist[i] = (char *) undoc;
76 #endif /* SYS_SIGLIST_MISSING */
78 /* Initialize signal names. */
80 init_sig (SIGHUP, "HUP", "Hangup");
83 init_sig (SIGINT, "INT", "Interrupt");
86 init_sig (SIGQUIT, "QUIT", "Quit");
89 init_sig (SIGILL, "ILL", "Illegal Instruction");
92 init_sig (SIGTRAP, "TRAP", "Trace/breakpoint trap");
94 /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
95 SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
97 init_sig (SIGABRT, "ABRT", "Aborted");
100 init_sig (SIGIOT, "IOT", "IOT trap");
103 init_sig (SIGEMT, "EMT", "EMT trap");
106 init_sig (SIGFPE, "FPE", "Floating point exception");
108 #if defined (SIGKILL)
109 init_sig (SIGKILL, "KILL", "Killed");
112 init_sig (SIGBUS, "BUS", "Bus error");
114 #if defined (SIGSEGV)
115 init_sig (SIGSEGV, "SEGV", "Segmentation fault");
118 init_sig (SIGSYS, "SYS", "Bad system call");
120 #if defined (SIGPIPE)
121 init_sig (SIGPIPE, "PIPE", "Broken pipe");
123 #if defined (SIGALRM)
124 init_sig (SIGALRM, "ALRM", "Alarm clock");
126 #if defined (SIGTERM)
127 init_sig (SIGTERM, "TERM", "Terminated");
129 #if defined (SIGUSR1)
130 init_sig (SIGUSR1, "USR1", "User defined signal 1");
132 #if defined (SIGUSR2)
133 init_sig (SIGUSR2, "USR2", "User defined signal 2");
135 /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
136 is what is in POSIX.1. */
137 #if defined (SIGCHLD)
138 init_sig (SIGCHLD, "CHLD", "Child exited");
141 init_sig (SIGCLD, "CLD", "Child exited");
144 init_sig (SIGPWR, "PWR", "Power failure");
146 #if defined (SIGTSTP)
147 init_sig (SIGTSTP, "TSTP", "Stopped");
149 #if defined (SIGTTIN)
150 init_sig (SIGTTIN, "TTIN", "Stopped (tty input)");
152 #if defined (SIGTTOU)
153 init_sig (SIGTTOU, "TTOU", "Stopped (tty output)");
155 #if defined (SIGSTOP)
156 init_sig (SIGSTOP, "STOP", "Stopped (signal)");
158 #if defined (SIGXCPU)
159 init_sig (SIGXCPU, "XCPU", "CPU time limit exceeded");
161 #if defined (SIGXFSZ)
162 init_sig (SIGXFSZ, "XFSZ", "File size limit exceeded");
164 #if defined (SIGVTALRM)
165 init_sig (SIGVTALRM, "VTALRM", "Virtual timer expired");
167 #if defined (SIGPROF)
168 init_sig (SIGPROF, "PROF", "Profiling timer expired");
170 #if defined (SIGWINCH)
171 /* "Window size changed" might be more accurate, but even if that
172 is all that it means now, perhaps in the future it will be
173 extended to cover other kinds of window changes. */
174 init_sig (SIGWINCH, "WINCH", "Window changed");
176 #if defined (SIGCONT)
177 init_sig (SIGCONT, "CONT", "Continued");
180 init_sig (SIGURG, "URG", "Urgent I/O condition");
183 /* "I/O pending" has also been suggested. A disadvantage is
184 that signal only happens when the process has
185 asked for it, not everytime I/O is pending. Another disadvantage
186 is the confusion from giving it a different name than under Unix. */
187 init_sig (SIGIO, "IO", "I/O possible");
189 #if defined (SIGWIND)
190 init_sig (SIGWIND, "WIND", "SIGWIND");
192 #if defined (SIGPHONE)
193 init_sig (SIGPHONE, "PHONE", "SIGPHONE");
195 #if defined (SIGPOLL)
196 init_sig (SIGPOLL, "POLL", "I/O possible");
198 #if defined (SIGLOST)
199 init_sig (SIGLOST, "LOST", "Resource lost");
201 #if defined (SIGWAITING)
202 init_sig (SIGWAITING, "WAITING", "Process's LWPs are blocked"); /* FIXME */
205 init_sig (SIGLWP, "LWP", "Signal LWP"); /* FIXME description */
209 /* Return the abbreviation for signal NUMBER. */
216 for (i = 0; i < sig_table_nelts; i++)
217 if (sig_table[i].number == number)
218 return (char *)sig_table[i].abbrev;
222 /* Return the signal number for an ABBREV, or -1 if there is no
223 signal by that name. */
230 /* Skip over "SIG" if present. */
231 if (abbrev[0] == 'S' && abbrev[1] == 'I' && abbrev[2] == 'G')
234 for (i = 0; i < sig_table_nelts; i++)
235 if (abbrev[0] == sig_table[i].abbrev[0]
236 && strcmp (abbrev, sig_table[i].abbrev) == 0)
237 return sig_table[i].number;
241 #if SYS_SIGLIST_MISSING
242 /* Print to standard error the name of SIGNAL, preceded by MESSAGE and
243 a colon, and followed by a newline. */
245 psignal (signal, message)
249 if (signal <= 0 || signal >= NSIG)
250 fprintf (stderr, "%s: unknown signal", message);
252 fprintf (stderr, "%s: %s\n", message, sys_siglist[signal]);
254 #endif /* SYS_SIGLIST_MISSING */
257 _initialize_signame ()