Commit | Line | Data |
---|---|---|
f7e85b1b AC |
1 | /* Architecture commands for GDB, the GNU debugger. |
2 | Copyright 1998, Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #ifndef GDBARCH_H | |
21 | #define GDBARCH_H | |
22 | ||
dcf46491 AC |
23 | /* start-sanitize-carp start-sanitize-vr4xxx */ |
24 | ||
25 | #ifndef GDB_MULTI_ARCH | |
26 | #define GDB_MULTI_ARCH 0 | |
27 | #endif | |
28 | ||
29 | extern struct gdbarch *current_gdbarch; | |
30 | ||
31 | ||
32 | /* When GDB_MULTI_ARCH override any earlier definitions of the | |
33 | below. */ | |
34 | ||
35 | extern const struct bfd_arch_info *gdbarch_bfd_arch_info PARAMS ((struct gdbarch*)); | |
36 | #if GDB_MULTI_ARCH | |
37 | #undef TARGET_ARCHITECTURE | |
38 | #define TARGET_ARCHITECTURE (gdbarch_bfd_arch_info (current_gdbarch)) | |
39 | #endif | |
40 | ||
41 | extern int gdbarch_byte_order PARAMS ((struct gdbarch*)); | |
42 | #if GDB_MULTI_ARCH | |
43 | #undef TARGET_BYTE_ORDER | |
44 | #define TARGET_BYTE_ORDER (gdbarch_byte_order (current_gdbarch)) | |
45 | #endif | |
46 | ||
47 | extern int gdbarch_long_bit PARAMS ((struct gdbarch*)); | |
48 | extern void set_gdbarch_long_bit PARAMS ((struct gdbarch*, int)); | |
49 | #if GDB_MULTI_ARCH | |
50 | #undef TARGET_LONG_BIT | |
51 | #define TARGET_LONG_BIT (gdbarch_long_bit (current_gdbarch)) | |
52 | #endif | |
53 | ||
54 | extern int gdbarch_long_long_bit PARAMS ((struct gdbarch*)); | |
55 | extern void set_gdbarch_long_long_bit PARAMS ((struct gdbarch*, int)); | |
56 | #if GDB_MULTI_ARCH | |
57 | #undef TARGET_LONG_LONG_BIT | |
58 | #define TARGET_LONG_LONG_BIT (gdbarch_long_long_bit (current_gdbarch)) | |
59 | #endif | |
60 | ||
61 | extern int gdbarch_ptr_bit PARAMS ((struct gdbarch*)); | |
62 | extern void set_gdbarch_ptr_bit PARAMS ((struct gdbarch*, int)); | |
63 | #if GDB_MULTI_ARCH | |
64 | #undef TARGET_PTR_BIT | |
65 | #define TARGET_PTR_BIT (gdbarch_ptr_bit (current_gdbarch)) | |
66 | #endif | |
67 | ||
68 | extern struct gdbarch_tdep *gdbarch_tdep PARAMS ((struct gdbarch*)); | |
69 | ||
70 | ||
71 | /* Mechanism for co-ordinating the selection of a specific | |
72 | architecture. | |
73 | ||
74 | GDB targets (*-tdep.c) can register an interest in a specific | |
75 | architecture. Other GDB components can register a need to maintain | |
76 | per-architecture data. | |
77 | ||
78 | The mechanisms below ensures that only a loose connection between | |
79 | the set-architecture command and the various GDB components exists. | |
80 | Each component can independantly register their need to maintain | |
81 | architecture specific data with gdbarch. | |
82 | ||
83 | Pragmatics: | |
84 | ||
85 | Previously, a single TARGET_ARCHITECTURE_HOOK was provided. It | |
86 | didn't scale. | |
87 | ||
88 | The more traditional mega-struct containing architecture specific | |
89 | data for all the various GDB components was also considered. Since | |
90 | GDB is built from a variable number of (fairly independant) | |
91 | components this global aproach was considered non-applicable. */ | |
92 | ||
93 | ||
94 | /* Register a new architectural family with GDB. | |
95 | ||
96 | Register support for the specified architecture with GDB. When | |
97 | ever gdbarch determines that this architecture has been selected, | |
98 | the specifed INIT function is called. | |
99 | ||
100 | INIT takes two parameters: INFO which contains the information | |
101 | available to gdbarch about the (possibly new) architecture; ARCHES | |
102 | which is a list of the previously created ``struct gdbarch'' for | |
103 | this architecture. Fields within the structure INFO which have no | |
104 | previous value are set to defaults: BFD_ARCHITECTURE - | |
105 | bfd_arch_unknown; BFD_ARCH_INFO - NULL; BYTE_ORDER - 0; ABFD - | |
106 | NULL; | |
107 | ||
108 | The INIT function shall return any of: NULL indicating that it | |
109 | doesn't reconize the selected architecture; an existing ``struct | |
110 | gdbarch'' from the ARCHES list (indicating that the new | |
111 | architecture is just a synonym for an earlier architecture); create | |
112 | and then return a new ``struct gdbarch'' for this new architecture | |
113 | (using gdbarch_alloc()). */ | |
114 | ||
115 | struct gdbarch_list | |
116 | { | |
117 | struct gdbarch *gdbarch; | |
118 | struct gdbarch_list *next; | |
119 | }; | |
120 | ||
121 | struct gdbarch_info | |
122 | { | |
123 | enum bfd_architecture bfd_architecture; | |
124 | const struct bfd_arch_info *bfd_arch_info; | |
125 | int byte_order; | |
126 | bfd *abfd; | |
127 | }; | |
128 | ||
129 | typedef struct gdbarch *(gdbarch_init_ftype) PARAMS ((const struct gdbarch_info *info, struct gdbarch_list *arches)); | |
130 | ||
131 | extern void register_gdbarch_init PARAMS ((enum bfd_architecture, gdbarch_init_ftype *)); | |
132 | ||
133 | /* Helper function. Search ARCHES for a gdbarch that matches | |
134 | information provided by INFO. */ | |
135 | ||
136 | extern struct gdbarch_list *gdbarch_list_lookup_by_info PARAMS ((struct gdbarch_list *arches, const struct gdbarch_info *info)); | |
137 | ||
138 | /* Helper function. Create a preliminary ``struct gdbarch''. Perform | |
139 | basic initialization using values from the INFO structure. */ | |
140 | ||
141 | extern struct gdbarch *gdbarch_alloc PARAMS ((const struct gdbarch_info *, struct gdbarch_tdep *)); | |
142 | ||
143 | /* Helper function. Force the updating of the current architecture. | |
144 | Used by targets that have added their own target specific | |
145 | architecture manipulation commands. */ | |
146 | ||
147 | extern int gdbarch_update PARAMS ((struct gdbarch_info)); | |
148 | ||
149 | ||
150 | ||
151 | /* Register per-architecture data-pointer. | |
152 | ||
153 | Reserve space for a per-architecture data-pointer. An identifier | |
154 | for the reserved data-pointer is returned. That identifer should | |
155 | be saved in a local static. | |
156 | ||
157 | When a new architecture is selected, INIT() is called. When a | |
158 | previous architecture is re-selected, the per-architecture | |
159 | data-pointer for that previous architecture is restored (INIT() is | |
160 | not called). | |
161 | ||
162 | INIT() shall return the initial value for the per-architecture | |
163 | data-pointer for the current architecture. | |
164 | ||
165 | Multiple registrarants for any architecture are allowed (and | |
166 | strongly encouraged). */ | |
167 | ||
168 | typedef void *(gdbarch_data_ftype) PARAMS ((void)); | |
169 | extern struct gdbarch_data *register_gdbarch_data PARAMS ((gdbarch_data_ftype *init)); | |
170 | ||
171 | ||
172 | /* Return the value of the per-architecture data-pointer for the | |
173 | current architecture. */ | |
174 | ||
175 | extern void *gdbarch_data PARAMS ((struct gdbarch_data*)); | |
176 | ||
177 | ||
178 | /* Register per-architecture memory region. | |
179 | ||
180 | For legacy code, provide a memory-region swap mechanism. | |
181 | Per-architecture memory blocks are created, these being swapped | |
182 | whenever the architecture is changed. For a new architecture, the | |
183 | memory region is initialized with zero (0) and the INIT function is | |
184 | called. | |
185 | ||
186 | Memory regions are swapped / initialized in the order that they are | |
187 | registered. NULL DATA and/or INIT values can be specified. */ | |
188 | ||
189 | typedef void (gdbarch_swap_ftype) PARAMS ((void)); | |
190 | extern void register_gdbarch_swap PARAMS ((void *data, unsigned long size, gdbarch_swap_ftype *init)); | |
191 | ||
192 | ||
193 | /* end-sanitize-carp end-sanitize-vr4xxx */ | |
f7e85b1b | 194 | |
5036d102 | 195 | /* The target-system-dependant byte order is dynamic */ |
f7e85b1b AC |
196 | |
197 | /* TARGET_BYTE_ORDER_SELECTABLE_P determines if the target endianness | |
198 | is selectable at runtime. The user can use the `set endian' | |
199 | command to change it. TARGET_BYTE_ORDER_AUTO is nonzero when | |
200 | target_byte_order should be auto-detected (from the program image | |
201 | say). */ | |
202 | ||
203 | #ifndef TARGET_BYTE_ORDER_SELECTABLE_P | |
204 | /* compat - Catch old targets that define TARGET_BYTE_ORDER_SLECTABLE | |
205 | when they should have defined TARGET_BYTE_ORDER_SELECTABLE_P 1 */ | |
206 | #ifdef TARGET_BYTE_ORDER_SELECTABLE | |
207 | #define TARGET_BYTE_ORDER_SELECTABLE_P 1 | |
208 | #else | |
209 | #define TARGET_BYTE_ORDER_SELECTABLE_P 0 | |
210 | #endif | |
211 | #endif | |
212 | ||
213 | extern int target_byte_order; | |
214 | #ifdef TARGET_BYTE_ORDER_SELECTABLE | |
215 | /* compat - Catch old targets that define TARGET_BYTE_ORDER_SELECTABLE | |
216 | and expect defs.h to re-define TARGET_BYTE_ORDER. */ | |
217 | #undef TARGET_BYTE_ORDER | |
218 | #endif | |
219 | #ifndef TARGET_BYTE_ORDER | |
220 | #define TARGET_BYTE_ORDER (target_byte_order + 0) | |
221 | #endif | |
222 | ||
223 | extern int target_byte_order_auto; | |
224 | #ifndef TARGET_BYTE_ORDER_AUTO | |
225 | #define TARGET_BYTE_ORDER_AUTO (target_byte_order_auto + 0) | |
226 | #endif | |
227 | ||
228 | ||
229 | ||
230 | /* The target-system-dependant BFD architecture is dynamic */ | |
231 | ||
232 | extern int target_architecture_auto; | |
5036d102 | 233 | #ifndef TARGET_ARCHITECTURE_AUTO |
f7e85b1b | 234 | #define TARGET_ARCHITECTURE_AUTO (target_architecture_auto + 0) |
5036d102 | 235 | #endif |
f7e85b1b | 236 | |
5036d102 AC |
237 | extern const struct bfd_arch_info *target_architecture; |
238 | #ifndef TARGET_ARCHITECTURE | |
f7e85b1b | 239 | #define TARGET_ARCHITECTURE (target_architecture + 0) |
5036d102 | 240 | #endif |
f7e85b1b AC |
241 | |
242 | /* Notify the target dependant backend of a change to the selected | |
243 | architecture. A zero return status indicates that the target did | |
244 | not like the change. */ | |
245 | ||
5036d102 | 246 | extern int (*target_architecture_hook) PARAMS ((const struct bfd_arch_info *)); |
f7e85b1b AC |
247 | |
248 | ||
249 | ||
250 | /* The target-system-dependant disassembler is semi-dynamic */ | |
251 | ||
252 | #include "dis-asm.h" /* Get defs for disassemble_info */ | |
253 | ||
254 | extern int dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, | |
255 | int len, disassemble_info *info)); | |
256 | ||
257 | extern void dis_asm_memory_error PARAMS ((int status, bfd_vma memaddr, | |
258 | disassemble_info *info)); | |
259 | ||
260 | extern void dis_asm_print_address PARAMS ((bfd_vma addr, | |
261 | disassemble_info *info)); | |
262 | ||
263 | extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*)); | |
264 | extern disassemble_info tm_print_insn_info; | |
265 | #ifndef TARGET_PRINT_INSN | |
266 | #define TARGET_PRINT_INSN(vma, info) (*tm_print_insn) (vma, info) | |
267 | #endif | |
268 | #ifndef TARGET_PRINT_INSN_INFO | |
269 | #define TARGET_PRINT_INSN_INFO (&tm_print_insn_info) | |
270 | #endif | |
271 | ||
272 | ||
273 | ||
274 | /* Set the dynamic target-system-dependant parameters (architecture, | |
275 | byte-order, ...) using information found in the BFD */ | |
276 | ||
277 | extern void set_gdbarch_from_file PARAMS ((bfd *)); | |
278 | ||
5036d102 | 279 | |
f7e85b1b AC |
280 | /* Explicitly set the dynamic target-system-dependant parameters based |
281 | on bfd_architecture and machine. */ | |
282 | ||
283 | extern void set_architecture_from_arch_mach PARAMS ((enum bfd_architecture, unsigned long)); | |
284 | ||
5036d102 AC |
285 | |
286 | /* gdbarch trace variable */ | |
287 | extern int gdbarch_debug; | |
288 | ||
f7e85b1b | 289 | #endif |