]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Simulator signal support |
6aba47ca | 2 | Copyright (C) 1997, 2007 Free Software Foundation, Inc. |
c906108c SS |
3 | Contributed by Cygnus Support |
4 | ||
5 | This file is part of the GNU Simulators. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License along | |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include <signal.h> | |
22 | #include "sim-main.h" | |
23 | ||
24 | /* Convert SIM_SIGFOO to SIGFOO. | |
25 | What to do when the host doesn't have SIGFOO is handled on a case by case | |
26 | basis. Generally, in the case of passing a value back to gdb, we want gdb | |
27 | to not think the process has died (so it can be debugged at the point of | |
28 | failure). */ | |
29 | ||
30 | #ifdef _MSC_VER | |
31 | #ifndef SIGTRAP | |
32 | #define SIGTRAP 5 | |
33 | #endif | |
34 | #ifndef SIGBUS | |
35 | #define SIGBUS 10 | |
36 | #endif | |
37 | #ifndef SIGQUIT | |
38 | #define SIGQUIT 3 | |
39 | #endif | |
40 | #endif | |
41 | ||
42 | int | |
43 | sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig) | |
44 | { | |
45 | switch (sig) | |
46 | { | |
47 | case SIM_SIGINT : | |
48 | return SIGINT; | |
49 | ||
50 | case SIM_SIGABRT : | |
51 | return SIGABRT; | |
52 | ||
53 | case SIM_SIGILL : | |
54 | #ifdef SIGILL | |
55 | return SIGILL; | |
56 | #else | |
57 | return SIGSEGV; | |
58 | #endif | |
59 | ||
60 | case SIM_SIGTRAP : | |
61 | return SIGTRAP; | |
62 | ||
63 | case SIM_SIGBUS : | |
64 | #ifdef SIGBUS | |
65 | return SIGBUS; | |
66 | #else | |
67 | return SIGSEGV; | |
68 | #endif | |
69 | ||
70 | case SIM_SIGSEGV : | |
71 | return SIGSEGV; | |
72 | ||
73 | case SIM_SIGXCPU : | |
74 | #ifdef SIGXCPU | |
75 | return SIGXCPU; | |
76 | #endif | |
77 | break; | |
78 | ||
79 | case SIM_SIGFPE: | |
aba6488e | 80 | #ifdef SIGFPE |
c906108c SS |
81 | return SIGFPE; |
82 | #endif | |
83 | break; | |
84 | ||
85 | case SIM_SIGNONE: | |
86 | return 0; | |
87 | break; | |
88 | } | |
89 | ||
90 | sim_io_eprintf (sd, "sim_signal_to_host: unknown signal: %d\n", sig); | |
91 | #ifdef SIGHUP | |
92 | return SIGHUP; /* FIXME: Suggestions? */ | |
93 | #else | |
94 | return 1; | |
95 | #endif | |
96 | } | |
aba6488e | 97 | |
25520859 | 98 | enum target_signal |
aba6488e MM |
99 | sim_signal_to_target (SIM_DESC sd, SIM_SIGNAL sig) |
100 | { | |
101 | switch (sig) | |
102 | { | |
103 | case SIM_SIGINT : | |
104 | return TARGET_SIGNAL_INT; | |
105 | ||
106 | case SIM_SIGABRT : | |
107 | return TARGET_SIGNAL_ABRT; | |
108 | ||
109 | case SIM_SIGILL : | |
110 | return TARGET_SIGNAL_ILL; | |
111 | ||
112 | case SIM_SIGTRAP : | |
113 | return TARGET_SIGNAL_TRAP; | |
114 | ||
115 | case SIM_SIGBUS : | |
116 | return TARGET_SIGNAL_BUS; | |
117 | ||
25520859 | 118 | case SIM_SIGSEGV : |
aba6488e MM |
119 | return TARGET_SIGNAL_SEGV; |
120 | ||
121 | case SIM_SIGXCPU : | |
122 | return TARGET_SIGNAL_XCPU; | |
123 | ||
124 | case SIM_SIGFPE: | |
125 | return TARGET_SIGNAL_FPE; | |
126 | break; | |
127 | ||
128 | case SIM_SIGNONE: | |
129 | return TARGET_SIGNAL_0; | |
130 | break; | |
131 | } | |
132 | ||
133 | sim_io_eprintf (sd, "sim_signal_to_host: unknown signal: %d\n", sig); | |
134 | return TARGET_SIGNAL_HUP; | |
135 | } |