* gdbarch.sh: Document the return_value method. Explain that
[platform/upstream/binutils.git] / gdb / gdbarch.h
1 /* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
2
3 /* Dynamic architecture support for GDB, the GNU debugger.
4
5    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
6    Free Software Foundation, Inc.
7
8    This file is part of GDB.
9
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 3 of the License, or
13    (at your option) any later version.
14   
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19   
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
22
23 /* This file was created with the aid of ``gdbarch.sh''.
24
25    The Bourne shell script ``gdbarch.sh'' creates the files
26    ``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
27    against the existing ``gdbarch.[hc]''.  Any differences found
28    being reported.
29
30    If editing this file, please also run gdbarch.sh and merge any
31    changes into that script. Conversely, when making sweeping changes
32    to this file, modifying gdbarch.sh and using its output may prove
33    easier. */
34
35 #ifndef GDBARCH_H
36 #define GDBARCH_H
37
38 struct floatformat;
39 struct ui_file;
40 struct frame_info;
41 struct value;
42 struct objfile;
43 struct obj_section;
44 struct minimal_symbol;
45 struct regcache;
46 struct reggroup;
47 struct regset;
48 struct disassemble_info;
49 struct target_ops;
50 struct obstack;
51 struct bp_target_info;
52 struct target_desc;
53
54 extern struct gdbarch *current_gdbarch;
55
56
57 /* The following are pre-initialized by GDBARCH. */
58
59 extern const struct bfd_arch_info * gdbarch_bfd_arch_info (struct gdbarch *gdbarch);
60 /* set_gdbarch_bfd_arch_info() - not applicable - pre-initialized. */
61
62 extern int gdbarch_byte_order (struct gdbarch *gdbarch);
63 /* set_gdbarch_byte_order() - not applicable - pre-initialized. */
64
65 extern enum gdb_osabi gdbarch_osabi (struct gdbarch *gdbarch);
66 /* set_gdbarch_osabi() - not applicable - pre-initialized. */
67
68 extern const struct target_desc * gdbarch_target_desc (struct gdbarch *gdbarch);
69 /* set_gdbarch_target_desc() - not applicable - pre-initialized. */
70
71
72 /* The following are initialized by the target dependent code. */
73
74 /* The bit byte-order has to do just with numbering of bits in debugging symbols
75    and such.  Conceptually, it's quite separate from byte/word byte order. */
76
77 extern int gdbarch_bits_big_endian (struct gdbarch *gdbarch);
78 extern void set_gdbarch_bits_big_endian (struct gdbarch *gdbarch, int bits_big_endian);
79
80 /* Number of bits in a char or unsigned char for the target machine.
81    Just like CHAR_BIT in <limits.h> but describes the target machine.
82    v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
83   
84    Number of bits in a short or unsigned short for the target machine. */
85
86 extern int gdbarch_short_bit (struct gdbarch *gdbarch);
87 extern void set_gdbarch_short_bit (struct gdbarch *gdbarch, int short_bit);
88
89 /* Number of bits in an int or unsigned int for the target machine. */
90
91 extern int gdbarch_int_bit (struct gdbarch *gdbarch);
92 extern void set_gdbarch_int_bit (struct gdbarch *gdbarch, int int_bit);
93
94 /* Number of bits in a long or unsigned long for the target machine. */
95
96 extern int gdbarch_long_bit (struct gdbarch *gdbarch);
97 extern void set_gdbarch_long_bit (struct gdbarch *gdbarch, int long_bit);
98
99 /* Number of bits in a long long or unsigned long long for the target
100    machine. */
101
102 extern int gdbarch_long_long_bit (struct gdbarch *gdbarch);
103 extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bit);
104
105 /* The ABI default bit-size and format for "float", "double", and "long
106    double".  These bit/format pairs should eventually be combined into
107    a single object.  For the moment, just initialize them as a pair.
108    Each format describes both the big and little endian layouts (if
109    useful). */
110
111 extern int gdbarch_float_bit (struct gdbarch *gdbarch);
112 extern void set_gdbarch_float_bit (struct gdbarch *gdbarch, int float_bit);
113
114 extern const struct floatformat ** gdbarch_float_format (struct gdbarch *gdbarch);
115 extern void set_gdbarch_float_format (struct gdbarch *gdbarch, const struct floatformat ** float_format);
116
117 extern int gdbarch_double_bit (struct gdbarch *gdbarch);
118 extern void set_gdbarch_double_bit (struct gdbarch *gdbarch, int double_bit);
119
120 extern const struct floatformat ** gdbarch_double_format (struct gdbarch *gdbarch);
121 extern void set_gdbarch_double_format (struct gdbarch *gdbarch, const struct floatformat ** double_format);
122
123 extern int gdbarch_long_double_bit (struct gdbarch *gdbarch);
124 extern void set_gdbarch_long_double_bit (struct gdbarch *gdbarch, int long_double_bit);
125
126 extern const struct floatformat ** gdbarch_long_double_format (struct gdbarch *gdbarch);
127 extern void set_gdbarch_long_double_format (struct gdbarch *gdbarch, const struct floatformat ** long_double_format);
128
129 /* For most targets, a pointer on the target and its representation as an
130    address in GDB have the same size and "look the same".  For such a
131    target, you need only set gdbarch_ptr_bit and gdbarch_addr_bit
132    / addr_bit will be set from it.
133   
134    If gdbarch_ptr_bit and gdbarch_addr_bit are different, you'll probably
135    also need to set gdbarch_pointer_to_address and gdbarch_address_to_pointer
136    as well.
137   
138    ptr_bit is the size of a pointer on the target */
139
140 extern int gdbarch_ptr_bit (struct gdbarch *gdbarch);
141 extern void set_gdbarch_ptr_bit (struct gdbarch *gdbarch, int ptr_bit);
142
143 /* addr_bit is the size of a target address as represented in gdb */
144
145 extern int gdbarch_addr_bit (struct gdbarch *gdbarch);
146 extern void set_gdbarch_addr_bit (struct gdbarch *gdbarch, int addr_bit);
147
148 /* One if `char' acts like `signed char', zero if `unsigned char'. */
149
150 extern int gdbarch_char_signed (struct gdbarch *gdbarch);
151 extern void set_gdbarch_char_signed (struct gdbarch *gdbarch, int char_signed);
152
153 extern int gdbarch_read_pc_p (struct gdbarch *gdbarch);
154
155 typedef CORE_ADDR (gdbarch_read_pc_ftype) (struct regcache *regcache);
156 extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, struct regcache *regcache);
157 extern void set_gdbarch_read_pc (struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc);
158
159 extern int gdbarch_write_pc_p (struct gdbarch *gdbarch);
160
161 typedef void (gdbarch_write_pc_ftype) (struct regcache *regcache, CORE_ADDR val);
162 extern void gdbarch_write_pc (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR val);
163 extern void set_gdbarch_write_pc (struct gdbarch *gdbarch, gdbarch_write_pc_ftype *write_pc);
164
165 /* Function for getting target's idea of a frame pointer.  FIXME: GDB's
166    whole scheme for dealing with "frames" and "frame pointers" needs a
167    serious shakedown. */
168
169 typedef void (gdbarch_virtual_frame_pointer_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset);
170 extern void gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset);
171 extern void set_gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer);
172
173 extern int gdbarch_pseudo_register_read_p (struct gdbarch *gdbarch);
174
175 typedef void (gdbarch_pseudo_register_read_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, gdb_byte *buf);
176 extern void gdbarch_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, gdb_byte *buf);
177 extern void set_gdbarch_pseudo_register_read (struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype *pseudo_register_read);
178
179 extern int gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch);
180
181 typedef void (gdbarch_pseudo_register_write_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, const gdb_byte *buf);
182 extern void gdbarch_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, const gdb_byte *buf);
183 extern void set_gdbarch_pseudo_register_write (struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype *pseudo_register_write);
184
185 extern int gdbarch_num_regs (struct gdbarch *gdbarch);
186 extern void set_gdbarch_num_regs (struct gdbarch *gdbarch, int num_regs);
187
188 /* This macro gives the number of pseudo-registers that live in the
189    register namespace but do not get fetched or stored on the target.
190    These pseudo-registers may be aliases for other registers,
191    combinations of other registers, or they may be computed by GDB. */
192
193 extern int gdbarch_num_pseudo_regs (struct gdbarch *gdbarch);
194 extern void set_gdbarch_num_pseudo_regs (struct gdbarch *gdbarch, int num_pseudo_regs);
195
196 /* GDB's standard (or well known) register numbers.  These can map onto
197    a real register or a pseudo (computed) register or not be defined at
198    all (-1).
199    gdbarch_sp_regnum will hopefully be replaced by UNWIND_SP. */
200
201 extern int gdbarch_sp_regnum (struct gdbarch *gdbarch);
202 extern void set_gdbarch_sp_regnum (struct gdbarch *gdbarch, int sp_regnum);
203
204 extern int gdbarch_pc_regnum (struct gdbarch *gdbarch);
205 extern void set_gdbarch_pc_regnum (struct gdbarch *gdbarch, int pc_regnum);
206
207 extern int gdbarch_ps_regnum (struct gdbarch *gdbarch);
208 extern void set_gdbarch_ps_regnum (struct gdbarch *gdbarch, int ps_regnum);
209
210 extern int gdbarch_fp0_regnum (struct gdbarch *gdbarch);
211 extern void set_gdbarch_fp0_regnum (struct gdbarch *gdbarch, int fp0_regnum);
212
213 /* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
214
215 typedef int (gdbarch_stab_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int stab_regnr);
216 extern int gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch, int stab_regnr);
217 extern void set_gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_stab_reg_to_regnum_ftype *stab_reg_to_regnum);
218
219 /* Provide a default mapping from a ecoff register number to a gdb REGNUM. */
220
221 typedef int (gdbarch_ecoff_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int ecoff_regnr);
222 extern int gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch, int ecoff_regnr);
223 extern void set_gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_ecoff_reg_to_regnum_ftype *ecoff_reg_to_regnum);
224
225 /* Provide a default mapping from a DWARF register number to a gdb REGNUM. */
226
227 typedef int (gdbarch_dwarf_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int dwarf_regnr);
228 extern int gdbarch_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int dwarf_regnr);
229 extern void set_gdbarch_dwarf_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_dwarf_reg_to_regnum_ftype *dwarf_reg_to_regnum);
230
231 /* Convert from an sdb register number to an internal gdb register number. */
232
233 typedef int (gdbarch_sdb_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int sdb_regnr);
234 extern int gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch, int sdb_regnr);
235 extern void set_gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_sdb_reg_to_regnum_ftype *sdb_reg_to_regnum);
236
237 typedef int (gdbarch_dwarf2_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int dwarf2_regnr);
238 extern int gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int dwarf2_regnr);
239 extern void set_gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum);
240
241 typedef const char * (gdbarch_register_name_ftype) (struct gdbarch *gdbarch, int regnr);
242 extern const char * gdbarch_register_name (struct gdbarch *gdbarch, int regnr);
243 extern void set_gdbarch_register_name (struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name);
244
245 /* Return the type of a register specified by the architecture.  Only
246    the register cache should call this function directly; others should
247    use "register_type". */
248
249 extern int gdbarch_register_type_p (struct gdbarch *gdbarch);
250
251 typedef struct type * (gdbarch_register_type_ftype) (struct gdbarch *gdbarch, int reg_nr);
252 extern struct type * gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr);
253 extern void set_gdbarch_register_type (struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type);
254
255 /* See gdbint.texinfo, and PUSH_DUMMY_CALL. */
256
257 extern int gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch);
258
259 typedef struct frame_id (gdbarch_unwind_dummy_id_ftype) (struct gdbarch *gdbarch, struct frame_info *info);
260 extern struct frame_id gdbarch_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *info);
261 extern void set_gdbarch_unwind_dummy_id (struct gdbarch *gdbarch, gdbarch_unwind_dummy_id_ftype *unwind_dummy_id);
262
263 /* Implement UNWIND_DUMMY_ID and PUSH_DUMMY_CALL, then delete
264    deprecated_fp_regnum. */
265
266 extern int gdbarch_deprecated_fp_regnum (struct gdbarch *gdbarch);
267 extern void set_gdbarch_deprecated_fp_regnum (struct gdbarch *gdbarch, int deprecated_fp_regnum);
268
269 /* See gdbint.texinfo.  See infcall.c. */
270
271 extern int gdbarch_push_dummy_call_p (struct gdbarch *gdbarch);
272
273 typedef CORE_ADDR (gdbarch_push_dummy_call_ftype) (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr);
274 extern CORE_ADDR gdbarch_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr);
275 extern void set_gdbarch_push_dummy_call (struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call);
276
277 extern int gdbarch_call_dummy_location (struct gdbarch *gdbarch);
278 extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, int call_dummy_location);
279
280 extern int gdbarch_push_dummy_code_p (struct gdbarch *gdbarch);
281
282 typedef CORE_ADDR (gdbarch_push_dummy_code_ftype) (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache);
283 extern CORE_ADDR gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache);
284 extern void set_gdbarch_push_dummy_code (struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype *push_dummy_code);
285
286 typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
287 extern void gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
288 extern void set_gdbarch_print_registers_info (struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info);
289
290 extern int gdbarch_print_float_info_p (struct gdbarch *gdbarch);
291
292 typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
293 extern void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
294 extern void set_gdbarch_print_float_info (struct gdbarch *gdbarch, gdbarch_print_float_info_ftype *print_float_info);
295
296 extern int gdbarch_print_vector_info_p (struct gdbarch *gdbarch);
297
298 typedef void (gdbarch_print_vector_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
299 extern void gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
300 extern void set_gdbarch_print_vector_info (struct gdbarch *gdbarch, gdbarch_print_vector_info_ftype *print_vector_info);
301
302 /* MAP a GDB RAW register number onto a simulator register number.  See
303    also include/...-sim.h. */
304
305 typedef int (gdbarch_register_sim_regno_ftype) (struct gdbarch *gdbarch, int reg_nr);
306 extern int gdbarch_register_sim_regno (struct gdbarch *gdbarch, int reg_nr);
307 extern void set_gdbarch_register_sim_regno (struct gdbarch *gdbarch, gdbarch_register_sim_regno_ftype *register_sim_regno);
308
309 typedef int (gdbarch_cannot_fetch_register_ftype) (struct gdbarch *gdbarch, int regnum);
310 extern int gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, int regnum);
311 extern void set_gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, gdbarch_cannot_fetch_register_ftype *cannot_fetch_register);
312
313 typedef int (gdbarch_cannot_store_register_ftype) (struct gdbarch *gdbarch, int regnum);
314 extern int gdbarch_cannot_store_register (struct gdbarch *gdbarch, int regnum);
315 extern void set_gdbarch_cannot_store_register (struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype *cannot_store_register);
316
317 /* setjmp/longjmp support. */
318
319 extern int gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch);
320
321 typedef int (gdbarch_get_longjmp_target_ftype) (struct frame_info *frame, CORE_ADDR *pc);
322 extern int gdbarch_get_longjmp_target (struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR *pc);
323 extern void set_gdbarch_get_longjmp_target (struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype *get_longjmp_target);
324
325 extern int gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch);
326 extern void set_gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch, int believe_pcc_promotion);
327
328 typedef int (gdbarch_convert_register_p_ftype) (struct gdbarch *gdbarch, int regnum, struct type *type);
329 extern int gdbarch_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type);
330 extern void set_gdbarch_convert_register_p (struct gdbarch *gdbarch, gdbarch_convert_register_p_ftype *convert_register_p);
331
332 typedef void (gdbarch_register_to_value_ftype) (struct frame_info *frame, int regnum, struct type *type, gdb_byte *buf);
333 extern void gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, gdb_byte *buf);
334 extern void set_gdbarch_register_to_value (struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value);
335
336 typedef void (gdbarch_value_to_register_ftype) (struct frame_info *frame, int regnum, struct type *type, const gdb_byte *buf);
337 extern void gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, const gdb_byte *buf);
338 extern void set_gdbarch_value_to_register (struct gdbarch *gdbarch, gdbarch_value_to_register_ftype *value_to_register);
339
340 /* Construct a value representing the contents of register REGNUM in
341    frame FRAME, interpreted as type TYPE.  The routine needs to
342    allocate and return a struct value with all value attributes
343    (but not the value contents) filled in. */
344
345 typedef struct value * (gdbarch_value_from_register_ftype) (struct type *type, int regnum, struct frame_info *frame);
346 extern struct value * gdbarch_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_info *frame);
347 extern void set_gdbarch_value_from_register (struct gdbarch *gdbarch, gdbarch_value_from_register_ftype *value_from_register);
348
349 typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct type *type, const gdb_byte *buf);
350 extern CORE_ADDR gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
351 extern void set_gdbarch_pointer_to_address (struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address);
352
353 typedef void (gdbarch_address_to_pointer_ftype) (struct type *type, gdb_byte *buf, CORE_ADDR addr);
354 extern void gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr);
355 extern void set_gdbarch_address_to_pointer (struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer);
356
357 extern int gdbarch_integer_to_address_p (struct gdbarch *gdbarch);
358
359 typedef CORE_ADDR (gdbarch_integer_to_address_ftype) (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
360 extern CORE_ADDR gdbarch_integer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
361 extern void set_gdbarch_integer_to_address (struct gdbarch *gdbarch, gdbarch_integer_to_address_ftype *integer_to_address);
362
363 /* Return the return-value convention that will be used by FUNCTYPE
364    to return a value of type VALTYPE.  FUNCTYPE may be NULL in which
365    case the return convention is computed based only on VALTYPE.
366   
367    If READBUF is not NULL, extract the return value and save it in this buffer.
368   
369    If WRITEBUF is not NULL, it contains a return value which will be
370    stored into the appropriate register.  This can be used when we want
371    to force the value returned by a function (see the "return" command
372    for instance). */
373
374 extern int gdbarch_return_value_p (struct gdbarch *gdbarch);
375
376 typedef enum return_value_convention (gdbarch_return_value_ftype) (struct gdbarch *gdbarch, struct type *functype, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf);
377 extern enum return_value_convention gdbarch_return_value (struct gdbarch *gdbarch, struct type *functype, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf);
378 extern void set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value);
379
380 typedef CORE_ADDR (gdbarch_skip_prologue_ftype) (struct gdbarch *gdbarch, CORE_ADDR ip);
381 extern CORE_ADDR gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip);
382 extern void set_gdbarch_skip_prologue (struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue);
383
384 typedef int (gdbarch_inner_than_ftype) (CORE_ADDR lhs, CORE_ADDR rhs);
385 extern int gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs);
386 extern void set_gdbarch_inner_than (struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than);
387
388 typedef const gdb_byte * (gdbarch_breakpoint_from_pc_ftype) (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
389 extern const gdb_byte * gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
390 extern void set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc);
391
392 extern int gdbarch_adjust_breakpoint_address_p (struct gdbarch *gdbarch);
393
394 typedef CORE_ADDR (gdbarch_adjust_breakpoint_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
395 extern CORE_ADDR gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
396 extern void set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address);
397
398 typedef int (gdbarch_memory_insert_breakpoint_ftype) (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
399 extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
400 extern void set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint);
401
402 typedef int (gdbarch_memory_remove_breakpoint_ftype) (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
403 extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
404 extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
405
406 extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
407 extern void set_gdbarch_decr_pc_after_break (struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break);
408
409 /* A function can be addressed by either it's "pointer" (possibly a
410    descriptor address) or "entry point" (first executable instruction).
411    The method "convert_from_func_ptr_addr" converting the former to the
412    latter.  gdbarch_deprecated_function_start_offset is being used to implement
413    a simplified subset of that functionality - the function's address
414    corresponds to the "function pointer" and the function's start
415    corresponds to the "function entry point" - and hence is redundant. */
416
417 extern CORE_ADDR gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch);
418 extern void set_gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch, CORE_ADDR deprecated_function_start_offset);
419
420 /* Return the remote protocol register number associated with this
421    register.  Normally the identity mapping. */
422
423 typedef int (gdbarch_remote_register_number_ftype) (struct gdbarch *gdbarch, int regno);
424 extern int gdbarch_remote_register_number (struct gdbarch *gdbarch, int regno);
425 extern void set_gdbarch_remote_register_number (struct gdbarch *gdbarch, gdbarch_remote_register_number_ftype *remote_register_number);
426
427 /* Fetch the target specific address used to represent a load module. */
428
429 extern int gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch);
430
431 typedef CORE_ADDR (gdbarch_fetch_tls_load_module_address_ftype) (struct objfile *objfile);
432 extern CORE_ADDR gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, struct objfile *objfile);
433 extern void set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address);
434
435 extern CORE_ADDR gdbarch_frame_args_skip (struct gdbarch *gdbarch);
436 extern void set_gdbarch_frame_args_skip (struct gdbarch *gdbarch, CORE_ADDR frame_args_skip);
437
438 extern int gdbarch_unwind_pc_p (struct gdbarch *gdbarch);
439
440 typedef CORE_ADDR (gdbarch_unwind_pc_ftype) (struct gdbarch *gdbarch, struct frame_info *next_frame);
441 extern CORE_ADDR gdbarch_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame);
442 extern void set_gdbarch_unwind_pc (struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc);
443
444 extern int gdbarch_unwind_sp_p (struct gdbarch *gdbarch);
445
446 typedef CORE_ADDR (gdbarch_unwind_sp_ftype) (struct gdbarch *gdbarch, struct frame_info *next_frame);
447 extern CORE_ADDR gdbarch_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame);
448 extern void set_gdbarch_unwind_sp (struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype *unwind_sp);
449
450 /* DEPRECATED_FRAME_LOCALS_ADDRESS as been replaced by the per-frame
451    frame-base.  Enable frame-base before frame-unwind. */
452
453 extern int gdbarch_frame_num_args_p (struct gdbarch *gdbarch);
454
455 typedef int (gdbarch_frame_num_args_ftype) (struct frame_info *frame);
456 extern int gdbarch_frame_num_args (struct gdbarch *gdbarch, struct frame_info *frame);
457 extern void set_gdbarch_frame_num_args (struct gdbarch *gdbarch, gdbarch_frame_num_args_ftype *frame_num_args);
458
459 extern int gdbarch_frame_align_p (struct gdbarch *gdbarch);
460
461 typedef CORE_ADDR (gdbarch_frame_align_ftype) (struct gdbarch *gdbarch, CORE_ADDR address);
462 extern CORE_ADDR gdbarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR address);
463 extern void set_gdbarch_frame_align (struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align);
464
465 typedef int (gdbarch_stabs_argument_has_addr_ftype) (struct gdbarch *gdbarch, struct type *type);
466 extern int gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type);
467 extern void set_gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr);
468
469 extern int gdbarch_frame_red_zone_size (struct gdbarch *gdbarch);
470 extern void set_gdbarch_frame_red_zone_size (struct gdbarch *gdbarch, int frame_red_zone_size);
471
472 typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
473 extern CORE_ADDR gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
474 extern void set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr);
475
476 /* On some machines there are bits in addresses which are not really
477    part of the address, but are used by the kernel, the hardware, etc.
478    for special purposes.  gdbarch_addr_bits_remove takes out any such bits so
479    we get a "real" address such as one would find in a symbol table.
480    This is used only for addresses of instructions, and even then I'm
481    not sure it's used in all contexts.  It exists to deal with there
482    being a few stray bits in the PC which would mislead us, not as some
483    sort of generic thing to handle alignment or segmentation (it's
484    possible it should be in TARGET_READ_PC instead). */
485
486 typedef CORE_ADDR (gdbarch_addr_bits_remove_ftype) (CORE_ADDR addr);
487 extern CORE_ADDR gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr);
488 extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_bits_remove_ftype *addr_bits_remove);
489
490 /* It is not at all clear why gdbarch_smash_text_address is not folded into
491    gdbarch_addr_bits_remove. */
492
493 typedef CORE_ADDR (gdbarch_smash_text_address_ftype) (CORE_ADDR addr);
494 extern CORE_ADDR gdbarch_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr);
495 extern void set_gdbarch_smash_text_address (struct gdbarch *gdbarch, gdbarch_smash_text_address_ftype *smash_text_address);
496
497 /* FIXME/cagney/2001-01-18: This should be split in two.  A target method that
498    indicates if the target needs software single step.  An ISA method to
499    implement it.
500   
501    FIXME/cagney/2001-01-18: This should be replaced with something that inserts
502    breakpoints using the breakpoint system instead of blatting memory directly
503    (as with rs6000).
504   
505    FIXME/cagney/2001-01-18: The logic is backwards.  It should be asking if the
506    target can single step.  If not, then implement single step using breakpoints.
507   
508    A return value of 1 means that the software_single_step breakpoints
509    were inserted; 0 means they were not. */
510
511 extern int gdbarch_software_single_step_p (struct gdbarch *gdbarch);
512
513 typedef int (gdbarch_software_single_step_ftype) (struct frame_info *frame);
514 extern int gdbarch_software_single_step (struct gdbarch *gdbarch, struct frame_info *frame);
515 extern void set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step);
516
517 /* Return non-zero if the processor is executing a delay slot and a
518    further single-step is needed before the instruction finishes. */
519
520 extern int gdbarch_single_step_through_delay_p (struct gdbarch *gdbarch);
521
522 typedef int (gdbarch_single_step_through_delay_ftype) (struct gdbarch *gdbarch, struct frame_info *frame);
523 extern int gdbarch_single_step_through_delay (struct gdbarch *gdbarch, struct frame_info *frame);
524 extern void set_gdbarch_single_step_through_delay (struct gdbarch *gdbarch, gdbarch_single_step_through_delay_ftype *single_step_through_delay);
525
526 /* FIXME: cagney/2003-08-28: Need to find a better way of selecting the
527    disassembler.  Perhaps objdump can handle it? */
528
529 typedef int (gdbarch_print_insn_ftype) (bfd_vma vma, struct disassemble_info *info);
530 extern int gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, struct disassemble_info *info);
531 extern void set_gdbarch_print_insn (struct gdbarch *gdbarch, gdbarch_print_insn_ftype *print_insn);
532
533 typedef CORE_ADDR (gdbarch_skip_trampoline_code_ftype) (struct frame_info *frame, CORE_ADDR pc);
534 extern CORE_ADDR gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR pc);
535 extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code);
536
537 /* If IN_SOLIB_DYNSYM_RESOLVE_CODE returns true, and SKIP_SOLIB_RESOLVER
538    evaluates non-zero, this is the address where the debugger will place
539    a step-resume breakpoint to get us past the dynamic linker. */
540
541 typedef CORE_ADDR (gdbarch_skip_solib_resolver_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc);
542 extern CORE_ADDR gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc);
543 extern void set_gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype *skip_solib_resolver);
544
545 /* Some systems also have trampoline code for returning from shared libs. */
546
547 typedef int (gdbarch_in_solib_return_trampoline_ftype) (CORE_ADDR pc, char *name);
548 extern int gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
549 extern void set_gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline);
550
551 /* A target might have problems with watchpoints as soon as the stack
552    frame of the current function has been destroyed.  This mostly happens
553    as the first action in a funtion's epilogue.  in_function_epilogue_p()
554    is defined to return a non-zero value if either the given addr is one
555    instruction after the stack destroying instruction up to the trailing
556    return instruction or if we can figure out that the stack frame has
557    already been invalidated regardless of the value of addr.  Targets
558    which don't suffer from that problem could just let this functionality
559    untouched. */
560
561 typedef int (gdbarch_in_function_epilogue_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
562 extern int gdbarch_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR addr);
563 extern void set_gdbarch_in_function_epilogue_p (struct gdbarch *gdbarch, gdbarch_in_function_epilogue_p_ftype *in_function_epilogue_p);
564
565 /* Given a vector of command-line arguments, return a newly allocated
566    string which, when passed to the create_inferior function, will be
567    parsed (on Unix systems, by the shell) to yield the same vector.
568    This function should call error() if the argument vector is not
569    representable for this target or if this target does not support
570    command-line arguments.
571    ARGC is the number of elements in the vector.
572    ARGV is an array of strings, one per argument. */
573
574 typedef char * (gdbarch_construct_inferior_arguments_ftype) (struct gdbarch *gdbarch, int argc, char **argv);
575 extern char * gdbarch_construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv);
576 extern void set_gdbarch_construct_inferior_arguments (struct gdbarch *gdbarch, gdbarch_construct_inferior_arguments_ftype *construct_inferior_arguments);
577
578 typedef void (gdbarch_elf_make_msymbol_special_ftype) (asymbol *sym, struct minimal_symbol *msym);
579 extern void gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym);
580 extern void set_gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special);
581
582 typedef void (gdbarch_coff_make_msymbol_special_ftype) (int val, struct minimal_symbol *msym);
583 extern void gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, int val, struct minimal_symbol *msym);
584 extern void set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special);
585
586 extern const char * gdbarch_name_of_malloc (struct gdbarch *gdbarch);
587 extern void set_gdbarch_name_of_malloc (struct gdbarch *gdbarch, const char * name_of_malloc);
588
589 extern int gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch);
590 extern void set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch, int cannot_step_breakpoint);
591
592 extern int gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch);
593 extern void set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch, int have_nonsteppable_watchpoint);
594
595 extern int gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch);
596
597 typedef int (gdbarch_address_class_type_flags_ftype) (int byte_size, int dwarf2_addr_class);
598 extern int gdbarch_address_class_type_flags (struct gdbarch *gdbarch, int byte_size, int dwarf2_addr_class);
599 extern void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype *address_class_type_flags);
600
601 extern int gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch);
602
603 typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, int type_flags);
604 extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags);
605 extern void set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name);
606
607 extern int gdbarch_address_class_name_to_type_flags_p (struct gdbarch *gdbarch);
608
609 typedef int (gdbarch_address_class_name_to_type_flags_ftype) (struct gdbarch *gdbarch, const char *name, int *type_flags_ptr);
610 extern int gdbarch_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char *name, int *type_flags_ptr);
611 extern void set_gdbarch_address_class_name_to_type_flags (struct gdbarch *gdbarch, gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags);
612
613 /* Is a register in a group */
614
615 typedef int (gdbarch_register_reggroup_p_ftype) (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
616 extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
617 extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
618
619 /* Fetch the pointer to the ith function argument. */
620
621 extern int gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch);
622
623 typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct frame_info *frame, int argi, struct type *type);
624 extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type);
625 extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
626
627 /* Return the appropriate register set for a core file section with
628    name SECT_NAME and size SECT_SIZE. */
629
630 extern int gdbarch_regset_from_core_section_p (struct gdbarch *gdbarch);
631
632 typedef const struct regset * (gdbarch_regset_from_core_section_ftype) (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size);
633 extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size);
634 extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section);
635
636 /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from
637    core file into buffer READBUF with length LEN. */
638
639 extern int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch);
640
641 typedef LONGEST (gdbarch_core_xfer_shared_libraries_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
642 extern LONGEST gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
643 extern void set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries);
644
645 /* If the elements of C++ vtables are in-place function descriptors rather
646    than normal function pointers (which may point to code or a descriptor),
647    set this to one. */
648
649 extern int gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch);
650 extern void set_gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch, int vtable_function_descriptors);
651
652 /* Set if the least significant bit of the delta is used instead of the least
653    significant bit of the pfn for pointers to virtual member functions. */
654
655 extern int gdbarch_vbit_in_delta (struct gdbarch *gdbarch);
656 extern void set_gdbarch_vbit_in_delta (struct gdbarch *gdbarch, int vbit_in_delta);
657
658 /* Advance PC to next instruction in order to skip a permanent breakpoint. */
659
660 extern int gdbarch_skip_permanent_breakpoint_p (struct gdbarch *gdbarch);
661
662 typedef void (gdbarch_skip_permanent_breakpoint_ftype) (struct regcache *regcache);
663 extern void gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache);
664 extern void set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint);
665
666 /* Refresh overlay mapped state for section OSECT. */
667
668 extern int gdbarch_overlay_update_p (struct gdbarch *gdbarch);
669
670 typedef void (gdbarch_overlay_update_ftype) (struct obj_section *osect);
671 extern void gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect);
672 extern void set_gdbarch_overlay_update (struct gdbarch *gdbarch, gdbarch_overlay_update_ftype *overlay_update);
673
674 extern int gdbarch_core_read_description_p (struct gdbarch *gdbarch);
675
676 typedef const struct target_desc * (gdbarch_core_read_description_ftype) (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
677 extern const struct target_desc * gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
678 extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_core_read_description_ftype *core_read_description);
679
680 /* Handle special encoding of static variables in stabs debug info. */
681
682 extern int gdbarch_static_transform_name_p (struct gdbarch *gdbarch);
683
684 typedef char * (gdbarch_static_transform_name_ftype) (char *name);
685 extern char * gdbarch_static_transform_name (struct gdbarch *gdbarch, char *name);
686 extern void set_gdbarch_static_transform_name (struct gdbarch *gdbarch, gdbarch_static_transform_name_ftype *static_transform_name);
687
688 /* Set if the address in N_SO or N_FUN stabs may be zero. */
689
690 extern int gdbarch_sofun_address_maybe_missing (struct gdbarch *gdbarch);
691 extern void set_gdbarch_sofun_address_maybe_missing (struct gdbarch *gdbarch, int sofun_address_maybe_missing);
692
693 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
694
695
696 /* Mechanism for co-ordinating the selection of a specific
697    architecture.
698
699    GDB targets (*-tdep.c) can register an interest in a specific
700    architecture.  Other GDB components can register a need to maintain
701    per-architecture data.
702
703    The mechanisms below ensures that there is only a loose connection
704    between the set-architecture command and the various GDB
705    components.  Each component can independently register their need
706    to maintain architecture specific data with gdbarch.
707
708    Pragmatics:
709
710    Previously, a single TARGET_ARCHITECTURE_HOOK was provided.  It
711    didn't scale.
712
713    The more traditional mega-struct containing architecture specific
714    data for all the various GDB components was also considered.  Since
715    GDB is built from a variable number of (fairly independent)
716    components it was determined that the global aproach was not
717    applicable. */
718
719
720 /* Register a new architectural family with GDB.
721
722    Register support for the specified ARCHITECTURE with GDB.  When
723    gdbarch determines that the specified architecture has been
724    selected, the corresponding INIT function is called.
725
726    --
727
728    The INIT function takes two parameters: INFO which contains the
729    information available to gdbarch about the (possibly new)
730    architecture; ARCHES which is a list of the previously created
731    ``struct gdbarch'' for this architecture.
732
733    The INFO parameter is, as far as possible, be pre-initialized with
734    information obtained from INFO.ABFD or the global defaults.
735
736    The ARCHES parameter is a linked list (sorted most recently used)
737    of all the previously created architures for this architecture
738    family.  The (possibly NULL) ARCHES->gdbarch can used to access
739    values from the previously selected architecture for this
740    architecture family.  The global ``current_gdbarch'' shall not be
741    used.
742
743    The INIT function shall return any of: NULL - indicating that it
744    doesn't recognize the selected architecture; an existing ``struct
745    gdbarch'' from the ARCHES list - indicating that the new
746    architecture is just a synonym for an earlier architecture (see
747    gdbarch_list_lookup_by_info()); a newly created ``struct gdbarch''
748    - that describes the selected architecture (see gdbarch_alloc()).
749
750    The DUMP_TDEP function shall print out all target specific values.
751    Care should be taken to ensure that the function works in both the
752    multi-arch and non- multi-arch cases. */
753
754 struct gdbarch_list
755 {
756   struct gdbarch *gdbarch;
757   struct gdbarch_list *next;
758 };
759
760 struct gdbarch_info
761 {
762   /* Use default: NULL (ZERO). */
763   const struct bfd_arch_info *bfd_arch_info;
764
765   /* Use default: BFD_ENDIAN_UNKNOWN (NB: is not ZERO).  */
766   int byte_order;
767
768   /* Use default: NULL (ZERO). */
769   bfd *abfd;
770
771   /* Use default: NULL (ZERO). */
772   struct gdbarch_tdep_info *tdep_info;
773
774   /* Use default: GDB_OSABI_UNINITIALIZED (-1).  */
775   enum gdb_osabi osabi;
776
777   /* Use default: NULL (ZERO).  */
778   const struct target_desc *target_desc;
779 };
780
781 typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches);
782 typedef void (gdbarch_dump_tdep_ftype) (struct gdbarch *gdbarch, struct ui_file *file);
783
784 /* DEPRECATED - use gdbarch_register() */
785 extern void register_gdbarch_init (enum bfd_architecture architecture, gdbarch_init_ftype *);
786
787 extern void gdbarch_register (enum bfd_architecture architecture,
788                               gdbarch_init_ftype *,
789                               gdbarch_dump_tdep_ftype *);
790
791
792 /* Return a freshly allocated, NULL terminated, array of the valid
793    architecture names.  Since architectures are registered during the
794    _initialize phase this function only returns useful information
795    once initialization has been completed. */
796
797 extern const char **gdbarch_printable_names (void);
798
799
800 /* Helper function.  Search the list of ARCHES for a GDBARCH that
801    matches the information provided by INFO. */
802
803 extern struct gdbarch_list *gdbarch_list_lookup_by_info (struct gdbarch_list *arches, const struct gdbarch_info *info);
804
805
806 /* Helper function.  Create a preliminary ``struct gdbarch''.  Perform
807    basic initialization using values obtained from the INFO and TDEP
808    parameters.  set_gdbarch_*() functions are called to complete the
809    initialization of the object. */
810
811 extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep *tdep);
812
813
814 /* Helper function.  Free a partially-constructed ``struct gdbarch''.
815    It is assumed that the caller freeds the ``struct
816    gdbarch_tdep''. */
817
818 extern void gdbarch_free (struct gdbarch *);
819
820
821 /* Helper function.  Allocate memory from the ``struct gdbarch''
822    obstack.  The memory is freed when the corresponding architecture
823    is also freed.  */
824
825 extern void *gdbarch_obstack_zalloc (struct gdbarch *gdbarch, long size);
826 #define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE) ((TYPE *) gdbarch_obstack_zalloc ((GDBARCH), (NR) * sizeof (TYPE)))
827 #define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE) ((TYPE *) gdbarch_obstack_zalloc ((GDBARCH), sizeof (TYPE)))
828
829
830 /* Helper function. Force an update of the current architecture.
831
832    The actual architecture selected is determined by INFO, ``(gdb) set
833    architecture'' et.al., the existing architecture and BFD's default
834    architecture.  INFO should be initialized to zero and then selected
835    fields should be updated.
836
837    Returns non-zero if the update succeeds */
838
839 extern int gdbarch_update_p (struct gdbarch_info info);
840
841
842 /* Helper function.  Find an architecture matching info.
843
844    INFO should be initialized using gdbarch_info_init, relevant fields
845    set, and then finished using gdbarch_info_fill.
846
847    Returns the corresponding architecture, or NULL if no matching
848    architecture was found.  "current_gdbarch" is not updated.  */
849
850 extern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info);
851
852
853 /* Helper function.  Set the global "current_gdbarch" to "gdbarch".
854
855    FIXME: kettenis/20031124: Of the functions that follow, only
856    gdbarch_from_bfd is supposed to survive.  The others will
857    dissappear since in the future GDB will (hopefully) be truly
858    multi-arch.  However, for now we're still stuck with the concept of
859    a single active architecture.  */
860
861 extern void deprecated_current_gdbarch_select_hack (struct gdbarch *gdbarch);
862
863
864 /* Register per-architecture data-pointer.
865
866    Reserve space for a per-architecture data-pointer.  An identifier
867    for the reserved data-pointer is returned.  That identifer should
868    be saved in a local static variable.
869
870    Memory for the per-architecture data shall be allocated using
871    gdbarch_obstack_zalloc.  That memory will be deleted when the
872    corresponding architecture object is deleted.
873
874    When a previously created architecture is re-selected, the
875    per-architecture data-pointer for that previous architecture is
876    restored.  INIT() is not re-called.
877
878    Multiple registrarants for any architecture are allowed (and
879    strongly encouraged).  */
880
881 struct gdbarch_data;
882
883 typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
884 extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
885 typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
886 extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
887 extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
888                                          struct gdbarch_data *data,
889                                          void *pointer);
890
891 extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
892
893
894 /* Set the dynamic target-system-dependent parameters (architecture,
895    byte-order, ...) using information found in the BFD */
896
897 extern void set_gdbarch_from_file (bfd *);
898
899
900 /* Initialize the current architecture to the "first" one we find on
901    our list.  */
902
903 extern void initialize_current_architecture (void);
904
905 /* gdbarch trace variable */
906 extern int gdbarch_debug;
907
908 extern void gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file);
909
910 #endif