signals.cc revision 1.1.1.3 1 1.1 christos /* Target signal translation functions for GDB.
2 1.1.1.3 christos Copyright (C) 1990-2024 Free Software Foundation, Inc.
3 1.1 christos Contributed by Cygnus Support.
4 1.1 christos
5 1.1 christos This file is part of GDB.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos
21 1.1 christos #ifdef HAVE_SIGNAL_H
22 1.1 christos #include <signal.h>
23 1.1 christos #endif
24 1.1 christos
25 1.1 christos #include "gdb_signals.h"
26 1.1 christos
27 1.1 christos struct gdbarch;
28 1.1 christos
29 1.1 christos /* Always use __SIGRTMIN if it's available. SIGRTMIN is the lowest
30 1.1 christos _available_ realtime signal, not the lowest supported; glibc takes
31 1.1 christos several for its own use. */
32 1.1 christos
33 1.1 christos #ifndef REALTIME_LO
34 1.1 christos # if defined(__SIGRTMIN)
35 1.1 christos # define REALTIME_LO __SIGRTMIN
36 1.1 christos # define REALTIME_HI (__SIGRTMAX + 1)
37 1.1 christos # elif defined(SIGRTMIN)
38 1.1 christos # define REALTIME_LO SIGRTMIN
39 1.1 christos # define REALTIME_HI (SIGRTMAX + 1)
40 1.1 christos # endif
41 1.1 christos #endif
42 1.1 christos
43 1.1 christos /* This table must match in order and size the signals in enum
44 1.1 christos gdb_signal. */
45 1.1 christos
46 1.1 christos static const struct {
47 1.1 christos const char *symbol;
48 1.1 christos const char *name;
49 1.1 christos const char *string;
50 1.1 christos } signals [] =
51 1.1 christos {
52 1.1 christos #define SET(symbol, constant, name, string) { #symbol, name, string },
53 1.1 christos #include "gdb/signals.def"
54 1.1 christos #undef SET
55 1.1 christos };
56 1.1 christos
57 1.1 christos const char *
58 1.1 christos gdb_signal_to_symbol_string (enum gdb_signal sig)
59 1.1 christos {
60 1.1 christos gdb_assert ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST);
61 1.1 christos
62 1.1 christos return signals[sig].symbol;
63 1.1 christos }
64 1.1 christos
65 1.1 christos /* Return the string for a signal. */
66 1.1 christos const char *
67 1.1 christos gdb_signal_to_string (enum gdb_signal sig)
68 1.1 christos {
69 1.1 christos if ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST)
70 1.1 christos return signals[sig].string;
71 1.1 christos else
72 1.1 christos return signals[GDB_SIGNAL_UNKNOWN].string;
73 1.1 christos }
74 1.1 christos
75 1.1 christos /* Return the name for a signal. */
76 1.1 christos const char *
77 1.1 christos gdb_signal_to_name (enum gdb_signal sig)
78 1.1 christos {
79 1.1 christos if ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST
80 1.1 christos && signals[sig].name != NULL)
81 1.1 christos return signals[sig].name;
82 1.1 christos else
83 1.1 christos /* I think the code which prints this will always print it along
84 1.1 christos with the string, so no need to be verbose (very old comment). */
85 1.1 christos return "?";
86 1.1 christos }
87 1.1 christos
88 1.1 christos /* Given a name, return its signal. */
89 1.1 christos enum gdb_signal
90 1.1 christos gdb_signal_from_name (const char *name)
91 1.1 christos {
92 1.1 christos enum gdb_signal sig;
93 1.1 christos
94 1.1 christos /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
95 1.1 christos for GDB_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
96 1.1 christos questionable; seems like by now people should call it SIGABRT
97 1.1 christos instead. */
98 1.1 christos
99 1.1 christos /* This ugly cast brought to you by the native VAX compiler. */
100 1.1 christos for (sig = GDB_SIGNAL_HUP;
101 1.1 christos sig < GDB_SIGNAL_LAST;
102 1.1 christos sig = (enum gdb_signal) ((int) sig + 1))
103 1.1 christos if (signals[sig].name != NULL
104 1.1 christos && strcmp (name, signals[sig].name) == 0)
105 1.1 christos return sig;
106 1.1 christos return GDB_SIGNAL_UNKNOWN;
107 1.1 christos }
108 1.1 christos
109 1.1 christos /* The following functions are to help certain targets deal
111 1.1 christos with the signal/waitstatus stuff. They could just as well be in
112 1.1 christos a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
113 1.1 christos
114 1.1 christos /* Convert host signal to our signals. */
115 1.1 christos enum gdb_signal
116 1.1 christos gdb_signal_from_host (int hostsig)
117 1.1 christos {
118 1.1 christos /* A switch statement would make sense but would require special
119 1.1 christos kludges to deal with the cases where more than one signal has the
120 1.1 christos same number. Signals are ordered ANSI-standard signals first,
121 1.1 christos other signals second, with signals in each block ordered by their
122 1.1 christos numerical values on a typical POSIX platform. */
123 1.1 christos
124 1.1 christos if (hostsig == 0)
125 1.1 christos return GDB_SIGNAL_0;
126 1.1 christos
127 1.1 christos /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
128 1.1 christos are ANSI-standard signals and are always available. */
129 1.1 christos if (hostsig == SIGINT)
130 1.1 christos return GDB_SIGNAL_INT;
131 1.1 christos if (hostsig == SIGILL)
132 1.1 christos return GDB_SIGNAL_ILL;
133 1.1 christos if (hostsig == SIGABRT)
134 1.1 christos return GDB_SIGNAL_ABRT;
135 1.1 christos if (hostsig == SIGFPE)
136 1.1 christos return GDB_SIGNAL_FPE;
137 1.1 christos if (hostsig == SIGSEGV)
138 1.1 christos return GDB_SIGNAL_SEGV;
139 1.1 christos if (hostsig == SIGTERM)
140 1.1 christos return GDB_SIGNAL_TERM;
141 1.1 christos
142 1.1 christos /* All other signals need preprocessor conditionals. */
143 1.1 christos #if defined (SIGHUP)
144 1.1 christos if (hostsig == SIGHUP)
145 1.1 christos return GDB_SIGNAL_HUP;
146 1.1 christos #endif
147 1.1 christos #if defined (SIGQUIT)
148 1.1 christos if (hostsig == SIGQUIT)
149 1.1 christos return GDB_SIGNAL_QUIT;
150 1.1 christos #endif
151 1.1 christos #if defined (SIGTRAP)
152 1.1 christos if (hostsig == SIGTRAP)
153 1.1 christos return GDB_SIGNAL_TRAP;
154 1.1 christos #endif
155 1.1 christos #if defined (SIGEMT)
156 1.1 christos if (hostsig == SIGEMT)
157 1.1 christos return GDB_SIGNAL_EMT;
158 1.1 christos #endif
159 1.1 christos #if defined (SIGKILL)
160 1.1 christos if (hostsig == SIGKILL)
161 1.1 christos return GDB_SIGNAL_KILL;
162 1.1 christos #endif
163 1.1 christos #if defined (SIGBUS)
164 1.1 christos if (hostsig == SIGBUS)
165 1.1 christos return GDB_SIGNAL_BUS;
166 1.1 christos #endif
167 1.1 christos #if defined (SIGSYS)
168 1.1 christos if (hostsig == SIGSYS)
169 1.1 christos return GDB_SIGNAL_SYS;
170 1.1 christos #endif
171 1.1 christos #if defined (SIGPIPE)
172 1.1 christos if (hostsig == SIGPIPE)
173 1.1 christos return GDB_SIGNAL_PIPE;
174 1.1 christos #endif
175 1.1 christos #if defined (SIGALRM)
176 1.1 christos if (hostsig == SIGALRM)
177 1.1 christos return GDB_SIGNAL_ALRM;
178 1.1 christos #endif
179 1.1 christos #if defined (SIGUSR1)
180 1.1 christos if (hostsig == SIGUSR1)
181 1.1 christos return GDB_SIGNAL_USR1;
182 1.1 christos #endif
183 1.1 christos #if defined (SIGUSR2)
184 1.1 christos if (hostsig == SIGUSR2)
185 1.1 christos return GDB_SIGNAL_USR2;
186 1.1 christos #endif
187 1.1 christos #if defined (SIGCLD)
188 1.1 christos if (hostsig == SIGCLD)
189 1.1 christos return GDB_SIGNAL_CHLD;
190 1.1 christos #endif
191 1.1 christos #if defined (SIGCHLD)
192 1.1 christos if (hostsig == SIGCHLD)
193 1.1 christos return GDB_SIGNAL_CHLD;
194 1.1 christos #endif
195 1.1 christos #if defined (SIGPWR)
196 1.1 christos if (hostsig == SIGPWR)
197 1.1 christos return GDB_SIGNAL_PWR;
198 1.1 christos #endif
199 1.1 christos #if defined (SIGWINCH)
200 1.1 christos if (hostsig == SIGWINCH)
201 1.1 christos return GDB_SIGNAL_WINCH;
202 1.1 christos #endif
203 1.1 christos #if defined (SIGURG)
204 1.1 christos if (hostsig == SIGURG)
205 1.1 christos return GDB_SIGNAL_URG;
206 1.1 christos #endif
207 1.1 christos #if defined (SIGIO)
208 1.1 christos if (hostsig == SIGIO)
209 1.1 christos return GDB_SIGNAL_IO;
210 1.1 christos #endif
211 1.1 christos #if defined (SIGPOLL)
212 1.1 christos if (hostsig == SIGPOLL)
213 1.1 christos return GDB_SIGNAL_POLL;
214 1.1 christos #endif
215 1.1 christos #if defined (SIGSTOP)
216 1.1 christos if (hostsig == SIGSTOP)
217 1.1 christos return GDB_SIGNAL_STOP;
218 1.1 christos #endif
219 1.1 christos #if defined (SIGTSTP)
220 1.1 christos if (hostsig == SIGTSTP)
221 1.1 christos return GDB_SIGNAL_TSTP;
222 1.1 christos #endif
223 1.1 christos #if defined (SIGCONT)
224 1.1 christos if (hostsig == SIGCONT)
225 1.1 christos return GDB_SIGNAL_CONT;
226 1.1 christos #endif
227 1.1 christos #if defined (SIGTTIN)
228 1.1 christos if (hostsig == SIGTTIN)
229 1.1 christos return GDB_SIGNAL_TTIN;
230 1.1 christos #endif
231 1.1 christos #if defined (SIGTTOU)
232 1.1 christos if (hostsig == SIGTTOU)
233 1.1 christos return GDB_SIGNAL_TTOU;
234 1.1 christos #endif
235 1.1 christos #if defined (SIGVTALRM)
236 1.1 christos if (hostsig == SIGVTALRM)
237 1.1 christos return GDB_SIGNAL_VTALRM;
238 1.1 christos #endif
239 1.1 christos #if defined (SIGPROF)
240 1.1 christos if (hostsig == SIGPROF)
241 1.1 christos return GDB_SIGNAL_PROF;
242 1.1 christos #endif
243 1.1 christos #if defined (SIGXCPU)
244 1.1 christos if (hostsig == SIGXCPU)
245 1.1 christos return GDB_SIGNAL_XCPU;
246 1.1 christos #endif
247 1.1 christos #if defined (SIGXFSZ)
248 1.1 christos if (hostsig == SIGXFSZ)
249 1.1 christos return GDB_SIGNAL_XFSZ;
250 1.1 christos #endif
251 1.1 christos #if defined (SIGWIND)
252 1.1 christos if (hostsig == SIGWIND)
253 1.1 christos return GDB_SIGNAL_WIND;
254 1.1 christos #endif
255 1.1 christos #if defined (SIGPHONE)
256 1.1 christos if (hostsig == SIGPHONE)
257 1.1 christos return GDB_SIGNAL_PHONE;
258 1.1 christos #endif
259 1.1 christos #if defined (SIGLOST)
260 1.1 christos if (hostsig == SIGLOST)
261 1.1 christos return GDB_SIGNAL_LOST;
262 1.1 christos #endif
263 1.1 christos #if defined (SIGWAITING)
264 1.1 christos if (hostsig == SIGWAITING)
265 1.1 christos return GDB_SIGNAL_WAITING;
266 1.1 christos #endif
267 1.1 christos #if defined (SIGCANCEL)
268 1.1 christos if (hostsig == SIGCANCEL)
269 1.1 christos return GDB_SIGNAL_CANCEL;
270 1.1 christos #endif
271 1.1 christos #if defined (SIGLWP)
272 1.1 christos if (hostsig == SIGLWP)
273 1.1 christos return GDB_SIGNAL_LWP;
274 1.1 christos #endif
275 1.1 christos #if defined (SIGDANGER)
276 1.1 christos if (hostsig == SIGDANGER)
277 1.1 christos return GDB_SIGNAL_DANGER;
278 1.1 christos #endif
279 1.1 christos #if defined (SIGGRANT)
280 1.1 christos if (hostsig == SIGGRANT)
281 1.1 christos return GDB_SIGNAL_GRANT;
282 1.1 christos #endif
283 1.1 christos #if defined (SIGRETRACT)
284 1.1 christos if (hostsig == SIGRETRACT)
285 1.1 christos return GDB_SIGNAL_RETRACT;
286 1.1 christos #endif
287 1.1 christos #if defined (SIGMSG)
288 1.1 christos if (hostsig == SIGMSG)
289 1.1 christos return GDB_SIGNAL_MSG;
290 1.1 christos #endif
291 1.1 christos #if defined (SIGSOUND)
292 1.1 christos if (hostsig == SIGSOUND)
293 1.1 christos return GDB_SIGNAL_SOUND;
294 1.1 christos #endif
295 1.1 christos #if defined (SIGSAK)
296 1.1 christos if (hostsig == SIGSAK)
297 1.1 christos return GDB_SIGNAL_SAK;
298 1.1 christos #endif
299 1.1 christos #if defined (SIGPRIO)
300 1.1 christos if (hostsig == SIGPRIO)
301 1.1 christos return GDB_SIGNAL_PRIO;
302 1.1 christos #endif
303 1.1 christos
304 1.1 christos /* Mach exceptions. Assumes that the values for EXC_ are positive! */
305 1.1 christos #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
306 1.1 christos if (hostsig == _NSIG + EXC_BAD_ACCESS)
307 1.1 christos return GDB_EXC_BAD_ACCESS;
308 1.1 christos #endif
309 1.1 christos #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
310 1.1 christos if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
311 1.1 christos return GDB_EXC_BAD_INSTRUCTION;
312 1.1 christos #endif
313 1.1 christos #if defined (EXC_ARITHMETIC) && defined (_NSIG)
314 1.1 christos if (hostsig == _NSIG + EXC_ARITHMETIC)
315 1.1 christos return GDB_EXC_ARITHMETIC;
316 1.1 christos #endif
317 1.1 christos #if defined (EXC_EMULATION) && defined (_NSIG)
318 1.1 christos if (hostsig == _NSIG + EXC_EMULATION)
319 1.1 christos return GDB_EXC_EMULATION;
320 1.1 christos #endif
321 1.1 christos #if defined (EXC_SOFTWARE) && defined (_NSIG)
322 1.1 christos if (hostsig == _NSIG + EXC_SOFTWARE)
323 1.1 christos return GDB_EXC_SOFTWARE;
324 1.1 christos #endif
325 1.1 christos #if defined (EXC_BREAKPOINT) && defined (_NSIG)
326 1.1 christos if (hostsig == _NSIG + EXC_BREAKPOINT)
327 1.1 christos return GDB_EXC_BREAKPOINT;
328 1.1 christos #endif
329 1.1 christos
330 1.1 christos #if defined (SIGINFO)
331 1.1 christos if (hostsig == SIGINFO)
332 1.1 christos return GDB_SIGNAL_INFO;
333 1.1 christos #endif
334 1.1 christos #if defined (SIGLIBRT)
335 1.1 christos if (hostsig == SIGLIBRT)
336 1.1 christos return GDB_SIGNAL_LIBRT;
337 1.1 christos #endif
338 1.1 christos
339 1.1 christos #if defined (REALTIME_LO)
340 1.1 christos if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
341 1.1 christos {
342 1.1 christos /* This block of GDB_SIGNAL_REALTIME value is in order. */
343 1.1 christos if (33 <= hostsig && hostsig <= 63)
344 1.1 christos return (enum gdb_signal)
345 1.1 christos (hostsig - 33 + (int) GDB_SIGNAL_REALTIME_33);
346 1.1 christos else if (hostsig == 32)
347 1.1 christos return GDB_SIGNAL_REALTIME_32;
348 1.1 christos else if (64 <= hostsig && hostsig <= 127)
349 1.1 christos return (enum gdb_signal)
350 1.1 christos (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
351 1.1 christos else
352 1.1 christos error (_("GDB bug: target.c (gdb_signal_from_host): "
353 1.1 christos "unrecognized real-time signal"));
354 1.1 christos }
355 1.1 christos #endif
356 1.1 christos
357 1.1 christos return GDB_SIGNAL_UNKNOWN;
358 1.1 christos }
359 1.1 christos
360 1.1.1.3 christos /* Convert a OURSIG (an enum gdb_signal) to the form used by the
361 1.1 christos target operating system (referred to as the ``host'') or zero if the
362 1.1 christos equivalent host signal is not available. Set/clear OURSIG_OK
363 1.1 christos accordingly. */
364 1.1 christos
365 1.1 christos static int
366 1.1 christos do_gdb_signal_to_host (enum gdb_signal oursig,
367 1.1 christos int *oursig_ok)
368 1.1 christos {
369 1.1 christos int retsig;
370 1.1 christos /* Silence the 'not used' warning, for targets that
371 1.1 christos do not support signals. */
372 1.1 christos (void) retsig;
373 1.1 christos
374 1.1 christos /* Signals are ordered ANSI-standard signals first, other signals
375 1.1 christos second, with signals in each block ordered by their numerical
376 1.1 christos values on a typical POSIX platform. */
377 1.1 christos
378 1.1 christos *oursig_ok = 1;
379 1.1 christos switch (oursig)
380 1.1 christos {
381 1.1 christos case GDB_SIGNAL_0:
382 1.1 christos return 0;
383 1.1 christos
384 1.1 christos /* SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
385 1.1 christos are ANSI-standard signals and are always available. */
386 1.1 christos case GDB_SIGNAL_INT:
387 1.1 christos return SIGINT;
388 1.1 christos case GDB_SIGNAL_ILL:
389 1.1 christos return SIGILL;
390 1.1 christos case GDB_SIGNAL_ABRT:
391 1.1 christos return SIGABRT;
392 1.1 christos case GDB_SIGNAL_FPE:
393 1.1 christos return SIGFPE;
394 1.1 christos case GDB_SIGNAL_SEGV:
395 1.1 christos return SIGSEGV;
396 1.1 christos case GDB_SIGNAL_TERM:
397 1.1 christos return SIGTERM;
398 1.1 christos
399 1.1 christos /* All other signals need preprocessor conditionals. */
400 1.1 christos #if defined (SIGHUP)
401 1.1 christos case GDB_SIGNAL_HUP:
402 1.1 christos return SIGHUP;
403 1.1 christos #endif
404 1.1 christos #if defined (SIGQUIT)
405 1.1 christos case GDB_SIGNAL_QUIT:
406 1.1 christos return SIGQUIT;
407 1.1 christos #endif
408 1.1 christos #if defined (SIGTRAP)
409 1.1 christos case GDB_SIGNAL_TRAP:
410 1.1 christos return SIGTRAP;
411 1.1 christos #endif
412 1.1 christos #if defined (SIGEMT)
413 1.1 christos case GDB_SIGNAL_EMT:
414 1.1 christos return SIGEMT;
415 1.1 christos #endif
416 1.1 christos #if defined (SIGKILL)
417 1.1 christos case GDB_SIGNAL_KILL:
418 1.1 christos return SIGKILL;
419 1.1 christos #endif
420 1.1 christos #if defined (SIGBUS)
421 1.1 christos case GDB_SIGNAL_BUS:
422 1.1 christos return SIGBUS;
423 1.1 christos #endif
424 1.1 christos #if defined (SIGSYS)
425 1.1 christos case GDB_SIGNAL_SYS:
426 1.1 christos return SIGSYS;
427 1.1 christos #endif
428 1.1 christos #if defined (SIGPIPE)
429 1.1 christos case GDB_SIGNAL_PIPE:
430 1.1 christos return SIGPIPE;
431 1.1 christos #endif
432 1.1 christos #if defined (SIGALRM)
433 1.1 christos case GDB_SIGNAL_ALRM:
434 1.1 christos return SIGALRM;
435 1.1 christos #endif
436 1.1 christos #if defined (SIGUSR1)
437 1.1 christos case GDB_SIGNAL_USR1:
438 1.1 christos return SIGUSR1;
439 1.1 christos #endif
440 1.1 christos #if defined (SIGUSR2)
441 1.1 christos case GDB_SIGNAL_USR2:
442 1.1 christos return SIGUSR2;
443 1.1 christos #endif
444 1.1 christos #if defined (SIGCHLD) || defined (SIGCLD)
445 1.1 christos case GDB_SIGNAL_CHLD:
446 1.1 christos #if defined (SIGCHLD)
447 1.1 christos return SIGCHLD;
448 1.1 christos #else
449 1.1 christos return SIGCLD;
450 1.1 christos #endif
451 1.1 christos #endif /* SIGCLD or SIGCHLD */
452 1.1 christos #if defined (SIGPWR)
453 1.1 christos case GDB_SIGNAL_PWR:
454 1.1 christos return SIGPWR;
455 1.1 christos #endif
456 1.1 christos #if defined (SIGWINCH)
457 1.1 christos case GDB_SIGNAL_WINCH:
458 1.1 christos return SIGWINCH;
459 1.1 christos #endif
460 1.1 christos #if defined (SIGURG)
461 1.1 christos case GDB_SIGNAL_URG:
462 1.1 christos return SIGURG;
463 1.1 christos #endif
464 1.1 christos #if defined (SIGIO)
465 1.1 christos case GDB_SIGNAL_IO:
466 1.1 christos return SIGIO;
467 1.1 christos #endif
468 1.1 christos #if defined (SIGPOLL)
469 1.1 christos case GDB_SIGNAL_POLL:
470 1.1 christos return SIGPOLL;
471 1.1 christos #endif
472 1.1 christos #if defined (SIGSTOP)
473 1.1 christos case GDB_SIGNAL_STOP:
474 1.1 christos return SIGSTOP;
475 1.1 christos #endif
476 1.1 christos #if defined (SIGTSTP)
477 1.1 christos case GDB_SIGNAL_TSTP:
478 1.1 christos return SIGTSTP;
479 1.1 christos #endif
480 1.1 christos #if defined (SIGCONT)
481 1.1 christos case GDB_SIGNAL_CONT:
482 1.1 christos return SIGCONT;
483 1.1 christos #endif
484 1.1 christos #if defined (SIGTTIN)
485 1.1 christos case GDB_SIGNAL_TTIN:
486 1.1 christos return SIGTTIN;
487 1.1 christos #endif
488 1.1 christos #if defined (SIGTTOU)
489 1.1 christos case GDB_SIGNAL_TTOU:
490 1.1 christos return SIGTTOU;
491 1.1 christos #endif
492 1.1 christos #if defined (SIGVTALRM)
493 1.1 christos case GDB_SIGNAL_VTALRM:
494 1.1 christos return SIGVTALRM;
495 1.1 christos #endif
496 1.1 christos #if defined (SIGPROF)
497 1.1 christos case GDB_SIGNAL_PROF:
498 1.1 christos return SIGPROF;
499 1.1 christos #endif
500 1.1 christos #if defined (SIGXCPU)
501 1.1 christos case GDB_SIGNAL_XCPU:
502 1.1 christos return SIGXCPU;
503 1.1 christos #endif
504 1.1 christos #if defined (SIGXFSZ)
505 1.1 christos case GDB_SIGNAL_XFSZ:
506 1.1 christos return SIGXFSZ;
507 1.1 christos #endif
508 1.1 christos #if defined (SIGWIND)
509 1.1 christos case GDB_SIGNAL_WIND:
510 1.1 christos return SIGWIND;
511 1.1 christos #endif
512 1.1 christos #if defined (SIGPHONE)
513 1.1 christos case GDB_SIGNAL_PHONE:
514 1.1 christos return SIGPHONE;
515 1.1 christos #endif
516 1.1 christos #if defined (SIGLOST)
517 1.1 christos case GDB_SIGNAL_LOST:
518 1.1 christos return SIGLOST;
519 1.1 christos #endif
520 1.1 christos #if defined (SIGWAITING)
521 1.1 christos case GDB_SIGNAL_WAITING:
522 1.1 christos return SIGWAITING;
523 1.1 christos #endif
524 1.1 christos #if defined (SIGCANCEL)
525 1.1 christos case GDB_SIGNAL_CANCEL:
526 1.1 christos return SIGCANCEL;
527 1.1 christos #endif
528 1.1 christos #if defined (SIGLWP)
529 1.1 christos case GDB_SIGNAL_LWP:
530 1.1 christos return SIGLWP;
531 1.1 christos #endif
532 1.1 christos #if defined (SIGDANGER)
533 1.1 christos case GDB_SIGNAL_DANGER:
534 1.1 christos return SIGDANGER;
535 1.1 christos #endif
536 1.1 christos #if defined (SIGGRANT)
537 1.1 christos case GDB_SIGNAL_GRANT:
538 1.1 christos return SIGGRANT;
539 1.1 christos #endif
540 1.1 christos #if defined (SIGRETRACT)
541 1.1 christos case GDB_SIGNAL_RETRACT:
542 1.1 christos return SIGRETRACT;
543 1.1 christos #endif
544 1.1 christos #if defined (SIGMSG)
545 1.1 christos case GDB_SIGNAL_MSG:
546 1.1 christos return SIGMSG;
547 1.1 christos #endif
548 1.1 christos #if defined (SIGSOUND)
549 1.1 christos case GDB_SIGNAL_SOUND:
550 1.1 christos return SIGSOUND;
551 1.1 christos #endif
552 1.1 christos #if defined (SIGSAK)
553 1.1 christos case GDB_SIGNAL_SAK:
554 1.1 christos return SIGSAK;
555 1.1 christos #endif
556 1.1 christos #if defined (SIGPRIO)
557 1.1 christos case GDB_SIGNAL_PRIO:
558 1.1 christos return SIGPRIO;
559 1.1 christos #endif
560 1.1 christos
561 1.1 christos /* Mach exceptions. Assumes that the values for EXC_ are positive! */
562 1.1 christos #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
563 1.1 christos case GDB_EXC_BAD_ACCESS:
564 1.1 christos return _NSIG + EXC_BAD_ACCESS;
565 1.1 christos #endif
566 1.1 christos #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
567 1.1 christos case GDB_EXC_BAD_INSTRUCTION:
568 1.1 christos return _NSIG + EXC_BAD_INSTRUCTION;
569 1.1 christos #endif
570 1.1 christos #if defined (EXC_ARITHMETIC) && defined (_NSIG)
571 1.1 christos case GDB_EXC_ARITHMETIC:
572 1.1 christos return _NSIG + EXC_ARITHMETIC;
573 1.1 christos #endif
574 1.1 christos #if defined (EXC_EMULATION) && defined (_NSIG)
575 1.1 christos case GDB_EXC_EMULATION:
576 1.1 christos return _NSIG + EXC_EMULATION;
577 1.1 christos #endif
578 1.1 christos #if defined (EXC_SOFTWARE) && defined (_NSIG)
579 1.1 christos case GDB_EXC_SOFTWARE:
580 1.1 christos return _NSIG + EXC_SOFTWARE;
581 1.1 christos #endif
582 1.1 christos #if defined (EXC_BREAKPOINT) && defined (_NSIG)
583 1.1 christos case GDB_EXC_BREAKPOINT:
584 1.1 christos return _NSIG + EXC_BREAKPOINT;
585 1.1 christos #endif
586 1.1 christos
587 1.1 christos #if defined (SIGINFO)
588 1.1 christos case GDB_SIGNAL_INFO:
589 1.1 christos return SIGINFO;
590 1.1 christos #endif
591 1.1 christos #if defined (SIGLIBRT)
592 1.1 christos case GDB_SIGNAL_LIBRT:
593 1.1 christos return SIGLIBRT;
594 1.1 christos #endif
595 1.1 christos
596 1.1 christos default:
597 1.1 christos #if defined (REALTIME_LO)
598 1.1 christos retsig = 0;
599 1.1 christos
600 1.1 christos if (oursig >= GDB_SIGNAL_REALTIME_33
601 1.1 christos && oursig <= GDB_SIGNAL_REALTIME_63)
602 1.1 christos {
603 1.1.1.2 christos /* This block of signals is continuous, and
604 1.1 christos GDB_SIGNAL_REALTIME_33 is 33 by definition. */
605 1.1 christos retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_33 + 33;
606 1.1 christos }
607 1.1 christos else if (oursig == GDB_SIGNAL_REALTIME_32)
608 1.1 christos {
609 1.1.1.2 christos /* GDB_SIGNAL_REALTIME_32 isn't contiguous with
610 1.1 christos GDB_SIGNAL_REALTIME_33. It is 32 by definition. */
611 1.1 christos retsig = 32;
612 1.1 christos }
613 1.1 christos else if (oursig >= GDB_SIGNAL_REALTIME_64
614 1.1 christos && oursig <= GDB_SIGNAL_REALTIME_127)
615 1.1 christos {
616 1.1.1.2 christos /* This block of signals is continuous, and
617 1.1 christos GDB_SIGNAL_REALTIME_64 is 64 by definition. */
618 1.1 christos retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_64 + 64;
619 1.1 christos }
620 1.1 christos
621 1.1 christos if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
622 1.1 christos return retsig;
623 1.1 christos #endif
624 1.1 christos
625 1.1 christos *oursig_ok = 0;
626 1.1 christos return 0;
627 1.1 christos }
628 1.1 christos }
629 1.1 christos
630 1.1 christos int
631 1.1 christos gdb_signal_to_host_p (enum gdb_signal oursig)
632 1.1 christos {
633 1.1 christos int oursig_ok;
634 1.1 christos do_gdb_signal_to_host (oursig, &oursig_ok);
635 1.1 christos return oursig_ok;
636 1.1 christos }
637 1.1 christos
638 1.1 christos int
639 1.1 christos gdb_signal_to_host (enum gdb_signal oursig)
640 1.1 christos {
641 1.1 christos int oursig_ok;
642 1.1 christos int targ_signo = do_gdb_signal_to_host (oursig, &oursig_ok);
643 1.1 christos if (!oursig_ok)
644 1.1 christos {
645 1.1.1.2 christos /* The user might be trying to do "signal SIGSAK" where this system
646 1.1 christos doesn't have SIGSAK. */
647 1.1 christos warning (_("Signal %s does not exist on this system."),
648 1.1 christos gdb_signal_to_name (oursig));
649 1.1 christos return 0;
650 1.1 christos }
651 1.1 christos else
652 1.1 christos return targ_signo;
653 }
654