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. 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 -
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()). */
117 struct gdbarch
*gdbarch
;
118 struct gdbarch_list
*next
;
123 enum bfd_architecture bfd_architecture
;
124 const struct bfd_arch_info
*bfd_arch_info
;
129 typedef struct gdbarch
*(gdbarch_init_ftype
) PARAMS ((const struct gdbarch_info
*info
, struct gdbarch_list
*arches
));
131 extern void register_gdbarch_init
PARAMS ((enum bfd_architecture
, gdbarch_init_ftype
*));
133 /* Helper function. Search ARCHES for a gdbarch that matches
134 information provided by INFO. */
136 extern struct gdbarch_list
*gdbarch_list_lookup_by_info
PARAMS ((struct gdbarch_list
*arches
, const struct gdbarch_info
*info
));
138 /* Helper function. Create a preliminary ``struct gdbarch''. Perform
139 basic initialization using values from the INFO structure. */
141 extern struct gdbarch
*gdbarch_alloc
PARAMS ((const struct gdbarch_info
*, struct gdbarch_tdep
*));
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. */
147 extern int gdbarch_update
PARAMS ((struct gdbarch_info
));
151 /* Register per-architecture data-pointer.
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.
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
162 INIT() shall return the initial value for the per-architecture
163 data-pointer for the current architecture.
165 Multiple registrarants for any architecture are allowed (and
166 strongly encouraged). */
168 typedef void *(gdbarch_data_ftype
) PARAMS ((void));
169 extern struct gdbarch_data
*register_gdbarch_data
PARAMS ((gdbarch_data_ftype
*init
));
172 /* Return the value of the per-architecture data-pointer for the
173 current architecture. */
175 extern void *gdbarch_data
PARAMS ((struct gdbarch_data
*));
178 /* Register per-architecture memory region.
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
186 Memory regions are swapped / initialized in the order that they are
187 registered. NULL DATA and/or INIT values can be specified. */
189 typedef void (gdbarch_swap_ftype
) PARAMS ((void));
190 extern void register_gdbarch_swap
PARAMS ((void *data
, unsigned long size
, gdbarch_swap_ftype
*init
));
193 /* end-sanitize-carp end-sanitize-vr4xxx */
195 /* The target-system-dependant byte order is dynamic */
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
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
209 #define TARGET_BYTE_ORDER_SELECTABLE_P 0
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
219 #ifndef TARGET_BYTE_ORDER
220 #define TARGET_BYTE_ORDER (target_byte_order + 0)
223 extern int target_byte_order_auto
;
224 #ifndef TARGET_BYTE_ORDER_AUTO
225 #define TARGET_BYTE_ORDER_AUTO (target_byte_order_auto + 0)
230 /* The target-system-dependant BFD architecture is dynamic */
232 extern int target_architecture_auto
;
233 #ifndef TARGET_ARCHITECTURE_AUTO
234 #define TARGET_ARCHITECTURE_AUTO (target_architecture_auto + 0)
237 extern const struct bfd_arch_info
*target_architecture
;
238 #ifndef TARGET_ARCHITECTURE
239 #define TARGET_ARCHITECTURE (target_architecture + 0)
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. */
246 extern int (*target_architecture_hook
) PARAMS ((const struct bfd_arch_info
*));
250 /* The target-system-dependant disassembler is semi-dynamic */
252 #include "dis-asm.h" /* Get defs for disassemble_info */
254 extern int dis_asm_read_memory
PARAMS ((bfd_vma memaddr
, bfd_byte
*myaddr
,
255 int len
, disassemble_info
*info
));
257 extern void dis_asm_memory_error
PARAMS ((int status
, bfd_vma memaddr
,
258 disassemble_info
*info
));
260 extern void dis_asm_print_address
PARAMS ((bfd_vma addr
,
261 disassemble_info
*info
));
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)
268 #ifndef TARGET_PRINT_INSN_INFO
269 #define TARGET_PRINT_INSN_INFO (&tm_print_insn_info)
274 /* Set the dynamic target-system-dependant parameters (architecture,
275 byte-order, ...) using information found in the BFD */
277 extern void set_gdbarch_from_file
PARAMS ((bfd
*));
280 /* Explicitly set the dynamic target-system-dependant parameters based
281 on bfd_architecture and machine. */
283 extern void set_architecture_from_arch_mach
PARAMS ((enum bfd_architecture
, unsigned long));
286 /* gdbarch trace variable */
287 extern int gdbarch_debug
;