Commit | Line | Data |
---|---|---|
0150732f | 1 | /* Target signal translation functions for GDB. |
28e7fd62 | 2 | Copyright (C) 1990-2013 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 |
34 | struct 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 | 53 | static 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 |
64 | const char * |
65 | gdb_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 | 73 | const char * |
2ea28649 | 74 | gdb_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 | 83 | const char * |
2ea28649 | 84 | gdb_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 |
96 | enum gdb_signal |
97 | gdb_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 |
121 | enum gdb_signal |
122 | gdb_signal_from_host (int hostsig) | |
0150732f DJ |
123 | { |
124 | /* A switch statement would make sense but would require special kludges | |
125 | to deal with the cases where more than one signal has the same number. */ | |
126 | ||
127 | if (hostsig == 0) | |
a493e3e2 | 128 | return GDB_SIGNAL_0; |
0150732f DJ |
129 | |
130 | #if defined (SIGHUP) | |
131 | if (hostsig == SIGHUP) | |
a493e3e2 | 132 | return GDB_SIGNAL_HUP; |
0150732f DJ |
133 | #endif |
134 | #if defined (SIGINT) | |
135 | if (hostsig == SIGINT) | |
a493e3e2 | 136 | return GDB_SIGNAL_INT; |
0150732f DJ |
137 | #endif |
138 | #if defined (SIGQUIT) | |
139 | if (hostsig == SIGQUIT) | |
a493e3e2 | 140 | return GDB_SIGNAL_QUIT; |
0150732f DJ |
141 | #endif |
142 | #if defined (SIGILL) | |
143 | if (hostsig == SIGILL) | |
a493e3e2 | 144 | return GDB_SIGNAL_ILL; |
0150732f DJ |
145 | #endif |
146 | #if defined (SIGTRAP) | |
147 | if (hostsig == SIGTRAP) | |
a493e3e2 | 148 | return GDB_SIGNAL_TRAP; |
0150732f DJ |
149 | #endif |
150 | #if defined (SIGABRT) | |
151 | if (hostsig == SIGABRT) | |
a493e3e2 | 152 | return GDB_SIGNAL_ABRT; |
0150732f DJ |
153 | #endif |
154 | #if defined (SIGEMT) | |
155 | if (hostsig == SIGEMT) | |
a493e3e2 | 156 | return GDB_SIGNAL_EMT; |
0150732f DJ |
157 | #endif |
158 | #if defined (SIGFPE) | |
159 | if (hostsig == SIGFPE) | |
a493e3e2 | 160 | return GDB_SIGNAL_FPE; |
0150732f DJ |
161 | #endif |
162 | #if defined (SIGKILL) | |
163 | if (hostsig == SIGKILL) | |
a493e3e2 | 164 | return GDB_SIGNAL_KILL; |
0150732f DJ |
165 | #endif |
166 | #if defined (SIGBUS) | |
167 | if (hostsig == SIGBUS) | |
a493e3e2 | 168 | return GDB_SIGNAL_BUS; |
0150732f DJ |
169 | #endif |
170 | #if defined (SIGSEGV) | |
171 | if (hostsig == SIGSEGV) | |
a493e3e2 | 172 | return GDB_SIGNAL_SEGV; |
0150732f DJ |
173 | #endif |
174 | #if defined (SIGSYS) | |
175 | if (hostsig == SIGSYS) | |
a493e3e2 | 176 | return GDB_SIGNAL_SYS; |
0150732f DJ |
177 | #endif |
178 | #if defined (SIGPIPE) | |
179 | if (hostsig == SIGPIPE) | |
a493e3e2 | 180 | return GDB_SIGNAL_PIPE; |
0150732f DJ |
181 | #endif |
182 | #if defined (SIGALRM) | |
183 | if (hostsig == SIGALRM) | |
a493e3e2 | 184 | return GDB_SIGNAL_ALRM; |
0150732f DJ |
185 | #endif |
186 | #if defined (SIGTERM) | |
187 | if (hostsig == SIGTERM) | |
a493e3e2 | 188 | return GDB_SIGNAL_TERM; |
0150732f DJ |
189 | #endif |
190 | #if defined (SIGUSR1) | |
191 | if (hostsig == SIGUSR1) | |
a493e3e2 | 192 | return GDB_SIGNAL_USR1; |
0150732f DJ |
193 | #endif |
194 | #if defined (SIGUSR2) | |
195 | if (hostsig == SIGUSR2) | |
a493e3e2 | 196 | return GDB_SIGNAL_USR2; |
0150732f DJ |
197 | #endif |
198 | #if defined (SIGCLD) | |
199 | if (hostsig == SIGCLD) | |
a493e3e2 | 200 | return GDB_SIGNAL_CHLD; |
0150732f DJ |
201 | #endif |
202 | #if defined (SIGCHLD) | |
203 | if (hostsig == SIGCHLD) | |
a493e3e2 | 204 | return GDB_SIGNAL_CHLD; |
0150732f DJ |
205 | #endif |
206 | #if defined (SIGPWR) | |
207 | if (hostsig == SIGPWR) | |
a493e3e2 | 208 | return GDB_SIGNAL_PWR; |
0150732f DJ |
209 | #endif |
210 | #if defined (SIGWINCH) | |
211 | if (hostsig == SIGWINCH) | |
a493e3e2 | 212 | return GDB_SIGNAL_WINCH; |
0150732f DJ |
213 | #endif |
214 | #if defined (SIGURG) | |
215 | if (hostsig == SIGURG) | |
a493e3e2 | 216 | return GDB_SIGNAL_URG; |
0150732f DJ |
217 | #endif |
218 | #if defined (SIGIO) | |
219 | if (hostsig == SIGIO) | |
a493e3e2 | 220 | return GDB_SIGNAL_IO; |
0150732f DJ |
221 | #endif |
222 | #if defined (SIGPOLL) | |
223 | if (hostsig == SIGPOLL) | |
a493e3e2 | 224 | return GDB_SIGNAL_POLL; |
0150732f DJ |
225 | #endif |
226 | #if defined (SIGSTOP) | |
227 | if (hostsig == SIGSTOP) | |
a493e3e2 | 228 | return GDB_SIGNAL_STOP; |
0150732f DJ |
229 | #endif |
230 | #if defined (SIGTSTP) | |
231 | if (hostsig == SIGTSTP) | |
a493e3e2 | 232 | return GDB_SIGNAL_TSTP; |
0150732f DJ |
233 | #endif |
234 | #if defined (SIGCONT) | |
235 | if (hostsig == SIGCONT) | |
a493e3e2 | 236 | return GDB_SIGNAL_CONT; |
0150732f DJ |
237 | #endif |
238 | #if defined (SIGTTIN) | |
239 | if (hostsig == SIGTTIN) | |
a493e3e2 | 240 | return GDB_SIGNAL_TTIN; |
0150732f DJ |
241 | #endif |
242 | #if defined (SIGTTOU) | |
243 | if (hostsig == SIGTTOU) | |
a493e3e2 | 244 | return GDB_SIGNAL_TTOU; |
0150732f DJ |
245 | #endif |
246 | #if defined (SIGVTALRM) | |
247 | if (hostsig == SIGVTALRM) | |
a493e3e2 | 248 | return GDB_SIGNAL_VTALRM; |
0150732f DJ |
249 | #endif |
250 | #if defined (SIGPROF) | |
251 | if (hostsig == SIGPROF) | |
a493e3e2 | 252 | return GDB_SIGNAL_PROF; |
0150732f DJ |
253 | #endif |
254 | #if defined (SIGXCPU) | |
255 | if (hostsig == SIGXCPU) | |
a493e3e2 | 256 | return GDB_SIGNAL_XCPU; |
0150732f DJ |
257 | #endif |
258 | #if defined (SIGXFSZ) | |
259 | if (hostsig == SIGXFSZ) | |
a493e3e2 | 260 | return GDB_SIGNAL_XFSZ; |
0150732f DJ |
261 | #endif |
262 | #if defined (SIGWIND) | |
263 | if (hostsig == SIGWIND) | |
a493e3e2 | 264 | return GDB_SIGNAL_WIND; |
0150732f DJ |
265 | #endif |
266 | #if defined (SIGPHONE) | |
267 | if (hostsig == SIGPHONE) | |
a493e3e2 | 268 | return GDB_SIGNAL_PHONE; |
0150732f DJ |
269 | #endif |
270 | #if defined (SIGLOST) | |
271 | if (hostsig == SIGLOST) | |
a493e3e2 | 272 | return GDB_SIGNAL_LOST; |
0150732f DJ |
273 | #endif |
274 | #if defined (SIGWAITING) | |
275 | if (hostsig == SIGWAITING) | |
a493e3e2 | 276 | return GDB_SIGNAL_WAITING; |
0150732f DJ |
277 | #endif |
278 | #if defined (SIGCANCEL) | |
279 | if (hostsig == SIGCANCEL) | |
a493e3e2 | 280 | return GDB_SIGNAL_CANCEL; |
0150732f DJ |
281 | #endif |
282 | #if defined (SIGLWP) | |
283 | if (hostsig == SIGLWP) | |
a493e3e2 | 284 | return GDB_SIGNAL_LWP; |
0150732f DJ |
285 | #endif |
286 | #if defined (SIGDANGER) | |
287 | if (hostsig == SIGDANGER) | |
a493e3e2 | 288 | return GDB_SIGNAL_DANGER; |
0150732f DJ |
289 | #endif |
290 | #if defined (SIGGRANT) | |
291 | if (hostsig == SIGGRANT) | |
a493e3e2 | 292 | return GDB_SIGNAL_GRANT; |
0150732f DJ |
293 | #endif |
294 | #if defined (SIGRETRACT) | |
295 | if (hostsig == SIGRETRACT) | |
a493e3e2 | 296 | return GDB_SIGNAL_RETRACT; |
0150732f DJ |
297 | #endif |
298 | #if defined (SIGMSG) | |
299 | if (hostsig == SIGMSG) | |
a493e3e2 | 300 | return GDB_SIGNAL_MSG; |
0150732f DJ |
301 | #endif |
302 | #if defined (SIGSOUND) | |
303 | if (hostsig == SIGSOUND) | |
a493e3e2 | 304 | return GDB_SIGNAL_SOUND; |
0150732f DJ |
305 | #endif |
306 | #if defined (SIGSAK) | |
307 | if (hostsig == SIGSAK) | |
a493e3e2 | 308 | return GDB_SIGNAL_SAK; |
0150732f DJ |
309 | #endif |
310 | #if defined (SIGPRIO) | |
311 | if (hostsig == SIGPRIO) | |
a493e3e2 | 312 | return GDB_SIGNAL_PRIO; |
0150732f DJ |
313 | #endif |
314 | ||
315 | /* Mach exceptions. Assumes that the values for EXC_ are positive! */ | |
316 | #if defined (EXC_BAD_ACCESS) && defined (_NSIG) | |
317 | if (hostsig == _NSIG + EXC_BAD_ACCESS) | |
4e225075 | 318 | return GDB_EXC_BAD_ACCESS; |
0150732f DJ |
319 | #endif |
320 | #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG) | |
321 | if (hostsig == _NSIG + EXC_BAD_INSTRUCTION) | |
4e225075 | 322 | return GDB_EXC_BAD_INSTRUCTION; |
0150732f DJ |
323 | #endif |
324 | #if defined (EXC_ARITHMETIC) && defined (_NSIG) | |
325 | if (hostsig == _NSIG + EXC_ARITHMETIC) | |
4e225075 | 326 | return GDB_EXC_ARITHMETIC; |
0150732f DJ |
327 | #endif |
328 | #if defined (EXC_EMULATION) && defined (_NSIG) | |
329 | if (hostsig == _NSIG + EXC_EMULATION) | |
4e225075 | 330 | return GDB_EXC_EMULATION; |
0150732f DJ |
331 | #endif |
332 | #if defined (EXC_SOFTWARE) && defined (_NSIG) | |
333 | if (hostsig == _NSIG + EXC_SOFTWARE) | |
4e225075 | 334 | return GDB_EXC_SOFTWARE; |
0150732f DJ |
335 | #endif |
336 | #if defined (EXC_BREAKPOINT) && defined (_NSIG) | |
337 | if (hostsig == _NSIG + EXC_BREAKPOINT) | |
4e225075 | 338 | return GDB_EXC_BREAKPOINT; |
0150732f DJ |
339 | #endif |
340 | ||
341 | #if defined (SIGINFO) | |
342 | if (hostsig == SIGINFO) | |
a493e3e2 | 343 | return GDB_SIGNAL_INFO; |
0150732f DJ |
344 | #endif |
345 | ||
346 | #if defined (REALTIME_LO) | |
347 | if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI) | |
348 | { | |
a493e3e2 | 349 | /* This block of GDB_SIGNAL_REALTIME value is in order. */ |
0150732f | 350 | if (33 <= hostsig && hostsig <= 63) |
2ea28649 | 351 | return (enum gdb_signal) |
a493e3e2 | 352 | (hostsig - 33 + (int) GDB_SIGNAL_REALTIME_33); |
0150732f | 353 | else if (hostsig == 32) |
a493e3e2 | 354 | return GDB_SIGNAL_REALTIME_32; |
0150732f | 355 | else if (64 <= hostsig && hostsig <= 127) |
2ea28649 | 356 | return (enum gdb_signal) |
a493e3e2 | 357 | (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64); |
0150732f | 358 | else |
2ea28649 | 359 | error (_("GDB bug: target.c (gdb_signal_from_host): " |
9e0627f1 | 360 | "unrecognized real-time signal")); |
0150732f DJ |
361 | } |
362 | #endif | |
363 | ||
a493e3e2 | 364 | return GDB_SIGNAL_UNKNOWN; |
0150732f DJ |
365 | } |
366 | ||
2ea28649 | 367 | /* Convert a OURSIG (an enum gdb_signal) to the form used by the |
0150732f DJ |
368 | target operating system (refered to as the ``host'') or zero if the |
369 | equivalent host signal is not available. Set/clear OURSIG_OK | |
370 | accordingly. */ | |
371 | ||
372 | static int | |
2ea28649 | 373 | do_gdb_signal_to_host (enum gdb_signal oursig, |
0150732f DJ |
374 | int *oursig_ok) |
375 | { | |
f541410f | 376 | int retsig; |
68070c10 PA |
377 | /* Silence the 'not used' warning, for targets that |
378 | do not support signals. */ | |
379 | (void) retsig; | |
f541410f | 380 | |
0150732f DJ |
381 | *oursig_ok = 1; |
382 | switch (oursig) | |
383 | { | |
a493e3e2 | 384 | case GDB_SIGNAL_0: |
0150732f DJ |
385 | return 0; |
386 | ||
387 | #if defined (SIGHUP) | |
a493e3e2 | 388 | case GDB_SIGNAL_HUP: |
0150732f DJ |
389 | return SIGHUP; |
390 | #endif | |
391 | #if defined (SIGINT) | |
a493e3e2 | 392 | case GDB_SIGNAL_INT: |
0150732f DJ |
393 | return SIGINT; |
394 | #endif | |
395 | #if defined (SIGQUIT) | |
a493e3e2 | 396 | case GDB_SIGNAL_QUIT: |
0150732f DJ |
397 | return SIGQUIT; |
398 | #endif | |
399 | #if defined (SIGILL) | |
a493e3e2 | 400 | case GDB_SIGNAL_ILL: |
0150732f DJ |
401 | return SIGILL; |
402 | #endif | |
403 | #if defined (SIGTRAP) | |
a493e3e2 | 404 | case GDB_SIGNAL_TRAP: |
0150732f DJ |
405 | return SIGTRAP; |
406 | #endif | |
407 | #if defined (SIGABRT) | |
a493e3e2 | 408 | case GDB_SIGNAL_ABRT: |
0150732f DJ |
409 | return SIGABRT; |
410 | #endif | |
411 | #if defined (SIGEMT) | |
a493e3e2 | 412 | case GDB_SIGNAL_EMT: |
0150732f DJ |
413 | return SIGEMT; |
414 | #endif | |
415 | #if defined (SIGFPE) | |
a493e3e2 | 416 | case GDB_SIGNAL_FPE: |
0150732f DJ |
417 | return SIGFPE; |
418 | #endif | |
419 | #if defined (SIGKILL) | |
a493e3e2 | 420 | case GDB_SIGNAL_KILL: |
0150732f DJ |
421 | return SIGKILL; |
422 | #endif | |
423 | #if defined (SIGBUS) | |
a493e3e2 | 424 | case GDB_SIGNAL_BUS: |
0150732f DJ |
425 | return SIGBUS; |
426 | #endif | |
427 | #if defined (SIGSEGV) | |
a493e3e2 | 428 | case GDB_SIGNAL_SEGV: |
0150732f DJ |
429 | return SIGSEGV; |
430 | #endif | |
431 | #if defined (SIGSYS) | |
a493e3e2 | 432 | case GDB_SIGNAL_SYS: |
0150732f DJ |
433 | return SIGSYS; |
434 | #endif | |
435 | #if defined (SIGPIPE) | |
a493e3e2 | 436 | case GDB_SIGNAL_PIPE: |
0150732f DJ |
437 | return SIGPIPE; |
438 | #endif | |
439 | #if defined (SIGALRM) | |
a493e3e2 | 440 | case GDB_SIGNAL_ALRM: |
0150732f DJ |
441 | return SIGALRM; |
442 | #endif | |
443 | #if defined (SIGTERM) | |
a493e3e2 | 444 | case GDB_SIGNAL_TERM: |
0150732f DJ |
445 | return SIGTERM; |
446 | #endif | |
447 | #if defined (SIGUSR1) | |
a493e3e2 | 448 | case GDB_SIGNAL_USR1: |
0150732f DJ |
449 | return SIGUSR1; |
450 | #endif | |
451 | #if defined (SIGUSR2) | |
a493e3e2 | 452 | case GDB_SIGNAL_USR2: |
0150732f DJ |
453 | return SIGUSR2; |
454 | #endif | |
455 | #if defined (SIGCHLD) || defined (SIGCLD) | |
a493e3e2 | 456 | case GDB_SIGNAL_CHLD: |
0150732f DJ |
457 | #if defined (SIGCHLD) |
458 | return SIGCHLD; | |
459 | #else | |
460 | return SIGCLD; | |
461 | #endif | |
462 | #endif /* SIGCLD or SIGCHLD */ | |
463 | #if defined (SIGPWR) | |
a493e3e2 | 464 | case GDB_SIGNAL_PWR: |
0150732f DJ |
465 | return SIGPWR; |
466 | #endif | |
467 | #if defined (SIGWINCH) | |
a493e3e2 | 468 | case GDB_SIGNAL_WINCH: |
0150732f DJ |
469 | return SIGWINCH; |
470 | #endif | |
471 | #if defined (SIGURG) | |
a493e3e2 | 472 | case GDB_SIGNAL_URG: |
0150732f DJ |
473 | return SIGURG; |
474 | #endif | |
475 | #if defined (SIGIO) | |
a493e3e2 | 476 | case GDB_SIGNAL_IO: |
0150732f DJ |
477 | return SIGIO; |
478 | #endif | |
479 | #if defined (SIGPOLL) | |
a493e3e2 | 480 | case GDB_SIGNAL_POLL: |
0150732f DJ |
481 | return SIGPOLL; |
482 | #endif | |
483 | #if defined (SIGSTOP) | |
a493e3e2 | 484 | case GDB_SIGNAL_STOP: |
0150732f DJ |
485 | return SIGSTOP; |
486 | #endif | |
487 | #if defined (SIGTSTP) | |
a493e3e2 | 488 | case GDB_SIGNAL_TSTP: |
0150732f DJ |
489 | return SIGTSTP; |
490 | #endif | |
491 | #if defined (SIGCONT) | |
a493e3e2 | 492 | case GDB_SIGNAL_CONT: |
0150732f DJ |
493 | return SIGCONT; |
494 | #endif | |
495 | #if defined (SIGTTIN) | |
a493e3e2 | 496 | case GDB_SIGNAL_TTIN: |
0150732f DJ |
497 | return SIGTTIN; |
498 | #endif | |
499 | #if defined (SIGTTOU) | |
a493e3e2 | 500 | case GDB_SIGNAL_TTOU: |
0150732f DJ |
501 | return SIGTTOU; |
502 | #endif | |
503 | #if defined (SIGVTALRM) | |
a493e3e2 | 504 | case GDB_SIGNAL_VTALRM: |
0150732f DJ |
505 | return SIGVTALRM; |
506 | #endif | |
507 | #if defined (SIGPROF) | |
a493e3e2 | 508 | case GDB_SIGNAL_PROF: |
0150732f DJ |
509 | return SIGPROF; |
510 | #endif | |
511 | #if defined (SIGXCPU) | |
a493e3e2 | 512 | case GDB_SIGNAL_XCPU: |
0150732f DJ |
513 | return SIGXCPU; |
514 | #endif | |
515 | #if defined (SIGXFSZ) | |
a493e3e2 | 516 | case GDB_SIGNAL_XFSZ: |
0150732f DJ |
517 | return SIGXFSZ; |
518 | #endif | |
519 | #if defined (SIGWIND) | |
a493e3e2 | 520 | case GDB_SIGNAL_WIND: |
0150732f DJ |
521 | return SIGWIND; |
522 | #endif | |
523 | #if defined (SIGPHONE) | |
a493e3e2 | 524 | case GDB_SIGNAL_PHONE: |
0150732f DJ |
525 | return SIGPHONE; |
526 | #endif | |
527 | #if defined (SIGLOST) | |
a493e3e2 | 528 | case GDB_SIGNAL_LOST: |
0150732f DJ |
529 | return SIGLOST; |
530 | #endif | |
531 | #if defined (SIGWAITING) | |
a493e3e2 | 532 | case GDB_SIGNAL_WAITING: |
0150732f DJ |
533 | return SIGWAITING; |
534 | #endif | |
535 | #if defined (SIGCANCEL) | |
a493e3e2 | 536 | case GDB_SIGNAL_CANCEL: |
0150732f DJ |
537 | return SIGCANCEL; |
538 | #endif | |
539 | #if defined (SIGLWP) | |
a493e3e2 | 540 | case GDB_SIGNAL_LWP: |
0150732f DJ |
541 | return SIGLWP; |
542 | #endif | |
543 | #if defined (SIGDANGER) | |
a493e3e2 | 544 | case GDB_SIGNAL_DANGER: |
0150732f DJ |
545 | return SIGDANGER; |
546 | #endif | |
547 | #if defined (SIGGRANT) | |
a493e3e2 | 548 | case GDB_SIGNAL_GRANT: |
0150732f DJ |
549 | return SIGGRANT; |
550 | #endif | |
551 | #if defined (SIGRETRACT) | |
a493e3e2 | 552 | case GDB_SIGNAL_RETRACT: |
0150732f DJ |
553 | return SIGRETRACT; |
554 | #endif | |
555 | #if defined (SIGMSG) | |
a493e3e2 | 556 | case GDB_SIGNAL_MSG: |
0150732f DJ |
557 | return SIGMSG; |
558 | #endif | |
559 | #if defined (SIGSOUND) | |
a493e3e2 | 560 | case GDB_SIGNAL_SOUND: |
0150732f DJ |
561 | return SIGSOUND; |
562 | #endif | |
563 | #if defined (SIGSAK) | |
a493e3e2 | 564 | case GDB_SIGNAL_SAK: |
0150732f DJ |
565 | return SIGSAK; |
566 | #endif | |
567 | #if defined (SIGPRIO) | |
a493e3e2 | 568 | case GDB_SIGNAL_PRIO: |
0150732f DJ |
569 | return SIGPRIO; |
570 | #endif | |
571 | ||
572 | /* Mach exceptions. Assumes that the values for EXC_ are positive! */ | |
573 | #if defined (EXC_BAD_ACCESS) && defined (_NSIG) | |
4e225075 | 574 | case GDB_EXC_BAD_ACCESS: |
0150732f DJ |
575 | return _NSIG + EXC_BAD_ACCESS; |
576 | #endif | |
577 | #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG) | |
4e225075 | 578 | case GDB_EXC_BAD_INSTRUCTION: |
0150732f DJ |
579 | return _NSIG + EXC_BAD_INSTRUCTION; |
580 | #endif | |
581 | #if defined (EXC_ARITHMETIC) && defined (_NSIG) | |
4e225075 | 582 | case GDB_EXC_ARITHMETIC: |
0150732f DJ |
583 | return _NSIG + EXC_ARITHMETIC; |
584 | #endif | |
585 | #if defined (EXC_EMULATION) && defined (_NSIG) | |
4e225075 | 586 | case GDB_EXC_EMULATION: |
0150732f DJ |
587 | return _NSIG + EXC_EMULATION; |
588 | #endif | |
589 | #if defined (EXC_SOFTWARE) && defined (_NSIG) | |
4e225075 | 590 | case GDB_EXC_SOFTWARE: |
0150732f DJ |
591 | return _NSIG + EXC_SOFTWARE; |
592 | #endif | |
593 | #if defined (EXC_BREAKPOINT) && defined (_NSIG) | |
4e225075 | 594 | case GDB_EXC_BREAKPOINT: |
0150732f DJ |
595 | return _NSIG + EXC_BREAKPOINT; |
596 | #endif | |
597 | ||
598 | #if defined (SIGINFO) | |
a493e3e2 | 599 | case GDB_SIGNAL_INFO: |
0150732f DJ |
600 | return SIGINFO; |
601 | #endif | |
602 | ||
603 | default: | |
604 | #if defined (REALTIME_LO) | |
f541410f | 605 | retsig = 0; |
0150732f | 606 | |
a493e3e2 PA |
607 | if (oursig >= GDB_SIGNAL_REALTIME_33 |
608 | && oursig <= GDB_SIGNAL_REALTIME_63) | |
0150732f DJ |
609 | { |
610 | /* This block of signals is continuous, and | |
a493e3e2 PA |
611 | GDB_SIGNAL_REALTIME_33 is 33 by definition. */ |
612 | retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_33 + 33; | |
0150732f | 613 | } |
a493e3e2 | 614 | else if (oursig == GDB_SIGNAL_REALTIME_32) |
2f2cf184 | 615 | { |
a493e3e2 PA |
616 | /* GDB_SIGNAL_REALTIME_32 isn't contiguous with |
617 | GDB_SIGNAL_REALTIME_33. It is 32 by definition. */ | |
f541410f | 618 | retsig = 32; |
2f2cf184 | 619 | } |
a493e3e2 PA |
620 | else if (oursig >= GDB_SIGNAL_REALTIME_64 |
621 | && oursig <= GDB_SIGNAL_REALTIME_127) | |
2f2cf184 DJ |
622 | { |
623 | /* This block of signals is continuous, and | |
a493e3e2 PA |
624 | GDB_SIGNAL_REALTIME_64 is 64 by definition. */ |
625 | retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_64 + 64; | |
2f2cf184 | 626 | } |
f541410f DJ |
627 | |
628 | if (retsig >= REALTIME_LO && retsig < REALTIME_HI) | |
629 | return retsig; | |
0150732f | 630 | #endif |
960cb555 | 631 | |
0150732f DJ |
632 | *oursig_ok = 0; |
633 | return 0; | |
634 | } | |
635 | } | |
636 | ||
637 | int | |
2ea28649 | 638 | gdb_signal_to_host_p (enum gdb_signal oursig) |
0150732f DJ |
639 | { |
640 | int oursig_ok; | |
2ea28649 | 641 | do_gdb_signal_to_host (oursig, &oursig_ok); |
0150732f DJ |
642 | return oursig_ok; |
643 | } | |
644 | ||
645 | int | |
2ea28649 | 646 | gdb_signal_to_host (enum gdb_signal oursig) |
0150732f DJ |
647 | { |
648 | int oursig_ok; | |
2ea28649 | 649 | int targ_signo = do_gdb_signal_to_host (oursig, &oursig_ok); |
0150732f DJ |
650 | if (!oursig_ok) |
651 | { | |
652 | /* The user might be trying to do "signal SIGSAK" where this system | |
653 | doesn't have SIGSAK. */ | |
9e0627f1 | 654 | warning (_("Signal %s does not exist on this system."), |
2ea28649 | 655 | gdb_signal_to_name (oursig)); |
0150732f DJ |
656 | return 0; |
657 | } | |
658 | else | |
659 | return targ_signo; | |
660 | } |