1 /* Architecture commands for GDB, the GNU debugger.
2 Copyright 1998, Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
23 /* start-sanitize-carp start-sanitize-vr4xxx */
25 #ifndef GDB_MULTI_ARCH
26 #define GDB_MULTI_ARCH 0
29 extern struct gdbarch
*current_gdbarch
;
32 /* When GDB_MULTI_ARCH override any earlier definitions of the
35 extern const struct bfd_arch_info
*gdbarch_bfd_arch_info
PARAMS ((struct gdbarch
*));
37 #undef TARGET_ARCHITECTURE
38 #define TARGET_ARCHITECTURE (gdbarch_bfd_arch_info (current_gdbarch))
41 extern int gdbarch_byte_order
PARAMS ((struct gdbarch
*));
43 #undef TARGET_BYTE_ORDER
44 #define TARGET_BYTE_ORDER (gdbarch_byte_order (current_gdbarch))
47 extern int gdbarch_long_bit
PARAMS ((struct gdbarch
*));
48 extern void set_gdbarch_long_bit
PARAMS ((struct gdbarch
*, int));
50 #undef TARGET_LONG_BIT
51 #define TARGET_LONG_BIT (gdbarch_long_bit (current_gdbarch))
54 extern int gdbarch_long_long_bit
PARAMS ((struct gdbarch
*));
55 extern void set_gdbarch_long_long_bit
PARAMS ((struct gdbarch
*, int));
57 #undef TARGET_LONG_LONG_BIT
58 #define TARGET_LONG_LONG_BIT (gdbarch_long_long_bit (current_gdbarch))
61 extern int gdbarch_ptr_bit
PARAMS ((struct gdbarch
*));
62 extern void set_gdbarch_ptr_bit
PARAMS ((struct gdbarch
*, int));
65 #define TARGET_PTR_BIT (gdbarch_ptr_bit (current_gdbarch))
68 extern struct gdbarch_tdep
*gdbarch_tdep
PARAMS ((struct gdbarch
*));
71 /* Mechanism for co-ordinating the selection of a specific
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.
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.
85 Previously, a single TARGET_ARCHITECTURE_HOOK was provided. It
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. */
94 /* Register a new architectural family with GDB.
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.
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
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()). */
116 struct gdbarch
*gdbarch
;
117 struct gdbarch_list
*next
;
122 /* Default: bfd_arch_unknown. */
123 enum bfd_architecture bfd_architecture
;
126 const struct bfd_arch_info
*bfd_arch_info
;
135 struct gdbarch_tdep_info
*tdep_info
;
138 typedef struct gdbarch
*(gdbarch_init_ftype
) PARAMS ((struct gdbarch_info info
, struct gdbarch_list
*arches
));
140 extern void register_gdbarch_init
PARAMS ((enum bfd_architecture
, gdbarch_init_ftype
*));
142 /* Helper function. Search ARCHES for a gdbarch that matches
143 information provided by INFO. */
145 extern struct gdbarch_list
*gdbarch_list_lookup_by_info
PARAMS ((struct gdbarch_list
*arches
, const struct gdbarch_info
*info
));
147 /* Helper function. Create a preliminary ``struct gdbarch''. Perform
148 basic initialization using values from the INFO structure. */
150 extern struct gdbarch
*gdbarch_alloc
PARAMS ((const struct gdbarch_info
*, struct gdbarch_tdep
*));
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. */
156 extern int gdbarch_update
PARAMS ((struct gdbarch_info
));
160 /* Register per-architecture data-pointer.
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.
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
171 INIT() shall return the initial value for the per-architecture
172 data-pointer for the current architecture.
174 Multiple registrarants for any architecture are allowed (and
175 strongly encouraged). */
177 typedef void *(gdbarch_data_ftype
) PARAMS ((void));
178 extern struct gdbarch_data
*register_gdbarch_data
PARAMS ((gdbarch_data_ftype
*init
));
181 /* Return the value of the per-architecture data-pointer for the
182 current architecture. */
184 extern void *gdbarch_data
PARAMS ((struct gdbarch_data
*));
187 /* Register per-architecture memory region.
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
195 Memory regions are swapped / initialized in the order that they are
196 registered. NULL DATA and/or INIT values can be specified. */
198 typedef void (gdbarch_swap_ftype
) PARAMS ((void));
199 extern void register_gdbarch_swap
PARAMS ((void *data
, unsigned long size
, gdbarch_swap_ftype
*init
));
202 /* end-sanitize-carp end-sanitize-vr4xxx */
204 /* The target-system-dependant byte order is dynamic */
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
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
218 #define TARGET_BYTE_ORDER_SELECTABLE_P 0
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
228 #ifndef TARGET_BYTE_ORDER
229 #define TARGET_BYTE_ORDER (target_byte_order + 0)
232 extern int target_byte_order_auto
;
233 #ifndef TARGET_BYTE_ORDER_AUTO
234 #define TARGET_BYTE_ORDER_AUTO (target_byte_order_auto + 0)
239 /* The target-system-dependant BFD architecture is dynamic */
241 extern int target_architecture_auto
;
242 #ifndef TARGET_ARCHITECTURE_AUTO
243 #define TARGET_ARCHITECTURE_AUTO (target_architecture_auto + 0)
246 extern const struct bfd_arch_info
*target_architecture
;
247 #ifndef TARGET_ARCHITECTURE
248 #define TARGET_ARCHITECTURE (target_architecture + 0)
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. */
255 extern int (*target_architecture_hook
) PARAMS ((const struct bfd_arch_info
*));
259 /* The target-system-dependant disassembler is semi-dynamic */
261 #include "dis-asm.h" /* Get defs for disassemble_info */
263 extern int dis_asm_read_memory
PARAMS ((bfd_vma memaddr
, bfd_byte
*myaddr
,
264 int len
, disassemble_info
*info
));
266 extern void dis_asm_memory_error
PARAMS ((int status
, bfd_vma memaddr
,
267 disassemble_info
*info
));
269 extern void dis_asm_print_address
PARAMS ((bfd_vma addr
,
270 disassemble_info
*info
));
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)
277 #ifndef TARGET_PRINT_INSN_INFO
278 #define TARGET_PRINT_INSN_INFO (&tm_print_insn_info)
283 /* Set the dynamic target-system-dependant parameters (architecture,
284 byte-order, ...) using information found in the BFD */
286 extern void set_gdbarch_from_file
PARAMS ((bfd
*));
289 /* Explicitly set the dynamic target-system-dependant parameters based
290 on bfd_architecture and machine. */
292 extern void set_architecture_from_arch_mach
PARAMS ((enum bfd_architecture
, unsigned long));
295 /* gdbarch trace variable */
296 extern int gdbarch_debug
;