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. */
22 /* GDB-specific, FIXME. (This is for the SYS_SIGLIST_MISSING define). */
27 init_sig
PARAMS ((int, const char *, const char *));
30 init_sigs
PARAMS ((void));
32 #if SYS_SIGLIST_MISSING
33 /* There is too much variation in Sys V signal numbers and names, so
34 we must initialize them at runtime. */
36 static const char undoc
[] = "unknown signal";
38 /* We'd like to make this const char*[], but whoever's using it might
39 want to assign from it to a char*. */
40 char *sys_siglist
[NSIG
];
41 #endif /* SYS_SIGLIST_MISSING */
43 /* Table of abbreviations for signals. Note: A given number can
44 appear more than once with different abbreviations. */
50 static num_abbrev sig_table
[NSIG
*2];
51 /* Number of elements of sig_table used. */
52 static int sig_table_nelts
= 0;
54 /* Enter signal number NUMBER into the tables with ABBREV and NAME. */
57 init_sig (number
, abbrev
, name
)
62 #if SYS_SIGLIST_MISSING
63 sys_siglist
[number
] = (char *) name
;
65 sig_table
[sig_table_nelts
].number
= number
;
66 sig_table
[sig_table_nelts
++].abbrev
= abbrev
;
69 static void init_sigs ()
71 #if SYS_SIGLIST_MISSING
74 /* Initialize signal names. */
75 for (i
= 0; i
< NSIG
; i
++)
76 sys_siglist
[i
] = (char *) undoc
;
77 #endif /* SYS_SIGLIST_MISSING */
79 /* Initialize signal names. */
81 init_sig (SIGHUP
, "HUP", "Hangup");
84 init_sig (SIGINT
, "INT", "Interrupt");
87 init_sig (SIGQUIT
, "QUIT", "Quit");
90 init_sig (SIGILL
, "ILL", "Illegal Instruction");
93 init_sig (SIGTRAP
, "TRAP", "Trace/breakpoint trap");
95 /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
96 SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
98 init_sig (SIGABRT
, "ABRT", "Aborted");
101 init_sig (SIGIOT
, "IOT", "IOT trap");
104 init_sig (SIGEMT
, "EMT", "EMT trap");
107 init_sig (SIGFPE
, "FPE", "Floating point exception");
109 #if defined (SIGKILL)
110 init_sig (SIGKILL
, "KILL", "Killed");
113 init_sig (SIGBUS
, "BUS", "Bus error");
115 #if defined (SIGSEGV)
116 init_sig (SIGSEGV
, "SEGV", "Segmentation fault");
119 init_sig (SIGSYS
, "SYS", "Bad system call");
121 #if defined (SIGPIPE)
122 init_sig (SIGPIPE
, "PIPE", "Broken pipe");
124 #if defined (SIGALRM)
125 init_sig (SIGALRM
, "ALRM", "Alarm clock");
127 #if defined (SIGTERM)
128 init_sig (SIGTERM
, "TERM", "Terminated");
130 #if defined (SIGUSR1)
131 init_sig (SIGUSR1
, "USR1", "User defined signal 1");
133 #if defined (SIGUSR2)
134 init_sig (SIGUSR2
, "USR2", "User defined signal 2");
136 /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
137 is what is in POSIX.1. */
138 #if defined (SIGCHLD)
139 init_sig (SIGCHLD
, "CHLD", "Child exited");
142 init_sig (SIGCLD
, "CLD", "Child exited");
145 init_sig (SIGPWR
, "PWR", "Power failure");
147 #if defined (SIGTSTP)
148 init_sig (SIGTSTP
, "TSTP", "Stopped");
150 #if defined (SIGTTIN)
151 init_sig (SIGTTIN
, "TTIN", "Stopped (tty input)");
153 #if defined (SIGTTOU)
154 init_sig (SIGTTOU
, "TTOU", "Stopped (tty output)");
156 #if defined (SIGSTOP)
157 init_sig (SIGSTOP
, "STOP", "Stopped (signal)");
159 #if defined (SIGXCPU)
160 init_sig (SIGXCPU
, "XCPU", "CPU time limit exceeded");
162 #if defined (SIGXFSZ)
163 init_sig (SIGXFSZ
, "XFSZ", "File size limit exceeded");
165 #if defined (SIGVTALRM)
166 init_sig (SIGVTALRM
, "VTALRM", "Virtual timer expired");
168 #if defined (SIGPROF)
169 init_sig (SIGPROF
, "PROF", "Profiling timer expired");
171 #if defined (SIGWINCH)
172 /* "Window size changed" might be more accurate, but even if that
173 is all that it means now, perhaps in the future it will be
174 extended to cover other kinds of window changes. */
175 init_sig (SIGWINCH
, "WINCH", "Window changed");
177 #if defined (SIGCONT)
178 init_sig (SIGCONT
, "CONT", "Continued");
181 init_sig (SIGURG
, "URG", "Urgent I/O condition");
184 /* "I/O pending" has also been suggested. A disadvantage is
185 that signal only happens when the process has
186 asked for it, not everytime I/O is pending. Another disadvantage
187 is the confusion from giving it a different name than under Unix. */
188 init_sig (SIGIO
, "IO", "I/O possible");
190 #if defined (SIGWIND)
191 init_sig (SIGWIND
, "WIND", "SIGWIND");
193 #if defined (SIGPHONE)
194 init_sig (SIGPHONE
, "PHONE", "SIGPHONE");
196 #if defined (SIGPOLL)
197 init_sig (SIGPOLL
, "POLL", "I/O possible");
199 #if defined (SIGLOST)
200 init_sig (SIGLOST
, "LOST", "Resource lost");
204 /* Return the abbreviation for signal NUMBER. */
211 for (i
= 0; i
< sig_table_nelts
; i
++)
212 if (sig_table
[i
].number
== number
)
213 return (char *)sig_table
[i
].abbrev
;
217 /* Return the signal number for an ABBREV, or -1 if there is no
218 signal by that name. */
225 /* Skip over "SIG" if present. */
226 if (abbrev
[0] == 'S' && abbrev
[1] == 'I' && abbrev
[2] == 'G')
229 for (i
= 0; i
< sig_table_nelts
; i
++)
230 if (abbrev
[0] == sig_table
[i
].abbrev
[0]
231 && strcmp (abbrev
, sig_table
[i
].abbrev
) == 0)
232 return sig_table
[i
].number
;
236 #if SYS_SIGLIST_MISSING
237 /* Print to standard error the name of SIGNAL, preceded by MESSAGE and
238 a colon, and followed by a newline. */
240 psignal (signal
, message
)
244 if (signal
<= 0 || signal
>= NSIG
)
245 fprintf (stderr
, "%s: unknown signal", message
);
247 fprintf (stderr
, "%s: %s\n", message
, sys_siglist
[signal
]);
249 #endif /* SYS_SIGLIST_MISSING */
252 _initialize_signame ()