[PATCH 22/57][Arm][GAS] Add support for MVE instructions: vmlaldav, vmlalv, vmlsldav...
[binutils-gdb.git] / sim / rx / err.c
blob39e15dc41e4c23ec52d9c69cd08ad9d7a1030b33
1 /* err.c --- handle errors for RX simulator.
3 Copyright (C) 2008-2019 Free Software Foundation, Inc.
4 Contributed by Red Hat, Inc.
6 This file is part of the GNU simulators.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include <stdio.h>
22 #include <stdlib.h>
24 #include "err.h"
26 static unsigned char ee_actions[SIM_ERR_NUM_ERRORS];
28 static enum execution_error last_error;
30 static void
31 ee_overrides ()
33 /* GCC may initialize a bitfield by reading the uninitialized byte,
34 masking in the bitfield, and writing the byte back out. */
35 ee_actions[SIM_ERR_READ_UNWRITTEN_BYTES] = SIM_ERRACTION_IGNORE;
36 /* This breaks stack unwinding for exceptions because it leaves
37 MC_PUSHED_PC tags in the unwound stack frames. */
38 ee_actions[SIM_ERR_CORRUPT_STACK] = SIM_ERRACTION_IGNORE;
41 void
42 execution_error_init_standalone (void)
44 int i;
46 for (i = 0; i < SIM_ERR_NUM_ERRORS; i++)
47 ee_actions[i] = SIM_ERRACTION_EXIT;
49 ee_overrides ();
52 void
53 execution_error_init_debugger (void)
55 int i;
57 for (i = 0; i < SIM_ERR_NUM_ERRORS; i++)
58 ee_actions[i] = SIM_ERRACTION_DEBUG;
60 ee_overrides ();
63 void
64 execution_error_exit_all (void)
66 int i;
68 for (i = 0; i < SIM_ERR_NUM_ERRORS; i++)
69 ee_actions[i] = SIM_ERRACTION_EXIT;
72 void
73 execution_error_warn_all (void)
75 int i;
77 for (i = 0; i < SIM_ERR_NUM_ERRORS; i++)
78 ee_actions[i] = SIM_ERRACTION_WARN;
81 void
82 execution_error_ignore_all (void)
84 int i;
86 for (i = 0; i < SIM_ERR_NUM_ERRORS; i++)
87 ee_actions[i] = SIM_ERRACTION_IGNORE;
90 void
91 execution_error (enum execution_error num, unsigned long address)
93 if (ee_actions[num] != SIM_ERRACTION_IGNORE)
94 last_error = num;
96 if (ee_actions[num] == SIM_ERRACTION_EXIT
97 || ee_actions[num] == SIM_ERRACTION_WARN)
99 switch (num)
101 case SIM_ERR_READ_UNWRITTEN_PAGES:
102 case SIM_ERR_READ_UNWRITTEN_BYTES:
103 printf("Read from unwritten memory at 0x%lx\n", address);
104 break;
106 case SIM_ERR_NULL_POINTER_DEREFERENCE:
107 printf ("NULL pointer dereference\n");
108 break;
110 case SIM_ERR_CORRUPT_STACK:
111 printf ("Stack corruption detected at 0x%lx\n", address);
112 break;
114 default:
115 printf ("Unknown execution error %d\n", num);
116 exit (1);
120 if (ee_actions[num] == SIM_ERRACTION_EXIT)
121 exit (1);
124 enum execution_error
125 execution_error_get_last_error (void)
127 return last_error;
130 void
131 execution_error_clear_last_error (void)
133 last_error = SIM_ERR_NONE;
136 void
137 execution_error_set_action (enum execution_error num, enum execution_error_action act)
139 ee_actions[num] = act;