1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / gdbarch.h
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
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. When possible, and when no other value was
104 provided, INFO is initialized using either the ABFD or the current
105 GDBARCH.
106
107 The INIT function shall return any of: NULL indicating that it
108 doesn't reconize the selected architecture; an existing ``struct
109 gdbarch'' from the ARCHES list (indicating that the new
110 architecture is just a synonym for an earlier architecture); create
111 and then return a new ``struct gdbarch'' for this new architecture
112 (using gdbarch_alloc()). */
113
114 struct gdbarch_list
115 {
116 struct gdbarch *gdbarch;
117 struct gdbarch_list *next;
118 };
119
120 struct gdbarch_info
121 {
122 /* Default: bfd_arch_unknown. */
123 enum bfd_architecture bfd_architecture;
124
125 /* Default: NULL */
126 const struct bfd_arch_info *bfd_arch_info;
127
128 /* Default: 0 */
129 int byte_order;
130
131 /* Default: NULL */
132 bfd *abfd;
133
134 /* Default: NULL */
135 struct gdbarch_tdep_info *tdep_info;
136 };
137
138 typedef struct gdbarch *(gdbarch_init_ftype) PARAMS ((struct gdbarch_info info, struct gdbarch_list *arches));
139
140 extern void register_gdbarch_init PARAMS ((enum bfd_architecture, gdbarch_init_ftype *));
141
142 /* Helper function. Search ARCHES for a gdbarch that matches
143 information provided by INFO. */
144
145 extern struct gdbarch_list *gdbarch_list_lookup_by_info PARAMS ((struct gdbarch_list *arches, const struct gdbarch_info *info));
146
147 /* Helper function. Create a preliminary ``struct gdbarch''. Perform
148 basic initialization using values from the INFO structure. */
149
150 extern struct gdbarch *gdbarch_alloc PARAMS ((const struct gdbarch_info *, struct gdbarch_tdep *));
151
152 /* Helper function. Force the updating of the current architecture.
153 Used by targets that have added their own target specific
154 architecture manipulation commands. */
155
156 extern int gdbarch_update PARAMS ((struct gdbarch_info));
157
158
159
160 /* Register per-architecture data-pointer.
161
162 Reserve space for a per-architecture data-pointer. An identifier
163 for the reserved data-pointer is returned. That identifer should
164 be saved in a local static.
165
166 When a new architecture is selected, INIT() is called. When a
167 previous architecture is re-selected, the per-architecture
168 data-pointer for that previous architecture is restored (INIT() is
169 not called).
170
171 INIT() shall return the initial value for the per-architecture
172 data-pointer for the current architecture.
173
174 Multiple registrarants for any architecture are allowed (and
175 strongly encouraged). */
176
177 typedef void *(gdbarch_data_ftype) PARAMS ((void));
178 extern struct gdbarch_data *register_gdbarch_data PARAMS ((gdbarch_data_ftype *init));
179
180
181 /* Return the value of the per-architecture data-pointer for the
182 current architecture. */
183
184 extern void *gdbarch_data PARAMS ((struct gdbarch_data*));
185
186
187 /* Register per-architecture memory region.
188
189 For legacy code, provide a memory-region swap mechanism.
190 Per-architecture memory blocks are created, these being swapped
191 whenever the architecture is changed. For a new architecture, the
192 memory region is initialized with zero (0) and the INIT function is
193 called.
194
195 Memory regions are swapped / initialized in the order that they are
196 registered. NULL DATA and/or INIT values can be specified. */
197
198 typedef void (gdbarch_swap_ftype) PARAMS ((void));
199 extern void register_gdbarch_swap PARAMS ((void *data, unsigned long size, gdbarch_swap_ftype *init));
200
201
202 /* end-sanitize-carp end-sanitize-vr4xxx */
203
204 /* The target-system-dependant byte order is dynamic */
205
206 /* TARGET_BYTE_ORDER_SELECTABLE_P determines if the target endianness
207 is selectable at runtime. The user can use the `set endian'
208 command to change it. TARGET_BYTE_ORDER_AUTO is nonzero when
209 target_byte_order should be auto-detected (from the program image
210 say). */
211
212 #ifndef TARGET_BYTE_ORDER_SELECTABLE_P
213 /* compat - Catch old targets that define TARGET_BYTE_ORDER_SLECTABLE
214 when they should have defined TARGET_BYTE_ORDER_SELECTABLE_P 1 */
215 #ifdef TARGET_BYTE_ORDER_SELECTABLE
216 #define TARGET_BYTE_ORDER_SELECTABLE_P 1
217 #else
218 #define TARGET_BYTE_ORDER_SELECTABLE_P 0
219 #endif
220 #endif
221
222 extern int target_byte_order;
223 #ifdef TARGET_BYTE_ORDER_SELECTABLE
224 /* compat - Catch old targets that define TARGET_BYTE_ORDER_SELECTABLE
225 and expect defs.h to re-define TARGET_BYTE_ORDER. */
226 #undef TARGET_BYTE_ORDER
227 #endif
228 #ifndef TARGET_BYTE_ORDER
229 #define TARGET_BYTE_ORDER (target_byte_order + 0)
230 #endif
231
232 extern int target_byte_order_auto;
233 #ifndef TARGET_BYTE_ORDER_AUTO
234 #define TARGET_BYTE_ORDER_AUTO (target_byte_order_auto + 0)
235 #endif
236
237
238
239 /* The target-system-dependant BFD architecture is dynamic */
240
241 extern int target_architecture_auto;
242 #ifndef TARGET_ARCHITECTURE_AUTO
243 #define TARGET_ARCHITECTURE_AUTO (target_architecture_auto + 0)
244 #endif
245
246 extern const struct bfd_arch_info *target_architecture;
247 #ifndef TARGET_ARCHITECTURE
248 #define TARGET_ARCHITECTURE (target_architecture + 0)
249 #endif
250
251 /* Notify the target dependant backend of a change to the selected
252 architecture. A zero return status indicates that the target did
253 not like the change. */
254
255 extern int (*target_architecture_hook) PARAMS ((const struct bfd_arch_info *));
256
257
258
259 /* The target-system-dependant disassembler is semi-dynamic */
260
261 #include "dis-asm.h" /* Get defs for disassemble_info */
262
263 extern int dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr,
264 int len, disassemble_info *info));
265
266 extern void dis_asm_memory_error PARAMS ((int status, bfd_vma memaddr,
267 disassemble_info *info));
268
269 extern void dis_asm_print_address PARAMS ((bfd_vma addr,
270 disassemble_info *info));
271
272 extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*));
273 extern disassemble_info tm_print_insn_info;
274 #ifndef TARGET_PRINT_INSN
275 #define TARGET_PRINT_INSN(vma, info) (*tm_print_insn) (vma, info)
276 #endif
277 #ifndef TARGET_PRINT_INSN_INFO
278 #define TARGET_PRINT_INSN_INFO (&tm_print_insn_info)
279 #endif
280
281
282
283 /* Set the dynamic target-system-dependant parameters (architecture,
284 byte-order, ...) using information found in the BFD */
285
286 extern void set_gdbarch_from_file PARAMS ((bfd *));
287
288
289 /* Explicitly set the dynamic target-system-dependant parameters based
290 on bfd_architecture and machine. */
291
292 extern void set_architecture_from_arch_mach PARAMS ((enum bfd_architecture, unsigned long));
293
294
295 /* gdbarch trace variable */
296 extern int gdbarch_debug;
297
298 #endif
This page took 0.037371 seconds and 4 git commands to generate.