1 /* Convert between signal names and numbers, for GDB.
2 Copyright 1990, 1991 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. */
24 /* GDB-specific, FIXME. (This is for the SYS_SIGLIST_MISSING define). */
33 #if SYS_SIGLIST_MISSING
34 /* There is too much variation in Sys V signal numbers and names, so
35 we must initialize them at runtime. */
37 static CONST
char undoc
[] = "unknown signal";
39 /* We'd like to make this const char*[], but whoever's using it might
40 want to assign from it to a char*. */
41 char *sys_siglist
[NSIG
];
42 #endif /* SYS_SIGLIST_MISSING */
44 /* Table of abbreviations for signals. Note: A given number can
45 appear more than once with different abbreviations. */
51 static num_abbrev sig_table
[NSIG
*2];
52 /* Number of elements of sig_table used. */
53 static int sig_table_nelts
= 0;
55 /* Enter signal number NUMBER into the tables with ABBREV and NAME. */
58 init_sig (number
, abbrev
, name
)
63 #if SYS_SIGLIST_MISSING
64 sys_siglist
[number
] = (char *) name
;
66 sig_table
[sig_table_nelts
].number
= number
;
67 sig_table
[sig_table_nelts
++].abbrev
= abbrev
;
70 static void init_sigs ()
72 #if SYS_SIGLIST_MISSING
75 /* Initialize signal names. */
76 for (i
= 0; i
< NSIG
; i
++)
77 sys_siglist
[i
] = (char *) undoc
;
78 #endif /* SYS_SIGLIST_MISSING */
80 /* Initialize signal names. */
82 init_sig (SIGHUP
, "HUP", "Hangup");
85 init_sig (SIGINT
, "INT", "Interrupt");
88 init_sig (SIGQUIT
, "QUIT", "Quit");
91 init_sig (SIGILL
, "ILL", "Illegal Instruction");
94 init_sig (SIGTRAP
, "TRAP", "Trace/breakpoint trap");
96 /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
97 SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
99 init_sig (SIGABRT
, "ABRT", "Aborted");
102 init_sig (SIGIOT
, "IOT", "IOT trap");
105 init_sig (SIGEMT
, "EMT", "EMT trap");
108 init_sig (SIGFPE
, "FPE", "Floating point exception");
110 #if defined (SIGKILL)
111 init_sig (SIGKILL
, "KILL", "Killed");
114 init_sig (SIGBUS
, "BUS", "Bus error");
116 #if defined (SIGSEGV)
117 init_sig (SIGSEGV
, "SEGV", "Segmentation fault");
120 init_sig (SIGSYS
, "SYS", "Bad system call");
122 #if defined (SIGPIPE)
123 init_sig (SIGPIPE
, "PIPE", "Broken pipe");
125 #if defined (SIGALRM)
126 init_sig (SIGALRM
, "ALRM", "Alarm clock");
128 #if defined (SIGTERM)
129 init_sig (SIGTERM
, "TERM", "Terminated");
131 #if defined (SIGUSR1)
132 init_sig (SIGUSR1
, "USR1", "User defined signal 1");
134 #if defined (SIGUSR2)
135 init_sig (SIGUSR2
, "USR2", "User defined signal 2");
137 /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
138 is what is in POSIX.1. */
139 #if defined (SIGCHLD)
140 init_sig (SIGCHLD
, "CHLD", "Child exited");
143 init_sig (SIGCLD
, "CLD", "Child exited");
146 init_sig (SIGPWR
, "PWR", "Power failure");
148 #if defined (SIGTSTP)
149 init_sig (SIGTSTP
, "TSTP", "Stopped");
151 #if defined (SIGTTIN)
152 init_sig (SIGTTIN
, "TTIN", "Stopped (tty input)");
154 #if defined (SIGTTOU)
155 init_sig (SIGTTOU
, "TTOU", "Stopped (tty output)");
157 #if defined (SIGSTOP)
158 init_sig (SIGSTOP
, "STOP", "Stopped (signal)");
160 #if defined (SIGXCPU)
161 init_sig (SIGXCPU
, "XCPU", "CPU time limit exceeded");
163 #if defined (SIGXFSZ)
164 init_sig (SIGXFSZ
, "XFSZ", "File size limit exceeded");
166 #if defined (SIGVTALRM)
167 init_sig (SIGVTALRM
, "VTALRM", "Virtual timer expired");
169 #if defined (SIGPROF)
170 init_sig (SIGPROF
, "PROF", "Profiling timer expired");
172 #if defined (SIGWINCH)
173 /* "Window size changed" might be more accurate, but even if that
174 is all that it means now, perhaps in the future it will be
175 extended to cover other kinds of window changes. */
176 init_sig (SIGWINCH
, "WINCH", "Window changed");
178 #if defined (SIGCONT)
179 init_sig (SIGCONT
, "CONT", "Continued");
182 init_sig (SIGURG
, "URG", "Urgent I/O condition");
185 /* "I/O pending" has also been suggested. A disadvantage is
186 that signal only happens when the process has
187 asked for it, not everytime I/O is pending. Another disadvantage
188 is the confusion from giving it a different name than under Unix. */
189 init_sig (SIGIO
, "IO", "I/O possible");
191 #if defined (SIGWIND)
192 init_sig (SIGWIND
, "WIND", "SIGWIND");
194 #if defined (SIGPHONE)
195 init_sig (SIGPHONE
, "PHONE", "SIGPHONE");
197 #if defined (SIGPOLL)
198 init_sig (SIGPOLL
, "POLL", "I/O possible");
200 #if defined (SIGLOST)
201 init_sig (SIGLOST
, "LOST", "Resource lost");
205 /* Return the abbreviation for signal NUMBER. */
212 for (i
= 0; i
< sig_table_nelts
; i
++)
213 if (sig_table
[i
].number
== number
)
214 return (char *)sig_table
[i
].abbrev
;
218 /* Return the signal number for an ABBREV, or -1 if there is no
219 signal by that name. */
226 /* Skip over "SIG" if present. */
227 if (abbrev
[0] == 'S' && abbrev
[1] == 'I' && abbrev
[2] == 'G')
230 for (i
= 0; i
< sig_table_nelts
; i
++)
231 if (abbrev
[0] == sig_table
[i
].abbrev
[0]
232 && strcmp (abbrev
, sig_table
[i
].abbrev
) == 0)
233 return sig_table
[i
].number
;
237 #if SYS_SIGLIST_MISSING
238 /* Print to standard error the name of SIGNAL, preceded by MESSAGE and
239 a colon, and followed by a newline. */
241 psignal (signal
, message
)
245 if (signal
<= 0 || signal
>= NSIG
)
246 fprintf (stderr
, "%s: unknown signal", message
);
248 fprintf (stderr
, "%s: %s\n", message
, sys_siglist
[signal
]);
250 #endif /* SYS_SIGLIST_MISSING */
253 _initialize_signame ()
This page took 0.035268 seconds and 5 git commands to generate.