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