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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [signals/] [signals.c] - Blame information for rev 24

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

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

powered by: WebSVN 2.1.0

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