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