NUMBERS_WITH_SUFFIX *doesn't* want to handle 'x', since that is valid
[deliverable/binutils-gdb.git] / sim / common / sim-signal.c
CommitLineData
c906108c
SS
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#ifndef SIGQUIT
38#define SIGQUIT 3
39#endif
40#endif
41
42int
43sim_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:
80#ifdef SIGXCPU
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}
This page took 0.039253 seconds and 4 git commands to generate.