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