Commit | Line | Data |
---|---|---|
feaee4bd AC |
1 | /* The IGEN simulator generator for GDB, the GNU Debugger. |
2 | ||
61baf725 | 3 | Copyright 2002-2017 Free Software Foundation, Inc. |
feaee4bd AC |
4 | |
5 | Contributed by Andrew Cagney. | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
4744ac1b | 11 | the Free Software Foundation; either version 3 of the License, or |
feaee4bd AC |
12 | (at your option) any later version. |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
4744ac1b | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
feaee4bd | 21 | |
c906108c SS |
22 | |
23 | ||
24 | /* Frustrating header junk */ | |
25 | ||
26 | #include "config.h" | |
27 | ||
28 | ||
4e0bf4c4 AC |
29 | enum |
30 | { | |
c906108c SS |
31 | default_insn_bit_size = 32, |
32 | max_insn_bit_size = 64, | |
33 | }; | |
34 | ||
35 | ||
36 | /* Define a 64bit data type */ | |
37 | ||
38 | #if defined __GNUC__ || defined _WIN32 | |
39 | #ifdef __GNUC__ | |
40 | ||
41 | typedef long long signed64; | |
42 | typedef unsigned long long unsigned64; | |
43 | ||
4e0bf4c4 | 44 | #else /* _WIN32 */ |
c906108c SS |
45 | |
46 | typedef __int64 signed64; | |
47 | typedef unsigned __int64 unsigned64; | |
48 | ||
49 | #endif /* _WIN32 */ | |
50 | #else /* Not GNUC or WIN32 */ | |
51 | /* Not supported */ | |
52 | #endif | |
53 | ||
54 | ||
55 | #include <stdio.h> | |
56 | #include <ctype.h> | |
57 | ||
58 | #ifdef HAVE_STRING_H | |
59 | #include <string.h> | |
60 | #else | |
61 | #ifdef HAVE_STRINGS_H | |
62 | #include <strings.h> | |
63 | #endif | |
64 | #endif | |
65 | ||
66 | #ifdef HAVE_STDLIB_H | |
67 | #include <stdlib.h> | |
68 | #endif | |
69 | ||
70 | #if !defined (__attribute__) && (!defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) | |
71 | #define __attribute__(arg) | |
72 | #endif | |
73 | ||
74 | ||
75 | ||
76 | #include "filter_host.h" | |
77 | ||
78 | typedef struct _line_ref line_ref; | |
4e0bf4c4 AC |
79 | struct _line_ref |
80 | { | |
c906108c SS |
81 | const char *file_name; |
82 | int line_nr; | |
83 | }; | |
84 | ||
85 | /* Error appends a new line, warning and notify do not */ | |
4e0bf4c4 | 86 | typedef void error_func (const line_ref *line, char *msg, ...); |
c906108c SS |
87 | |
88 | extern error_func error; | |
89 | extern error_func warning; | |
90 | extern error_func notify; | |
91 | ||
92 | ||
93 | #define ERROR(EXPRESSION) \ | |
94 | do { \ | |
95 | line_ref line; \ | |
96 | line.file_name = filter_filename (__FILE__); \ | |
97 | line.line_nr = __LINE__; \ | |
98 | error (&line, EXPRESSION); \ | |
99 | } while (0) | |
100 | ||
101 | #define ASSERT(EXPRESSION) \ | |
102 | do { \ | |
103 | if (!(EXPRESSION)) { \ | |
104 | line_ref line; \ | |
105 | line.file_name = filter_filename (__FILE__); \ | |
106 | line.line_nr = __LINE__; \ | |
107 | error(&line, "assertion failed - %s\n", #EXPRESSION); \ | |
108 | } \ | |
109 | } while (0) | |
110 | ||
111 | #define ZALLOC(TYPE) ((TYPE*) zalloc (sizeof(TYPE))) | |
112 | #define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N))) | |
c906108c | 113 | |
4e0bf4c4 | 114 | extern void *zalloc (long size); |
c906108c | 115 | |
4e0bf4c4 | 116 | extern unsigned target_a2i (int ms_bit_nr, const char *a); |
c906108c | 117 | |
4e0bf4c4 | 118 | extern unsigned i2target (int ms_bit_nr, unsigned bit); |
c906108c | 119 | |
4e0bf4c4 | 120 | extern unsigned long long a2i (const char *a); |
c906108c SS |
121 | |
122 | ||
123 | /* Try looking for name in the map table (returning the corresponding | |
124 | integer value). | |
125 | ||
126 | If the the sentinal (NAME == NULL) its value if >= zero is returned | |
127 | as the default. */ | |
128 | ||
4e0bf4c4 AC |
129 | typedef struct _name_map |
130 | { | |
c906108c SS |
131 | const char *name; |
132 | int i; | |
4e0bf4c4 AC |
133 | } |
134 | name_map; | |
c906108c | 135 | |
4e0bf4c4 | 136 | extern int name2i (const char *name, const name_map * map); |
c906108c | 137 | |
4e0bf4c4 | 138 | extern const char *i2name (const int i, const name_map * map); |