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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [common/] [signals.c] - Blame information for rev 330

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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