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