OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [signals/] [signals.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
/* Target signal translation functions for GDB.
2
   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3
   2000, 2001, 2002 Free Software Foundation, Inc.
4
   Contributed by Cygnus Support.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 2 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 59 Temple Place - Suite 330,
21
   Boston, MA 02111-1307, USA.  */
22
 
23
#ifdef GDBSERVER
24
#include "server.h"
25
#else
26
#include "defs.h"
27
#include "target.h"
28
#include "gdb_string.h"
29
#endif
30
 
31
#include <signal.h>
32
 
33
/* This table must match in order and size the signals in enum target_signal
34
   in target.h.  */
35
/* *INDENT-OFF* */
36
static struct {
37
  char *name;
38
  char *string;
39
  } signals [] =
40
{
41
  {"0", "Signal 0"},
42
  {"SIGHUP", "Hangup"},
43
  {"SIGINT", "Interrupt"},
44
  {"SIGQUIT", "Quit"},
45
  {"SIGILL", "Illegal instruction"},
46
  {"SIGTRAP", "Trace/breakpoint trap"},
47
  {"SIGABRT", "Aborted"},
48
  {"SIGEMT", "Emulation trap"},
49
  {"SIGFPE", "Arithmetic exception"},
50
  {"SIGKILL", "Killed"},
51
  {"SIGBUS", "Bus error"},
52
  {"SIGSEGV", "Segmentation fault"},
53
  {"SIGSYS", "Bad system call"},
54
  {"SIGPIPE", "Broken pipe"},
55
  {"SIGALRM", "Alarm clock"},
56
  {"SIGTERM", "Terminated"},
57
  {"SIGURG", "Urgent I/O condition"},
58
  {"SIGSTOP", "Stopped (signal)"},
59
  {"SIGTSTP", "Stopped (user)"},
60
  {"SIGCONT", "Continued"},
61
  {"SIGCHLD", "Child status changed"},
62
  {"SIGTTIN", "Stopped (tty input)"},
63
  {"SIGTTOU", "Stopped (tty output)"},
64
  {"SIGIO", "I/O possible"},
65
  {"SIGXCPU", "CPU time limit exceeded"},
66
  {"SIGXFSZ", "File size limit exceeded"},
67
  {"SIGVTALRM", "Virtual timer expired"},
68
  {"SIGPROF", "Profiling timer expired"},
69
  {"SIGWINCH", "Window size changed"},
70
  {"SIGLOST", "Resource lost"},
71
  {"SIGUSR1", "User defined signal 1"},
72
  {"SIGUSR2", "User defined signal 2"},
73
  {"SIGPWR", "Power fail/restart"},
74
  {"SIGPOLL", "Pollable event occurred"},
75
  {"SIGWIND", "SIGWIND"},
76
  {"SIGPHONE", "SIGPHONE"},
77
  {"SIGWAITING", "Process's LWPs are blocked"},
78
  {"SIGLWP", "Signal LWP"},
79
  {"SIGDANGER", "Swap space dangerously low"},
80
  {"SIGGRANT", "Monitor mode granted"},
81
  {"SIGRETRACT", "Need to relinquish monitor mode"},
82
  {"SIGMSG", "Monitor mode data available"},
83
  {"SIGSOUND", "Sound completed"},
84
  {"SIGSAK", "Secure attention"},
85
  {"SIGPRIO", "SIGPRIO"},
86
  {"SIG33", "Real-time event 33"},
87
  {"SIG34", "Real-time event 34"},
88
  {"SIG35", "Real-time event 35"},
89
  {"SIG36", "Real-time event 36"},
90
  {"SIG37", "Real-time event 37"},
91
  {"SIG38", "Real-time event 38"},
92
  {"SIG39", "Real-time event 39"},
93
  {"SIG40", "Real-time event 40"},
94
  {"SIG41", "Real-time event 41"},
95
  {"SIG42", "Real-time event 42"},
96
  {"SIG43", "Real-time event 43"},
97
  {"SIG44", "Real-time event 44"},
98
  {"SIG45", "Real-time event 45"},
99
  {"SIG46", "Real-time event 46"},
100
  {"SIG47", "Real-time event 47"},
101
  {"SIG48", "Real-time event 48"},
102
  {"SIG49", "Real-time event 49"},
103
  {"SIG50", "Real-time event 50"},
104
  {"SIG51", "Real-time event 51"},
105
  {"SIG52", "Real-time event 52"},
106
  {"SIG53", "Real-time event 53"},
107
  {"SIG54", "Real-time event 54"},
108
  {"SIG55", "Real-time event 55"},
109
  {"SIG56", "Real-time event 56"},
110
  {"SIG57", "Real-time event 57"},
111
  {"SIG58", "Real-time event 58"},
112
  {"SIG59", "Real-time event 59"},
113
  {"SIG60", "Real-time event 60"},
114
  {"SIG61", "Real-time event 61"},
115
  {"SIG62", "Real-time event 62"},
116
  {"SIG63", "Real-time event 63"},
117
  {"SIGCANCEL", "LWP internal signal"},
118
  {"SIG32", "Real-time event 32"},
119
  {"SIG64", "Real-time event 64"},
120
  {"SIG65", "Real-time event 65"},
121
  {"SIG66", "Real-time event 66"},
122
  {"SIG67", "Real-time event 67"},
123
  {"SIG68", "Real-time event 68"},
124
  {"SIG69", "Real-time event 69"},
125
  {"SIG70", "Real-time event 70"},
126
  {"SIG71", "Real-time event 71"},
127
  {"SIG72", "Real-time event 72"},
128
  {"SIG73", "Real-time event 73"},
129
  {"SIG74", "Real-time event 74"},
130
  {"SIG75", "Real-time event 75"},
131
  {"SIG76", "Real-time event 76"},
132
  {"SIG77", "Real-time event 77"},
133
  {"SIG78", "Real-time event 78"},
134
  {"SIG79", "Real-time event 79"},
135
  {"SIG80", "Real-time event 80"},
136
  {"SIG81", "Real-time event 81"},
137
  {"SIG82", "Real-time event 82"},
138
  {"SIG83", "Real-time event 83"},
139
  {"SIG84", "Real-time event 84"},
140
  {"SIG85", "Real-time event 85"},
141
  {"SIG86", "Real-time event 86"},
142
  {"SIG87", "Real-time event 87"},
143
  {"SIG88", "Real-time event 88"},
144
  {"SIG89", "Real-time event 89"},
145
  {"SIG90", "Real-time event 90"},
146
  {"SIG91", "Real-time event 91"},
147
  {"SIG92", "Real-time event 92"},
148
  {"SIG93", "Real-time event 93"},
149
  {"SIG94", "Real-time event 94"},
150
  {"SIG95", "Real-time event 95"},
151
  {"SIG96", "Real-time event 96"},
152
  {"SIG97", "Real-time event 97"},
153
  {"SIG98", "Real-time event 98"},
154
  {"SIG99", "Real-time event 99"},
155
  {"SIG100", "Real-time event 100"},
156
  {"SIG101", "Real-time event 101"},
157
  {"SIG102", "Real-time event 102"},
158
  {"SIG103", "Real-time event 103"},
159
  {"SIG104", "Real-time event 104"},
160
  {"SIG105", "Real-time event 105"},
161
  {"SIG106", "Real-time event 106"},
162
  {"SIG107", "Real-time event 107"},
163
  {"SIG108", "Real-time event 108"},
164
  {"SIG109", "Real-time event 109"},
165
  {"SIG110", "Real-time event 110"},
166
  {"SIG111", "Real-time event 111"},
167
  {"SIG112", "Real-time event 112"},
168
  {"SIG113", "Real-time event 113"},
169
  {"SIG114", "Real-time event 114"},
170
  {"SIG115", "Real-time event 115"},
171
  {"SIG116", "Real-time event 116"},
172
  {"SIG117", "Real-time event 117"},
173
  {"SIG118", "Real-time event 118"},
174
  {"SIG119", "Real-time event 119"},
175
  {"SIG120", "Real-time event 120"},
176
  {"SIG121", "Real-time event 121"},
177
  {"SIG122", "Real-time event 122"},
178
  {"SIG123", "Real-time event 123"},
179
  {"SIG124", "Real-time event 124"},
180
  {"SIG125", "Real-time event 125"},
181
  {"SIG126", "Real-time event 126"},
182
  {"SIG127", "Real-time event 127"},
183
 
184
  {"SIGINFO", "Information request"},
185
 
186
  {NULL, "Unknown signal"},
187
  {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
188
 
189
  /* Mach exceptions */
190
  {"EXC_BAD_ACCESS", "Could not access memory"},
191
  {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
192
  {"EXC_ARITHMETIC", "Arithmetic exception"},
193
  {"EXC_EMULATION", "Emulation instruction"},
194
  {"EXC_SOFTWARE", "Software generated exception"},
195
  {"EXC_BREAKPOINT", "Breakpoint"},
196
 
197
  /* Last entry, used to check whether the table is the right size.  */
198
  {NULL, "TARGET_SIGNAL_MAGIC"}
199
};
200
/* *INDENT-ON* */
201
 
202
 
203
 
204
/* Return the string for a signal.  */
205
char *
206
target_signal_to_string (enum target_signal sig)
207
{
208
  if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
209
    return signals[sig].string;
210
  else
211
    return signals[TARGET_SIGNAL_UNKNOWN].string;
212
}
213
 
214
/* Return the name for a signal.  */
215
char *
216
target_signal_to_name (enum target_signal sig)
217
{
218
  if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST)
219
      && signals[sig].name != NULL)
220
    return signals[sig].name;
221
  else
222
    /* I think the code which prints this will always print it along
223
       with the string, so no need to be verbose (very old comment).  */
224
    return "?";
225
}
226
 
227
/* Given a name, return its signal.  */
228
enum target_signal
229
target_signal_from_name (char *name)
230
{
231
  enum target_signal sig;
232
 
233
  /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
234
     for TARGET_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
235
     questionable; seems like by now people should call it SIGABRT
236
     instead.  */
237
 
238
  /* This ugly cast brought to you by the native VAX compiler.  */
239
  for (sig = TARGET_SIGNAL_HUP;
240
       sig < TARGET_SIGNAL_LAST;
241
       sig = (enum target_signal) ((int) sig + 1))
242
    if (signals[sig].name != NULL
243
        && strcmp (name, signals[sig].name) == 0)
244
      return sig;
245
  return TARGET_SIGNAL_UNKNOWN;
246
}
247
 
248
/* The following functions are to help certain targets deal
249
   with the signal/waitstatus stuff.  They could just as well be in
250
   a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
251
 
252
/* Convert host signal to our signals.  */
253
enum target_signal
254
target_signal_from_host (int hostsig)
255
{
256
  /* A switch statement would make sense but would require special kludges
257
     to deal with the cases where more than one signal has the same number.  */
258
 
259
  if (hostsig == 0)
260
    return TARGET_SIGNAL_0;
261
 
262
#if defined (SIGHUP)
263
  if (hostsig == SIGHUP)
264
    return TARGET_SIGNAL_HUP;
265
#endif
266
#if defined (SIGINT)
267
  if (hostsig == SIGINT)
268
    return TARGET_SIGNAL_INT;
269
#endif
270
#if defined (SIGQUIT)
271
  if (hostsig == SIGQUIT)
272
    return TARGET_SIGNAL_QUIT;
273
#endif
274
#if defined (SIGILL)
275
  if (hostsig == SIGILL)
276
    return TARGET_SIGNAL_ILL;
277
#endif
278
#if defined (SIGTRAP)
279
  if (hostsig == SIGTRAP)
280
    return TARGET_SIGNAL_TRAP;
281
#endif
282
#if defined (SIGABRT)
283
  if (hostsig == SIGABRT)
284
    return TARGET_SIGNAL_ABRT;
285
#endif
286
#if defined (SIGEMT)
287
  if (hostsig == SIGEMT)
288
    return TARGET_SIGNAL_EMT;
289
#endif
290
#if defined (SIGFPE)
291
  if (hostsig == SIGFPE)
292
    return TARGET_SIGNAL_FPE;
293
#endif
294
#if defined (SIGKILL)
295
  if (hostsig == SIGKILL)
296
    return TARGET_SIGNAL_KILL;
297
#endif
298
#if defined (SIGBUS)
299
  if (hostsig == SIGBUS)
300
    return TARGET_SIGNAL_BUS;
301
#endif
302
#if defined (SIGSEGV)
303
  if (hostsig == SIGSEGV)
304
    return TARGET_SIGNAL_SEGV;
305
#endif
306
#if defined (SIGSYS)
307
  if (hostsig == SIGSYS)
308
    return TARGET_SIGNAL_SYS;
309
#endif
310
#if defined (SIGPIPE)
311
  if (hostsig == SIGPIPE)
312
    return TARGET_SIGNAL_PIPE;
313
#endif
314
#if defined (SIGALRM)
315
  if (hostsig == SIGALRM)
316
    return TARGET_SIGNAL_ALRM;
317
#endif
318
#if defined (SIGTERM)
319
  if (hostsig == SIGTERM)
320
    return TARGET_SIGNAL_TERM;
321
#endif
322
#if defined (SIGUSR1)
323
  if (hostsig == SIGUSR1)
324
    return TARGET_SIGNAL_USR1;
325
#endif
326
#if defined (SIGUSR2)
327
  if (hostsig == SIGUSR2)
328
    return TARGET_SIGNAL_USR2;
329
#endif
330
#if defined (SIGCLD)
331
  if (hostsig == SIGCLD)
332
    return TARGET_SIGNAL_CHLD;
333
#endif
334
#if defined (SIGCHLD)
335
  if (hostsig == SIGCHLD)
336
    return TARGET_SIGNAL_CHLD;
337
#endif
338
#if defined (SIGPWR)
339
  if (hostsig == SIGPWR)
340
    return TARGET_SIGNAL_PWR;
341
#endif
342
#if defined (SIGWINCH)
343
  if (hostsig == SIGWINCH)
344
    return TARGET_SIGNAL_WINCH;
345
#endif
346
#if defined (SIGURG)
347
  if (hostsig == SIGURG)
348
    return TARGET_SIGNAL_URG;
349
#endif
350
#if defined (SIGIO)
351
  if (hostsig == SIGIO)
352
    return TARGET_SIGNAL_IO;
353
#endif
354
#if defined (SIGPOLL)
355
  if (hostsig == SIGPOLL)
356
    return TARGET_SIGNAL_POLL;
357
#endif
358
#if defined (SIGSTOP)
359
  if (hostsig == SIGSTOP)
360
    return TARGET_SIGNAL_STOP;
361
#endif
362
#if defined (SIGTSTP)
363
  if (hostsig == SIGTSTP)
364
    return TARGET_SIGNAL_TSTP;
365
#endif
366
#if defined (SIGCONT)
367
  if (hostsig == SIGCONT)
368
    return TARGET_SIGNAL_CONT;
369
#endif
370
#if defined (SIGTTIN)
371
  if (hostsig == SIGTTIN)
372
    return TARGET_SIGNAL_TTIN;
373
#endif
374
#if defined (SIGTTOU)
375
  if (hostsig == SIGTTOU)
376
    return TARGET_SIGNAL_TTOU;
377
#endif
378
#if defined (SIGVTALRM)
379
  if (hostsig == SIGVTALRM)
380
    return TARGET_SIGNAL_VTALRM;
381
#endif
382
#if defined (SIGPROF)
383
  if (hostsig == SIGPROF)
384
    return TARGET_SIGNAL_PROF;
385
#endif
386
#if defined (SIGXCPU)
387
  if (hostsig == SIGXCPU)
388
    return TARGET_SIGNAL_XCPU;
389
#endif
390
#if defined (SIGXFSZ)
391
  if (hostsig == SIGXFSZ)
392
    return TARGET_SIGNAL_XFSZ;
393
#endif
394
#if defined (SIGWIND)
395
  if (hostsig == SIGWIND)
396
    return TARGET_SIGNAL_WIND;
397
#endif
398
#if defined (SIGPHONE)
399
  if (hostsig == SIGPHONE)
400
    return TARGET_SIGNAL_PHONE;
401
#endif
402
#if defined (SIGLOST)
403
  if (hostsig == SIGLOST)
404
    return TARGET_SIGNAL_LOST;
405
#endif
406
#if defined (SIGWAITING)
407
  if (hostsig == SIGWAITING)
408
    return TARGET_SIGNAL_WAITING;
409
#endif
410
#if defined (SIGCANCEL)
411
  if (hostsig == SIGCANCEL)
412
    return TARGET_SIGNAL_CANCEL;
413
#endif
414
#if defined (SIGLWP)
415
  if (hostsig == SIGLWP)
416
    return TARGET_SIGNAL_LWP;
417
#endif
418
#if defined (SIGDANGER)
419
  if (hostsig == SIGDANGER)
420
    return TARGET_SIGNAL_DANGER;
421
#endif
422
#if defined (SIGGRANT)
423
  if (hostsig == SIGGRANT)
424
    return TARGET_SIGNAL_GRANT;
425
#endif
426
#if defined (SIGRETRACT)
427
  if (hostsig == SIGRETRACT)
428
    return TARGET_SIGNAL_RETRACT;
429
#endif
430
#if defined (SIGMSG)
431
  if (hostsig == SIGMSG)
432
    return TARGET_SIGNAL_MSG;
433
#endif
434
#if defined (SIGSOUND)
435
  if (hostsig == SIGSOUND)
436
    return TARGET_SIGNAL_SOUND;
437
#endif
438
#if defined (SIGSAK)
439
  if (hostsig == SIGSAK)
440
    return TARGET_SIGNAL_SAK;
441
#endif
442
#if defined (SIGPRIO)
443
  if (hostsig == SIGPRIO)
444
    return TARGET_SIGNAL_PRIO;
445
#endif
446
 
447
  /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
448
#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
449
  if (hostsig == _NSIG + EXC_BAD_ACCESS)
450
    return TARGET_EXC_BAD_ACCESS;
451
#endif
452
#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
453
  if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
454
    return TARGET_EXC_BAD_INSTRUCTION;
455
#endif
456
#if defined (EXC_ARITHMETIC) && defined (_NSIG)
457
  if (hostsig == _NSIG + EXC_ARITHMETIC)
458
    return TARGET_EXC_ARITHMETIC;
459
#endif
460
#if defined (EXC_EMULATION) && defined (_NSIG)
461
  if (hostsig == _NSIG + EXC_EMULATION)
462
    return TARGET_EXC_EMULATION;
463
#endif
464
#if defined (EXC_SOFTWARE) && defined (_NSIG)
465
  if (hostsig == _NSIG + EXC_SOFTWARE)
466
    return TARGET_EXC_SOFTWARE;
467
#endif
468
#if defined (EXC_BREAKPOINT) && defined (_NSIG)
469
  if (hostsig == _NSIG + EXC_BREAKPOINT)
470
    return TARGET_EXC_BREAKPOINT;
471
#endif
472
 
473
#if defined (SIGINFO)
474
  if (hostsig == SIGINFO)
475
    return TARGET_SIGNAL_INFO;
476
#endif
477
 
478
#if defined (REALTIME_LO)
479
  if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
480
    {
481
      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
482
      if (33 <= hostsig && hostsig <= 63)
483
        return (enum target_signal)
484
          (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
485
      else if (hostsig == 32)
486
        return TARGET_SIGNAL_REALTIME_32;
487
      else if (64 <= hostsig && hostsig <= 127)
488
        return (enum target_signal)
489
          (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
490
      else
491
        error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
492
    }
493
#endif
494
 
495
#if defined (SIGRTMIN)
496
  if (hostsig >= SIGRTMIN && hostsig <= SIGRTMAX)
497
    {
498
      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
499
      if (33 <= hostsig && hostsig <= 63)
500
        return (enum target_signal)
501
          (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
502
      else if (hostsig == 32)
503
        return TARGET_SIGNAL_REALTIME_32;
504
      else if (64 <= hostsig && hostsig <= 127)
505
        return (enum target_signal)
506
          (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
507
      else
508
        error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
509
    }
510
#endif
511
  return TARGET_SIGNAL_UNKNOWN;
512
}
513
 
514
/* Convert a OURSIG (an enum target_signal) to the form used by the
515
   target operating system (refered to as the ``host'') or zero if the
516
   equivalent host signal is not available.  Set/clear OURSIG_OK
517
   accordingly. */
518
 
519
static int
520
do_target_signal_to_host (enum target_signal oursig,
521
                          int *oursig_ok)
522
{
523
  *oursig_ok = 1;
524
  switch (oursig)
525
    {
526
    case TARGET_SIGNAL_0:
527
      return 0;
528
 
529
#if defined (SIGHUP)
530
    case TARGET_SIGNAL_HUP:
531
      return SIGHUP;
532
#endif
533
#if defined (SIGINT)
534
    case TARGET_SIGNAL_INT:
535
      return SIGINT;
536
#endif
537
#if defined (SIGQUIT)
538
    case TARGET_SIGNAL_QUIT:
539
      return SIGQUIT;
540
#endif
541
#if defined (SIGILL)
542
    case TARGET_SIGNAL_ILL:
543
      return SIGILL;
544
#endif
545
#if defined (SIGTRAP)
546
    case TARGET_SIGNAL_TRAP:
547
      return SIGTRAP;
548
#endif
549
#if defined (SIGABRT)
550
    case TARGET_SIGNAL_ABRT:
551
      return SIGABRT;
552
#endif
553
#if defined (SIGEMT)
554
    case TARGET_SIGNAL_EMT:
555
      return SIGEMT;
556
#endif
557
#if defined (SIGFPE)
558
    case TARGET_SIGNAL_FPE:
559
      return SIGFPE;
560
#endif
561
#if defined (SIGKILL)
562
    case TARGET_SIGNAL_KILL:
563
      return SIGKILL;
564
#endif
565
#if defined (SIGBUS)
566
    case TARGET_SIGNAL_BUS:
567
      return SIGBUS;
568
#endif
569
#if defined (SIGSEGV)
570
    case TARGET_SIGNAL_SEGV:
571
      return SIGSEGV;
572
#endif
573
#if defined (SIGSYS)
574
    case TARGET_SIGNAL_SYS:
575
      return SIGSYS;
576
#endif
577
#if defined (SIGPIPE)
578
    case TARGET_SIGNAL_PIPE:
579
      return SIGPIPE;
580
#endif
581
#if defined (SIGALRM)
582
    case TARGET_SIGNAL_ALRM:
583
      return SIGALRM;
584
#endif
585
#if defined (SIGTERM)
586
    case TARGET_SIGNAL_TERM:
587
      return SIGTERM;
588
#endif
589
#if defined (SIGUSR1)
590
    case TARGET_SIGNAL_USR1:
591
      return SIGUSR1;
592
#endif
593
#if defined (SIGUSR2)
594
    case TARGET_SIGNAL_USR2:
595
      return SIGUSR2;
596
#endif
597
#if defined (SIGCHLD) || defined (SIGCLD)
598
    case TARGET_SIGNAL_CHLD:
599
#if defined (SIGCHLD)
600
      return SIGCHLD;
601
#else
602
      return SIGCLD;
603
#endif
604
#endif /* SIGCLD or SIGCHLD */
605
#if defined (SIGPWR)
606
    case TARGET_SIGNAL_PWR:
607
      return SIGPWR;
608
#endif
609
#if defined (SIGWINCH)
610
    case TARGET_SIGNAL_WINCH:
611
      return SIGWINCH;
612
#endif
613
#if defined (SIGURG)
614
    case TARGET_SIGNAL_URG:
615
      return SIGURG;
616
#endif
617
#if defined (SIGIO)
618
    case TARGET_SIGNAL_IO:
619
      return SIGIO;
620
#endif
621
#if defined (SIGPOLL)
622
    case TARGET_SIGNAL_POLL:
623
      return SIGPOLL;
624
#endif
625
#if defined (SIGSTOP)
626
    case TARGET_SIGNAL_STOP:
627
      return SIGSTOP;
628
#endif
629
#if defined (SIGTSTP)
630
    case TARGET_SIGNAL_TSTP:
631
      return SIGTSTP;
632
#endif
633
#if defined (SIGCONT)
634
    case TARGET_SIGNAL_CONT:
635
      return SIGCONT;
636
#endif
637
#if defined (SIGTTIN)
638
    case TARGET_SIGNAL_TTIN:
639
      return SIGTTIN;
640
#endif
641
#if defined (SIGTTOU)
642
    case TARGET_SIGNAL_TTOU:
643
      return SIGTTOU;
644
#endif
645
#if defined (SIGVTALRM)
646
    case TARGET_SIGNAL_VTALRM:
647
      return SIGVTALRM;
648
#endif
649
#if defined (SIGPROF)
650
    case TARGET_SIGNAL_PROF:
651
      return SIGPROF;
652
#endif
653
#if defined (SIGXCPU)
654
    case TARGET_SIGNAL_XCPU:
655
      return SIGXCPU;
656
#endif
657
#if defined (SIGXFSZ)
658
    case TARGET_SIGNAL_XFSZ:
659
      return SIGXFSZ;
660
#endif
661
#if defined (SIGWIND)
662
    case TARGET_SIGNAL_WIND:
663
      return SIGWIND;
664
#endif
665
#if defined (SIGPHONE)
666
    case TARGET_SIGNAL_PHONE:
667
      return SIGPHONE;
668
#endif
669
#if defined (SIGLOST)
670
    case TARGET_SIGNAL_LOST:
671
      return SIGLOST;
672
#endif
673
#if defined (SIGWAITING)
674
    case TARGET_SIGNAL_WAITING:
675
      return SIGWAITING;
676
#endif
677
#if defined (SIGCANCEL)
678
    case TARGET_SIGNAL_CANCEL:
679
      return SIGCANCEL;
680
#endif
681
#if defined (SIGLWP)
682
    case TARGET_SIGNAL_LWP:
683
      return SIGLWP;
684
#endif
685
#if defined (SIGDANGER)
686
    case TARGET_SIGNAL_DANGER:
687
      return SIGDANGER;
688
#endif
689
#if defined (SIGGRANT)
690
    case TARGET_SIGNAL_GRANT:
691
      return SIGGRANT;
692
#endif
693
#if defined (SIGRETRACT)
694
    case TARGET_SIGNAL_RETRACT:
695
      return SIGRETRACT;
696
#endif
697
#if defined (SIGMSG)
698
    case TARGET_SIGNAL_MSG:
699
      return SIGMSG;
700
#endif
701
#if defined (SIGSOUND)
702
    case TARGET_SIGNAL_SOUND:
703
      return SIGSOUND;
704
#endif
705
#if defined (SIGSAK)
706
    case TARGET_SIGNAL_SAK:
707
      return SIGSAK;
708
#endif
709
#if defined (SIGPRIO)
710
    case TARGET_SIGNAL_PRIO:
711
      return SIGPRIO;
712
#endif
713
 
714
      /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
715
#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
716
    case TARGET_EXC_BAD_ACCESS:
717
      return _NSIG + EXC_BAD_ACCESS;
718
#endif
719
#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
720
    case TARGET_EXC_BAD_INSTRUCTION:
721
      return _NSIG + EXC_BAD_INSTRUCTION;
722
#endif
723
#if defined (EXC_ARITHMETIC) && defined (_NSIG)
724
    case TARGET_EXC_ARITHMETIC:
725
      return _NSIG + EXC_ARITHMETIC;
726
#endif
727
#if defined (EXC_EMULATION) && defined (_NSIG)
728
    case TARGET_EXC_EMULATION:
729
      return _NSIG + EXC_EMULATION;
730
#endif
731
#if defined (EXC_SOFTWARE) && defined (_NSIG)
732
    case TARGET_EXC_SOFTWARE:
733
      return _NSIG + EXC_SOFTWARE;
734
#endif
735
#if defined (EXC_BREAKPOINT) && defined (_NSIG)
736
    case TARGET_EXC_BREAKPOINT:
737
      return _NSIG + EXC_BREAKPOINT;
738
#endif
739
 
740
#if defined (SIGINFO)
741
    case TARGET_SIGNAL_INFO:
742
      return SIGINFO;
743
#endif
744
 
745
    default:
746
#if defined (REALTIME_LO)
747
      if (oursig >= TARGET_SIGNAL_REALTIME_33
748
          && oursig <= TARGET_SIGNAL_REALTIME_63)
749
        {
750
          /* This block of signals is continuous, and
751
             TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
752
          int retsig =
753
            (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
754
          if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
755
            return retsig;
756
        }
757
#if (REALTIME_LO < 33)
758
      else if (oursig == TARGET_SIGNAL_REALTIME_32)
759
        {
760
          /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
761
             TARGET_SIGNAL_REALTIME_33.  It is 32 by definition.  */
762
          return 32;
763
        }
764
#endif
765
#if (REALTIME_HI > 64)
766
      if (oursig >= TARGET_SIGNAL_REALTIME_64
767
          && oursig <= TARGET_SIGNAL_REALTIME_127)
768
        {
769
          /* This block of signals is continuous, and
770
             TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
771
          int retsig =
772
            (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
773
          if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
774
            return retsig;
775
        }
776
 
777
#endif
778
#endif
779
 
780
#if defined (SIGRTMIN)
781
      if (oursig >= TARGET_SIGNAL_REALTIME_33
782
          && oursig <= TARGET_SIGNAL_REALTIME_63)
783
        {
784
          /* This block of signals is continuous, and
785
             TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
786
          int retsig =
787
            (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
788
          if (retsig >= SIGRTMIN && retsig <= SIGRTMAX)
789
            return retsig;
790
        }
791
      else if (oursig == TARGET_SIGNAL_REALTIME_32)
792
        {
793
          /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
794
             TARGET_SIGNAL_REALTIME_33.  It is 32 by definition.  */
795
          return 32;
796
        }
797
      else if (oursig >= TARGET_SIGNAL_REALTIME_64
798
          && oursig <= TARGET_SIGNAL_REALTIME_127)
799
        {
800
          /* This block of signals is continuous, and
801
             TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
802
          int retsig =
803
            (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
804
          return retsig;
805
        }
806
#endif
807
      *oursig_ok = 0;
808
      return 0;
809
    }
810
}
811
 
812
int
813
target_signal_to_host_p (enum target_signal oursig)
814
{
815
  int oursig_ok;
816
  do_target_signal_to_host (oursig, &oursig_ok);
817
  return oursig_ok;
818
}
819
 
820
int
821
target_signal_to_host (enum target_signal oursig)
822
{
823
  int oursig_ok;
824
  int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
825
  if (!oursig_ok)
826
    {
827
      /* The user might be trying to do "signal SIGSAK" where this system
828
         doesn't have SIGSAK.  */
829
      warning ("Signal %s does not exist on this system.\n",
830
               target_signal_to_name (oursig));
831
      return 0;
832
    }
833
  else
834
    return targ_signo;
835
}
836
 
837
/* In some circumstances we allow a command to specify a numeric
838
   signal.  The idea is to keep these circumstances limited so that
839
   users (and scripts) develop portable habits.  For comparison,
840
   POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
841
   numeric signal at all is obsolescent.  We are slightly more
842
   lenient and allow 1-15 which should match host signal numbers on
843
   most systems.  Use of symbolic signal names is strongly encouraged.  */
844
 
845
enum target_signal
846
target_signal_from_command (int num)
847
{
848
  if (num >= 1 && num <= 15)
849
    return (enum target_signal) num;
850
  error ("Only signals 1-15 are valid as numeric signals.\n\
851
Use \"info signals\" for a list of symbolic signals.");
852
}
853
 
854
#ifndef GDBSERVER
855
void
856
_initialize_signals (void)
857
{
858
  if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0)
859
    internal_error (__FILE__, __LINE__, "failed internal consistency check");
860
}
861
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.