Do top level sim-hw module for device tree.
[deliverable/binutils-gdb.git] / sim / common / sim-signal.c
CommitLineData
1ebc7e0e
DE
1/* Simulator signal support
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support
4
5This file is part of the GNU Simulators.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along
18with this program; if not, write to the Free Software Foundation, Inc.,
1959 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
39int
40sim_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;
232156de
AC
73#endif
74 break;
75
76 case SIM_SIGFPE:
77#ifdef SIGXCPU
78 return SIGFPE;
1ebc7e0e
DE
79#endif
80 break;
a1cf18dc
AC
81
82 case SIM_SIGNONE:
83 return 0;
84 break;
1ebc7e0e
DE
85 }
86
87 sim_io_eprintf (sd, "sim_signal_to_host: unknown signal: %d\n", sig);
88#ifdef SIGHUP
89 return SIGHUP; /* FIXME: Suggestions? */
90#else
91 return 1;
92#endif
93}
This page took 0.038521 seconds and 4 git commands to generate.