1 /* Target signal translation functions for GDB.
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2011 Free Software Foundation, Inc.
4 Contributed by Cygnus Support.
6 This file is part of GDB.
7 It has been modified to integrate it in valgrind
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 2 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
26 #if defined(VGO_darwin)
27 // ???? darwin signal.h defines SIGPOLL conditionnally ????
33 enum target_signal
target_signal_from_name (const char *name
);
34 enum target_signal
target_signal_from_command (int num
);
36 /* This table must match in order and size the signals in enum target_signal
46 {"SIGINT", "Interrupt"},
48 {"SIGILL", "Illegal instruction"},
49 {"SIGTRAP", "Trace/breakpoint trap"},
50 {"SIGABRT", "Aborted"},
51 {"SIGEMT", "Emulation trap"},
52 {"SIGFPE", "Arithmetic exception"},
53 {"SIGKILL", "Killed"},
54 {"SIGBUS", "Bus error"},
55 {"SIGSEGV", "Segmentation fault"},
56 {"SIGSYS", "Bad system call"},
57 {"SIGPIPE", "Broken pipe"},
58 {"SIGALRM", "Alarm clock"},
59 {"SIGTERM", "Terminated"},
60 {"SIGURG", "Urgent I/O condition"},
61 {"SIGSTOP", "Stopped (signal)"},
62 {"SIGTSTP", "Stopped (user)"},
63 {"SIGCONT", "Continued"},
64 {"SIGCHLD", "Child status changed"},
65 {"SIGTTIN", "Stopped (tty input)"},
66 {"SIGTTOU", "Stopped (tty output)"},
67 {"SIGIO", "I/O possible"},
68 {"SIGXCPU", "CPU time limit exceeded"},
69 {"SIGXFSZ", "File size limit exceeded"},
70 {"SIGVTALRM", "Virtual timer expired"},
71 {"SIGPROF", "Profiling timer expired"},
72 {"SIGWINCH", "Window size changed"},
73 {"SIGLOST", "Resource lost"},
74 {"SIGUSR1", "User defined signal 1"},
75 {"SIGUSR2", "User defined signal 2"},
76 {"SIGPWR", "Power fail/restart"},
77 {"SIGPOLL", "Pollable event occurred"},
78 {"SIGWIND", "SIGWIND"},
79 {"SIGPHONE", "SIGPHONE"},
80 {"SIGWAITING", "Process's LWPs are blocked"},
81 {"SIGLWP", "Signal LWP"},
82 {"SIGDANGER", "Swap space dangerously low"},
83 {"SIGGRANT", "Monitor mode granted"},
84 {"SIGRETRACT", "Need to relinquish monitor mode"},
85 {"SIGMSG", "Monitor mode data available"},
86 {"SIGSOUND", "Sound completed"},
87 {"SIGSAK", "Secure attention"},
88 {"SIGPRIO", "SIGPRIO"},
89 {"SIG33", "Real-time event 33"},
90 {"SIG34", "Real-time event 34"},
91 {"SIG35", "Real-time event 35"},
92 {"SIG36", "Real-time event 36"},
93 {"SIG37", "Real-time event 37"},
94 {"SIG38", "Real-time event 38"},
95 {"SIG39", "Real-time event 39"},
96 {"SIG40", "Real-time event 40"},
97 {"SIG41", "Real-time event 41"},
98 {"SIG42", "Real-time event 42"},
99 {"SIG43", "Real-time event 43"},
100 {"SIG44", "Real-time event 44"},
101 {"SIG45", "Real-time event 45"},
102 {"SIG46", "Real-time event 46"},
103 {"SIG47", "Real-time event 47"},
104 {"SIG48", "Real-time event 48"},
105 {"SIG49", "Real-time event 49"},
106 {"SIG50", "Real-time event 50"},
107 {"SIG51", "Real-time event 51"},
108 {"SIG52", "Real-time event 52"},
109 {"SIG53", "Real-time event 53"},
110 {"SIG54", "Real-time event 54"},
111 {"SIG55", "Real-time event 55"},
112 {"SIG56", "Real-time event 56"},
113 {"SIG57", "Real-time event 57"},
114 {"SIG58", "Real-time event 58"},
115 {"SIG59", "Real-time event 59"},
116 {"SIG60", "Real-time event 60"},
117 {"SIG61", "Real-time event 61"},
118 {"SIG62", "Real-time event 62"},
119 {"SIG63", "Real-time event 63"},
120 {"SIGCANCEL", "LWP internal signal"},
121 {"SIG32", "Real-time event 32"},
122 {"SIG64", "Real-time event 64"},
123 {"SIG65", "Real-time event 65"},
124 {"SIG66", "Real-time event 66"},
125 {"SIG67", "Real-time event 67"},
126 {"SIG68", "Real-time event 68"},
127 {"SIG69", "Real-time event 69"},
128 {"SIG70", "Real-time event 70"},
129 {"SIG71", "Real-time event 71"},
130 {"SIG72", "Real-time event 72"},
131 {"SIG73", "Real-time event 73"},
132 {"SIG74", "Real-time event 74"},
133 {"SIG75", "Real-time event 75"},
134 {"SIG76", "Real-time event 76"},
135 {"SIG77", "Real-time event 77"},
136 {"SIG78", "Real-time event 78"},
137 {"SIG79", "Real-time event 79"},
138 {"SIG80", "Real-time event 80"},
139 {"SIG81", "Real-time event 81"},
140 {"SIG82", "Real-time event 82"},
141 {"SIG83", "Real-time event 83"},
142 {"SIG84", "Real-time event 84"},
143 {"SIG85", "Real-time event 85"},
144 {"SIG86", "Real-time event 86"},
145 {"SIG87", "Real-time event 87"},
146 {"SIG88", "Real-time event 88"},
147 {"SIG89", "Real-time event 89"},
148 {"SIG90", "Real-time event 90"},
149 {"SIG91", "Real-time event 91"},
150 {"SIG92", "Real-time event 92"},
151 {"SIG93", "Real-time event 93"},
152 {"SIG94", "Real-time event 94"},
153 {"SIG95", "Real-time event 95"},
154 {"SIG96", "Real-time event 96"},
155 {"SIG97", "Real-time event 97"},
156 {"SIG98", "Real-time event 98"},
157 {"SIG99", "Real-time event 99"},
158 {"SIG100", "Real-time event 100"},
159 {"SIG101", "Real-time event 101"},
160 {"SIG102", "Real-time event 102"},
161 {"SIG103", "Real-time event 103"},
162 {"SIG104", "Real-time event 104"},
163 {"SIG105", "Real-time event 105"},
164 {"SIG106", "Real-time event 106"},
165 {"SIG107", "Real-time event 107"},
166 {"SIG108", "Real-time event 108"},
167 {"SIG109", "Real-time event 109"},
168 {"SIG110", "Real-time event 110"},
169 {"SIG111", "Real-time event 111"},
170 {"SIG112", "Real-time event 112"},
171 {"SIG113", "Real-time event 113"},
172 {"SIG114", "Real-time event 114"},
173 {"SIG115", "Real-time event 115"},
174 {"SIG116", "Real-time event 116"},
175 {"SIG117", "Real-time event 117"},
176 {"SIG118", "Real-time event 118"},
177 {"SIG119", "Real-time event 119"},
178 {"SIG120", "Real-time event 120"},
179 {"SIG121", "Real-time event 121"},
180 {"SIG122", "Real-time event 122"},
181 {"SIG123", "Real-time event 123"},
182 {"SIG124", "Real-time event 124"},
183 {"SIG125", "Real-time event 125"},
184 {"SIG126", "Real-time event 126"},
185 {"SIG127", "Real-time event 127"},
187 {"SIGINFO", "Information request"},
189 {NULL
, "Unknown signal"},
190 {NULL
, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
192 /* Mach exceptions */
193 {"EXC_BAD_ACCESS", "Could not access memory"},
194 {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
195 {"EXC_ARITHMETIC", "Arithmetic exception"},
196 {"EXC_EMULATION", "Emulation instruction"},
197 {"EXC_SOFTWARE", "Software generated exception"},
198 {"EXC_BREAKPOINT", "Breakpoint"},
200 {"SIGLIBRT", "librt internal signal"},
202 /* Last entry, used to check whether the table is the right size. */
203 {NULL
, "TARGET_SIGNAL_MAGIC"}
209 /* Return the name for a signal. */
210 const char *target_signal_to_name (enum target_signal sig
)
212 if ((sig
>= TARGET_SIGNAL_FIRST
) && (sig
<= TARGET_SIGNAL_LAST
)
213 && signals
[sig
].name
!= NULL
)
214 return signals
[sig
].name
;
216 /* I think the code which prints this will always print it along
217 with the string, so no need to be verbose (very old comment). */
221 /* Given a name, return its signal. */
222 enum target_signal
target_signal_from_name (const char *name
)
224 enum target_signal sig
;
226 /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
227 for TARGET_SIGNAL_SIGCHLD. SIGIOT, on the other hand, is more
228 questionable; seems like by now people should call it SIGABRT
231 /* This ugly cast brought to you by the native VAX compiler. */
232 for (sig
= TARGET_SIGNAL_HUP
;
233 sig
< TARGET_SIGNAL_LAST
;
234 sig
= (enum target_signal
) ((int) sig
+ 1))
235 if (signals
[sig
].name
!= NULL
236 && strcmp (name
, signals
[sig
].name
) == 0)
238 return TARGET_SIGNAL_UNKNOWN
;
242 /* The following functions are to help certain targets deal
243 with the signal/waitstatus stuff. They could just as well be in
244 a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
246 /* Convert host signal to our signals. */
247 enum target_signal
target_signal_from_host (int hostsig
)
249 /* A switch statement would make sense but would require special kludges
250 to deal with the cases where more than one signal has the same number. */
253 return TARGET_SIGNAL_0
;
255 #if defined (VKI_SIGHUP)
256 if (hostsig
== VKI_SIGHUP
)
257 return TARGET_SIGNAL_HUP
;
259 #if defined (VKI_SIGINT)
260 if (hostsig
== VKI_SIGINT
)
261 return TARGET_SIGNAL_INT
;
263 #if defined (VKI_SIGQUIT)
264 if (hostsig
== VKI_SIGQUIT
)
265 return TARGET_SIGNAL_QUIT
;
267 #if defined (VKI_SIGILL)
268 if (hostsig
== VKI_SIGILL
)
269 return TARGET_SIGNAL_ILL
;
271 #if defined (VKI_SIGTRAP)
272 if (hostsig
== VKI_SIGTRAP
)
273 return TARGET_SIGNAL_TRAP
;
275 #if defined (VKI_SIGABRT)
276 if (hostsig
== VKI_SIGABRT
)
277 return TARGET_SIGNAL_ABRT
;
279 #if defined (VKI_SIGEMT)
280 if (hostsig
== VKI_SIGEMT
)
281 return TARGET_SIGNAL_EMT
;
283 #if defined (VKI_SIGFPE)
284 if (hostsig
== VKI_SIGFPE
)
285 return TARGET_SIGNAL_FPE
;
287 #if defined (VKI_SIGKILL)
288 if (hostsig
== VKI_SIGKILL
)
289 return TARGET_SIGNAL_KILL
;
291 #if defined (VKI_SIGBUS)
292 if (hostsig
== VKI_SIGBUS
)
293 return TARGET_SIGNAL_BUS
;
295 #if defined (VKI_SIGSEGV)
296 if (hostsig
== VKI_SIGSEGV
)
297 return TARGET_SIGNAL_SEGV
;
299 #if defined (VKI_SIGSYS)
300 if (hostsig
== VKI_SIGSYS
)
301 return TARGET_SIGNAL_SYS
;
303 #if defined (VKI_SIGPIPE)
304 if (hostsig
== VKI_SIGPIPE
)
305 return TARGET_SIGNAL_PIPE
;
307 #if defined (VKI_SIGALRM)
308 if (hostsig
== VKI_SIGALRM
)
309 return TARGET_SIGNAL_ALRM
;
311 #if defined (VKI_SIGTERM)
312 if (hostsig
== VKI_SIGTERM
)
313 return TARGET_SIGNAL_TERM
;
315 #if defined (VKI_SIGUSR1)
316 if (hostsig
== VKI_SIGUSR1
)
317 return TARGET_SIGNAL_USR1
;
319 #if defined (VKI_SIGUSR2)
320 if (hostsig
== VKI_SIGUSR2
)
321 return TARGET_SIGNAL_USR2
;
323 #if defined (VKI_SIGCLD)
324 if (hostsig
== VKI_SIGCLD
)
325 return TARGET_SIGNAL_CHLD
;
327 #if defined (VKI_SIGCHLD)
328 if (hostsig
== VKI_SIGCHLD
)
329 return TARGET_SIGNAL_CHLD
;
331 #if defined (VKI_SIGPWR)
332 if (hostsig
== VKI_SIGPWR
)
333 return TARGET_SIGNAL_PWR
;
335 #if defined (VKI_SIGWINCH)
336 if (hostsig
== VKI_SIGWINCH
)
337 return TARGET_SIGNAL_WINCH
;
339 #if defined (VKI_SIGURG)
340 if (hostsig
== VKI_SIGURG
)
341 return TARGET_SIGNAL_URG
;
343 #if defined (VKI_SIGIO)
344 if (hostsig
== VKI_SIGIO
)
345 return TARGET_SIGNAL_IO
;
347 #if defined (VKI_SIGPOLL)
348 if (hostsig
== VKI_SIGPOLL
)
349 return TARGET_SIGNAL_POLL
;
351 #if defined (VKI_SIGSTOP)
352 if (hostsig
== VKI_SIGSTOP
)
353 return TARGET_SIGNAL_STOP
;
355 #if defined (VKI_SIGTSTP)
356 if (hostsig
== VKI_SIGTSTP
)
357 return TARGET_SIGNAL_TSTP
;
359 #if defined (VKI_SIGCONT)
360 if (hostsig
== VKI_SIGCONT
)
361 return TARGET_SIGNAL_CONT
;
363 #if defined (VKI_SIGTTIN)
364 if (hostsig
== VKI_SIGTTIN
)
365 return TARGET_SIGNAL_TTIN
;
367 #if defined (VKI_SIGTTOU)
368 if (hostsig
== VKI_SIGTTOU
)
369 return TARGET_SIGNAL_TTOU
;
371 #if defined (VKI_SIGVTALRM)
372 if (hostsig
== VKI_SIGVTALRM
)
373 return TARGET_SIGNAL_VTALRM
;
375 #if defined (VKI_SIGPROF)
376 if (hostsig
== VKI_SIGPROF
)
377 return TARGET_SIGNAL_PROF
;
379 #if defined (VKI_SIGXCPU)
380 if (hostsig
== VKI_SIGXCPU
)
381 return TARGET_SIGNAL_XCPU
;
383 #if defined (VKI_SIGXFSZ)
384 if (hostsig
== VKI_SIGXFSZ
)
385 return TARGET_SIGNAL_XFSZ
;
387 #if defined (VKI_SIGWIND)
388 if (hostsig
== VKI_SIGWIND
)
389 return TARGET_SIGNAL_WIND
;
391 #if defined (VKI_SIGPHONE)
392 if (hostsig
== VKI_SIGPHONE
)
393 return TARGET_SIGNAL_PHONE
;
395 #if defined (VKI_SIGLOST)
396 if (hostsig
== VKI_SIGLOST
)
397 return TARGET_SIGNAL_LOST
;
399 #if defined (VKI_SIGWAITING)
400 if (hostsig
== VKI_SIGWAITING
)
401 return TARGET_SIGNAL_WAITING
;
403 #if defined (VKI_SIGCANCEL)
404 if (hostsig
== VKI_SIGCANCEL
)
405 return TARGET_SIGNAL_CANCEL
;
407 #if defined (VKI_SIGLWP)
408 if (hostsig
== VKI_SIGLWP
)
409 return TARGET_SIGNAL_LWP
;
411 #if defined (VKI_SIGDANGER)
412 if (hostsig
== VKI_SIGDANGER
)
413 return TARGET_SIGNAL_DANGER
;
415 #if defined (VKI_SIGGRANT)
416 if (hostsig
== VKI_SIGGRANT
)
417 return TARGET_SIGNAL_GRANT
;
419 #if defined (VKI_SIGRETRACT)
420 if (hostsig
== VKI_SIGRETRACT
)
421 return TARGET_SIGNAL_RETRACT
;
423 #if defined (VKI_SIGMSG)
424 if (hostsig
== VKI_SIGMSG
)
425 return TARGET_SIGNAL_MSG
;
427 #if defined (VKI_SIGSOUND)
428 if (hostsig
== VKI_SIGSOUND
)
429 return TARGET_SIGNAL_SOUND
;
431 #if defined (VKI_SIGSAK)
432 if (hostsig
== VKI_SIGSAK
)
433 return TARGET_SIGNAL_SAK
;
435 #if defined (VKI_SIGPRIO)
436 if (hostsig
== VKI_SIGPRIO
)
437 return TARGET_SIGNAL_PRIO
;
440 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
441 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
442 if (hostsig
== _NSIG
+ EXC_BAD_ACCESS
)
443 return TARGET_EXC_BAD_ACCESS
;
445 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
446 if (hostsig
== _NSIG
+ EXC_BAD_INSTRUCTION
)
447 return TARGET_EXC_BAD_INSTRUCTION
;
449 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
450 if (hostsig
== _NSIG
+ EXC_ARITHMETIC
)
451 return TARGET_EXC_ARITHMETIC
;
453 #if defined (EXC_EMULATION) && defined (_NSIG)
454 if (hostsig
== _NSIG
+ EXC_EMULATION
)
455 return TARGET_EXC_EMULATION
;
457 #if defined (EXC_SOFTWARE) && defined (_NSIG)
458 if (hostsig
== _NSIG
+ EXC_SOFTWARE
)
459 return TARGET_EXC_SOFTWARE
;
461 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
462 if (hostsig
== _NSIG
+ EXC_BREAKPOINT
)
463 return TARGET_EXC_BREAKPOINT
;
466 #if defined (VKI_SIGINFO)
467 if (hostsig
== VKI_SIGINFO
)
468 return TARGET_SIGNAL_INFO
;
470 #if defined (VKI_SIGLIBRT)
471 if (hostsig
== VKI_SIGLIBRT
)
472 return TARGET_SIGNAL_LIBRT
;
475 #if defined (VKI_SIGRTMIN)
476 if (hostsig
>= VKI_SIGRTMIN
&& hostsig
< VKI_SIGRTMAX
) {
477 /* This block of TARGET_SIGNAL_REALTIME value is in order. */
478 if (33 <= hostsig
&& hostsig
<= 63)
479 return (enum target_signal
)
480 (hostsig
- 33 + (int) TARGET_SIGNAL_REALTIME_33
);
481 else if (hostsig
== 32)
482 return TARGET_SIGNAL_REALTIME_32
;
483 else if (64 <= hostsig
&& hostsig
<= 127)
484 return (enum target_signal
)
485 (hostsig
- 64 + (int) TARGET_SIGNAL_REALTIME_64
);
489 error ("Valgrind GDBSERVER bug: (target_signal_from_host):"
490 " unrecognized vki signal %d\n", hostsig
);
491 return TARGET_SIGNAL_UNKNOWN
;
494 /* Convert a OURSIG (an enum target_signal) to the form used by the
495 target operating system (referred to as the ``host'') or zero if the
496 equivalent host signal is not available. Set/clear OURSIG_OK
500 int do_target_signal_to_host (enum target_signal oursig
,
505 case TARGET_SIGNAL_0
:
508 #if defined (VKI_SIGHUP)
509 case TARGET_SIGNAL_HUP
:
512 #if defined (VKI_SIGINT)
513 case TARGET_SIGNAL_INT
:
516 #if defined (VKI_SIGQUIT)
517 case TARGET_SIGNAL_QUIT
:
520 #if defined (VKI_SIGILL)
521 case TARGET_SIGNAL_ILL
:
524 #if defined (VKI_SIGTRAP)
525 case TARGET_SIGNAL_TRAP
:
528 #if defined (VKI_SIGABRT)
529 case TARGET_SIGNAL_ABRT
:
532 #if defined (VKI_SIGEMT)
533 case TARGET_SIGNAL_EMT
:
536 #if defined (VKI_SIGFPE)
537 case TARGET_SIGNAL_FPE
:
540 #if defined (VKI_SIGKILL)
541 case TARGET_SIGNAL_KILL
:
544 #if defined (VKI_SIGBUS)
545 case TARGET_SIGNAL_BUS
:
548 #if defined (VKI_SIGSEGV)
549 case TARGET_SIGNAL_SEGV
:
552 #if defined (VKI_SIGSYS)
553 case TARGET_SIGNAL_SYS
:
556 #if defined (VKI_SIGPIPE)
557 case TARGET_SIGNAL_PIPE
:
560 #if defined (VKI_SIGALRM)
561 case TARGET_SIGNAL_ALRM
:
564 #if defined (VKI_SIGTERM)
565 case TARGET_SIGNAL_TERM
:
568 #if defined (VKI_SIGUSR1)
569 case TARGET_SIGNAL_USR1
:
572 #if defined (VKI_SIGUSR2)
573 case TARGET_SIGNAL_USR2
:
576 #if defined (VKI_SIGCHLD) || defined (VKI_SIGCLD)
577 case TARGET_SIGNAL_CHLD
:
578 #if defined (VKI_SIGCHLD)
583 #endif /* SIGCLD or SIGCHLD */
584 #if defined (VKI_SIGPWR)
585 case TARGET_SIGNAL_PWR
:
588 #if defined (VKI_SIGWINCH)
589 case TARGET_SIGNAL_WINCH
:
592 #if defined (VKI_SIGURG)
593 case TARGET_SIGNAL_URG
:
596 #if defined (VKI_SIGIO)
597 case TARGET_SIGNAL_IO
:
600 #if defined (VKI_SIGPOLL)
601 case TARGET_SIGNAL_POLL
:
604 #if defined (VKI_SIGSTOP)
605 case TARGET_SIGNAL_STOP
:
608 #if defined (VKI_SIGTSTP)
609 case TARGET_SIGNAL_TSTP
:
612 #if defined (VKI_SIGCONT)
613 case TARGET_SIGNAL_CONT
:
616 #if defined (VKI_SIGTTIN)
617 case TARGET_SIGNAL_TTIN
:
620 #if defined (VKI_SIGTTOU)
621 case TARGET_SIGNAL_TTOU
:
624 #if defined (VKI_SIGVTALRM)
625 case TARGET_SIGNAL_VTALRM
:
626 return VKI_SIGVTALRM
;
628 #if defined (VKI_SIGPROF)
629 case TARGET_SIGNAL_PROF
:
632 #if defined (VKI_SIGXCPU)
633 case TARGET_SIGNAL_XCPU
:
636 #if defined (VKI_SIGXFSZ)
637 case TARGET_SIGNAL_XFSZ
:
640 #if defined (VKI_SIGWIND)
641 case TARGET_SIGNAL_WIND
:
644 #if defined (VKI_SIGPHONE)
645 case TARGET_SIGNAL_PHONE
:
648 #if defined (VKI_SIGLOST)
649 case TARGET_SIGNAL_LOST
:
652 #if defined (VKI_SIGWAITING)
653 case TARGET_SIGNAL_WAITING
:
654 return VKI_SIGWAITING
;
656 #if defined (VKI_SIGCANCEL)
657 case TARGET_SIGNAL_CANCEL
:
658 return VKI_SIGCANCEL
;
660 #if defined (VKI_SIGLWP)
661 case TARGET_SIGNAL_LWP
:
664 #if defined (VKI_SIGDANGER)
665 case TARGET_SIGNAL_DANGER
:
666 return VKI_SIGDANGER
;
668 #if defined (VKI_SIGGRANT)
669 case TARGET_SIGNAL_GRANT
:
672 #if defined (VKI_SIGRETRACT)
673 case TARGET_SIGNAL_RETRACT
:
674 return VKI_SIGRETRACT
;
676 #if defined (VKI_SIGMSG)
677 case TARGET_SIGNAL_MSG
:
680 #if defined (VKI_SIGSOUND)
681 case TARGET_SIGNAL_SOUND
:
684 #if defined (VKI_SIGSAK)
685 case TARGET_SIGNAL_SAK
:
688 #if defined (VKI_SIGPRIO)
689 case TARGET_SIGNAL_PRIO
:
693 /* Mach exceptions. Assumes that the values for EXC_ are positive! */
694 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
695 case TARGET_EXC_BAD_ACCESS
:
696 return _NSIG
+ EXC_BAD_ACCESS
;
698 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
699 case TARGET_EXC_BAD_INSTRUCTION
:
700 return _NSIG
+ EXC_BAD_INSTRUCTION
;
702 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
703 case TARGET_EXC_ARITHMETIC
:
704 return _NSIG
+ EXC_ARITHMETIC
;
706 #if defined (EXC_EMULATION) && defined (_NSIG)
707 case TARGET_EXC_EMULATION
:
708 return _NSIG
+ EXC_EMULATION
;
710 #if defined (EXC_SOFTWARE) && defined (_NSIG)
711 case TARGET_EXC_SOFTWARE
:
712 return _NSIG
+ EXC_SOFTWARE
;
714 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
715 case TARGET_EXC_BREAKPOINT
:
716 return _NSIG
+ EXC_BREAKPOINT
;
719 #if defined (VKI_SIGINFO)
720 case TARGET_SIGNAL_INFO
:
723 #if defined (SIGLIBRT)
724 case TARGET_SIGNAL_LIBRT
:
729 #if defined (VKI_SIGRTMIN)
733 if (oursig
>= TARGET_SIGNAL_REALTIME_33
734 && oursig
<= TARGET_SIGNAL_REALTIME_63
) {
735 /* This block of signals is continuous, and
736 TARGET_SIGNAL_REALTIME_33 is 33 by definition. */
737 retsig
= (int) oursig
- (int) TARGET_SIGNAL_REALTIME_33
+ 33;
738 } else if (oursig
== TARGET_SIGNAL_REALTIME_32
) {
739 /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
740 TARGET_SIGNAL_REALTIME_33. It is 32 by definition. */
742 } else if (oursig
>= TARGET_SIGNAL_REALTIME_64
743 && oursig
<= TARGET_SIGNAL_REALTIME_127
) {
744 /* This block of signals is continuous, and
745 TARGET_SIGNAL_REALTIME_64 is 64 by definition. */
746 retsig
= (int) oursig
- (int) TARGET_SIGNAL_REALTIME_64
+ 64;
749 if (retsig
>= VKI_SIGRTMIN
&& retsig
< VKI_SIGRTMAX
)
753 error ("Valgrind GDBSERVER bug: (do_target_signal_to_host):"
754 " unrecognized target signal %u\n", oursig
);
760 int target_signal_to_host_p (enum target_signal oursig
)
763 do_target_signal_to_host (oursig
, &oursig_ok
);
767 int target_signal_to_host (enum target_signal oursig
)
770 int targ_signo
= do_target_signal_to_host (oursig
, &oursig_ok
);
772 /* The user might be trying to do "signal SIGSAK" where this system
773 doesn't have SIGSAK. */
774 warning ("Signal %s does not exist on this system.\n",
775 target_signal_to_name (oursig
));
782 /* In some circumstances we allow a command to specify a numeric
783 signal. The idea is to keep these circumstances limited so that
784 users (and scripts) develop portable habits. For comparison,
785 POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
786 numeric signal at all is obsolescent. We are slightly more
787 lenient and allow 1-15 which should match host signal numbers on
788 most systems. Use of symbolic signal names is strongly encouraged. */
790 enum target_signal
target_signal_from_command (int num
)
792 if (num
>= 1 && num
<= 15)
793 return (enum target_signal
) num
;
794 error ("Only signals 1-15 are valid as numeric signals.\n\
795 Use \"info signals\" for a list of symbolic signals.\n");