Commit | Line | Data |
---|---|---|
1ebc7e0e DE |
1 | /* Simulator signal support |
2 | Copyright (C) 1997 Free Software Foundation, Inc. | |
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 | #endif | |
38 | ||
39 | int | |
40 | sim_signal_to_host (SIM_DESC sd, SIM_SIGNAL sig) | |
41 | { | |
42 | switch (sig) | |
43 | { | |
44 | case SIM_SIGINT : | |
45 | return SIGINT; | |
46 | ||
47 | case SIM_SIGABRT : | |
48 | return SIGABRT; | |
49 | ||
50 | case SIM_SIGILL : | |
51 | #ifdef SIGILL | |
52 | return SIGILL; | |
53 | #else | |
54 | return SIGSEGV; | |
55 | #endif | |
56 | ||
57 | case SIM_SIGTRAP : | |
58 | return SIGTRAP; | |
59 | ||
60 | case SIM_SIGBUS : | |
61 | #ifdef SIGBUS | |
62 | return SIGBUS; | |
63 | #else | |
64 | return SIGSEGV; | |
65 | #endif | |
66 | ||
67 | case SIM_SIGSEGV : | |
68 | return SIGSEGV; | |
69 | ||
70 | case SIM_SIGXCPU : | |
71 | #ifdef SIGXCPU | |
72 | return SIGXCPU; | |
73 | #endif | |
74 | break; | |
75 | } | |
76 | ||
77 | sim_io_eprintf (sd, "sim_signal_to_host: unknown signal: %d\n", sig); | |
78 | #ifdef SIGHUP | |
79 | return SIGHUP; /* FIXME: Suggestions? */ | |
80 | #else | |
81 | return 1; | |
82 | #endif | |
83 | } |