* gdbarch.sh (BELIEVE_PCC_PROMOTION): Replace by
[external/binutils.git] / gdb / gdbarch.c
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
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 2 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, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor,
23    Boston, MA 02110-1301, USA.  */
24
25 /* This file was created with the aid of ``gdbarch.sh''.
26
27    The Bourne shell script ``gdbarch.sh'' creates the files
28    ``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
29    against the existing ``gdbarch.[hc]''.  Any differences found
30    being reported.
31
32    If editing this file, please also run gdbarch.sh and merge any
33    changes into that script. Conversely, when making sweeping changes
34    to this file, modifying gdbarch.sh and using its output may prove
35    easier. */
36
37
38 #include "defs.h"
39 #include "arch-utils.h"
40
41 #include "gdbcmd.h"
42 #include "inferior.h" 
43 #include "symcat.h"
44
45 #include "floatformat.h"
46
47 #include "gdb_assert.h"
48 #include "gdb_string.h"
49 #include "gdb-events.h"
50 #include "reggroups.h"
51 #include "osabi.h"
52 #include "gdb_obstack.h"
53
54 /* Static function declarations */
55
56 static void alloc_gdbarch_data (struct gdbarch *);
57
58 /* Non-zero if we want to trace architecture code.  */
59
60 #ifndef GDBARCH_DEBUG
61 #define GDBARCH_DEBUG 0
62 #endif
63 int gdbarch_debug = GDBARCH_DEBUG;
64 static void
65 show_gdbarch_debug (struct ui_file *file, int from_tty,
66                     struct cmd_list_element *c, const char *value)
67 {
68   fprintf_filtered (file, _("Architecture debugging is %s.\n"), value);
69 }
70
71 static const char *
72 pformat (const struct floatformat **format)
73 {
74   if (format == NULL)
75     return "(null)";
76   else
77     /* Just print out one of them - this is only for diagnostics.  */
78     return format[0]->name;
79 }
80
81
82 /* Maintain the struct gdbarch object */
83
84 struct gdbarch
85 {
86   /* Has this architecture been fully initialized?  */
87   int initialized_p;
88
89   /* An obstack bound to the lifetime of the architecture.  */
90   struct obstack *obstack;
91
92   /* basic architectural information */
93   const struct bfd_arch_info * bfd_arch_info;
94   int byte_order;
95   enum gdb_osabi osabi;
96   const struct target_desc * target_desc;
97
98   /* target specific vector. */
99   struct gdbarch_tdep *tdep;
100   gdbarch_dump_tdep_ftype *dump_tdep;
101
102   /* per-architecture data-pointers */
103   unsigned nr_data;
104   void **data;
105
106   /* per-architecture swap-regions */
107   struct gdbarch_swap *swap;
108
109   /* Multi-arch values.
110
111      When extending this structure you must:
112
113      Add the field below.
114
115      Declare set/get functions and define the corresponding
116      macro in gdbarch.h.
117
118      gdbarch_alloc(): If zero/NULL is not a suitable default,
119      initialize the new field.
120
121      verify_gdbarch(): Confirm that the target updated the field
122      correctly.
123
124      gdbarch_dump(): Add a fprintf_unfiltered call so that the new
125      field is dumped out
126
127      ``startup_gdbarch()'': Append an initial value to the static
128      variable (base values on the host's c-type system).
129
130      get_gdbarch(): Implement the set/get functions (probably using
131      the macro's as shortcuts).
132
133      */
134
135   int short_bit;
136   int int_bit;
137   int long_bit;
138   int long_long_bit;
139   int float_bit;
140   const struct floatformat ** float_format;
141   int double_bit;
142   const struct floatformat ** double_format;
143   int long_double_bit;
144   const struct floatformat ** long_double_format;
145   int ptr_bit;
146   int addr_bit;
147   int char_signed;
148   gdbarch_read_pc_ftype *read_pc;
149   gdbarch_write_pc_ftype *write_pc;
150   gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer;
151   gdbarch_pseudo_register_read_ftype *pseudo_register_read;
152   gdbarch_pseudo_register_write_ftype *pseudo_register_write;
153   int num_regs;
154   int num_pseudo_regs;
155   int sp_regnum;
156   int pc_regnum;
157   int ps_regnum;
158   int fp0_regnum;
159   gdbarch_stab_reg_to_regnum_ftype *stab_reg_to_regnum;
160   gdbarch_ecoff_reg_to_regnum_ftype *ecoff_reg_to_regnum;
161   gdbarch_dwarf_reg_to_regnum_ftype *dwarf_reg_to_regnum;
162   gdbarch_sdb_reg_to_regnum_ftype *sdb_reg_to_regnum;
163   gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum;
164   gdbarch_register_name_ftype *register_name;
165   gdbarch_register_type_ftype *register_type;
166   gdbarch_unwind_dummy_id_ftype *unwind_dummy_id;
167   int deprecated_fp_regnum;
168   gdbarch_push_dummy_call_ftype *push_dummy_call;
169   int call_dummy_location;
170   gdbarch_push_dummy_code_ftype *push_dummy_code;
171   gdbarch_print_registers_info_ftype *print_registers_info;
172   gdbarch_print_float_info_ftype *print_float_info;
173   gdbarch_print_vector_info_ftype *print_vector_info;
174   gdbarch_register_sim_regno_ftype *register_sim_regno;
175   gdbarch_cannot_fetch_register_ftype *cannot_fetch_register;
176   gdbarch_cannot_store_register_ftype *cannot_store_register;
177   gdbarch_get_longjmp_target_ftype *get_longjmp_target;
178   int believe_pcc_promotion;
179   gdbarch_convert_register_p_ftype *convert_register_p;
180   gdbarch_register_to_value_ftype *register_to_value;
181   gdbarch_value_to_register_ftype *value_to_register;
182   gdbarch_value_from_register_ftype *value_from_register;
183   gdbarch_pointer_to_address_ftype *pointer_to_address;
184   gdbarch_address_to_pointer_ftype *address_to_pointer;
185   gdbarch_integer_to_address_ftype *integer_to_address;
186   gdbarch_return_value_ftype *return_value;
187   gdbarch_extract_return_value_ftype *extract_return_value;
188   gdbarch_store_return_value_ftype *store_return_value;
189   gdbarch_deprecated_use_struct_convention_ftype *deprecated_use_struct_convention;
190   gdbarch_skip_prologue_ftype *skip_prologue;
191   gdbarch_inner_than_ftype *inner_than;
192   gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc;
193   gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address;
194   gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint;
195   gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint;
196   CORE_ADDR decr_pc_after_break;
197   CORE_ADDR deprecated_function_start_offset;
198   gdbarch_remote_register_number_ftype *remote_register_number;
199   gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address;
200   CORE_ADDR frame_args_skip;
201   gdbarch_unwind_pc_ftype *unwind_pc;
202   gdbarch_unwind_sp_ftype *unwind_sp;
203   gdbarch_frame_num_args_ftype *frame_num_args;
204   gdbarch_frame_align_ftype *frame_align;
205   gdbarch_deprecated_reg_struct_has_addr_ftype *deprecated_reg_struct_has_addr;
206   gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr;
207   int frame_red_zone_size;
208   gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr;
209   gdbarch_addr_bits_remove_ftype *addr_bits_remove;
210   gdbarch_smash_text_address_ftype *smash_text_address;
211   gdbarch_software_single_step_ftype *software_single_step;
212   gdbarch_single_step_through_delay_ftype *single_step_through_delay;
213   gdbarch_print_insn_ftype *print_insn;
214   gdbarch_skip_trampoline_code_ftype *skip_trampoline_code;
215   gdbarch_skip_solib_resolver_ftype *skip_solib_resolver;
216   gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline;
217   gdbarch_in_function_epilogue_p_ftype *in_function_epilogue_p;
218   gdbarch_construct_inferior_arguments_ftype *construct_inferior_arguments;
219   gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special;
220   gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special;
221   const char * name_of_malloc;
222   int cannot_step_breakpoint;
223   int have_nonsteppable_watchpoint;
224   gdbarch_address_class_type_flags_ftype *address_class_type_flags;
225   gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name;
226   gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags;
227   gdbarch_register_reggroup_p_ftype *register_reggroup_p;
228   gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
229   gdbarch_regset_from_core_section_ftype *regset_from_core_section;
230   int vtable_function_descriptors;
231   int vbit_in_delta;
232   gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
233   gdbarch_overlay_update_ftype *overlay_update;
234 };
235
236
237 /* The default architecture uses host values (for want of a better
238    choice). */
239
240 extern const struct bfd_arch_info bfd_default_arch_struct;
241
242 struct gdbarch startup_gdbarch =
243 {
244   1, /* Always initialized.  */
245   NULL, /* The obstack.  */
246   /* basic architecture information */
247   &bfd_default_arch_struct,  /* bfd_arch_info */
248   BFD_ENDIAN_BIG,  /* byte_order */
249   GDB_OSABI_UNKNOWN,  /* osabi */
250   0,  /* target_desc */
251   /* target specific vector and its dump routine */
252   NULL, NULL,
253   /*per-architecture data-pointers and swap regions */
254   0, NULL, NULL,
255   /* Multi-arch values */
256   8 * sizeof (short),  /* short_bit */
257   8 * sizeof (int),  /* int_bit */
258   8 * sizeof (long),  /* long_bit */
259   8 * sizeof (LONGEST),  /* long_long_bit */
260   8 * sizeof (float),  /* float_bit */
261   0,  /* float_format */
262   8 * sizeof (double),  /* double_bit */
263   0,  /* double_format */
264   8 * sizeof (long double),  /* long_double_bit */
265   0,  /* long_double_format */
266   8 * sizeof (void*),  /* ptr_bit */
267   8 * sizeof (void*),  /* addr_bit */
268   1,  /* char_signed */
269   0,  /* read_pc */
270   0,  /* write_pc */
271   0,  /* virtual_frame_pointer */
272   0,  /* pseudo_register_read */
273   0,  /* pseudo_register_write */
274   0,  /* num_regs */
275   0,  /* num_pseudo_regs */
276   -1,  /* sp_regnum */
277   -1,  /* pc_regnum */
278   -1,  /* ps_regnum */
279   0,  /* fp0_regnum */
280   0,  /* stab_reg_to_regnum */
281   0,  /* ecoff_reg_to_regnum */
282   0,  /* dwarf_reg_to_regnum */
283   0,  /* sdb_reg_to_regnum */
284   0,  /* dwarf2_reg_to_regnum */
285   0,  /* register_name */
286   0,  /* register_type */
287   0,  /* unwind_dummy_id */
288   -1,  /* deprecated_fp_regnum */
289   0,  /* push_dummy_call */
290   0,  /* call_dummy_location */
291   0,  /* push_dummy_code */
292   default_print_registers_info,  /* print_registers_info */
293   0,  /* print_float_info */
294   0,  /* print_vector_info */
295   0,  /* register_sim_regno */
296   0,  /* cannot_fetch_register */
297   0,  /* cannot_store_register */
298   0,  /* get_longjmp_target */
299   0,  /* believe_pcc_promotion */
300   0,  /* convert_register_p */
301   0,  /* register_to_value */
302   0,  /* value_to_register */
303   0,  /* value_from_register */
304   0,  /* pointer_to_address */
305   0,  /* address_to_pointer */
306   0,  /* integer_to_address */
307   0,  /* return_value */
308   0,  /* extract_return_value */
309   0,  /* store_return_value */
310   0,  /* deprecated_use_struct_convention */
311   0,  /* skip_prologue */
312   0,  /* inner_than */
313   0,  /* breakpoint_from_pc */
314   0,  /* adjust_breakpoint_address */
315   0,  /* memory_insert_breakpoint */
316   0,  /* memory_remove_breakpoint */
317   0,  /* decr_pc_after_break */
318   0,  /* deprecated_function_start_offset */
319   default_remote_register_number,  /* remote_register_number */
320   0,  /* fetch_tls_load_module_address */
321   0,  /* frame_args_skip */
322   0,  /* unwind_pc */
323   0,  /* unwind_sp */
324   0,  /* frame_num_args */
325   0,  /* frame_align */
326   0,  /* deprecated_reg_struct_has_addr */
327   default_stabs_argument_has_addr,  /* stabs_argument_has_addr */
328   0,  /* frame_red_zone_size */
329   convert_from_func_ptr_addr_identity,  /* convert_from_func_ptr_addr */
330   0,  /* addr_bits_remove */
331   0,  /* smash_text_address */
332   0,  /* software_single_step */
333   0,  /* single_step_through_delay */
334   0,  /* print_insn */
335   0,  /* skip_trampoline_code */
336   generic_skip_solib_resolver,  /* skip_solib_resolver */
337   0,  /* in_solib_return_trampoline */
338   generic_in_function_epilogue_p,  /* in_function_epilogue_p */
339   construct_inferior_arguments,  /* construct_inferior_arguments */
340   0,  /* elf_make_msymbol_special */
341   0,  /* coff_make_msymbol_special */
342   "malloc",  /* name_of_malloc */
343   0,  /* cannot_step_breakpoint */
344   0,  /* have_nonsteppable_watchpoint */
345   0,  /* address_class_type_flags */
346   0,  /* address_class_type_flags_to_name */
347   0,  /* address_class_name_to_type_flags */
348   default_register_reggroup_p,  /* register_reggroup_p */
349   0,  /* fetch_pointer_argument */
350   0,  /* regset_from_core_section */
351   0,  /* vtable_function_descriptors */
352   0,  /* vbit_in_delta */
353   0,  /* skip_permanent_breakpoint */
354   0,  /* overlay_update */
355   /* startup_gdbarch() */
356 };
357
358 struct gdbarch *current_gdbarch = &startup_gdbarch;
359
360 /* Create a new ``struct gdbarch'' based on information provided by
361    ``struct gdbarch_info''. */
362
363 struct gdbarch *
364 gdbarch_alloc (const struct gdbarch_info *info,
365                struct gdbarch_tdep *tdep)
366 {
367   /* NOTE: The new architecture variable is named ``current_gdbarch''
368      so that macros such as TARGET_ARCHITECTURE, when expanded, refer to
369      the current local architecture and not the previous global
370      architecture.  This ensures that the new architectures initial
371      values are not influenced by the previous architecture.  Once
372      everything is parameterised with gdbarch, this will go away.  */
373   struct gdbarch *current_gdbarch;
374
375   /* Create an obstack for allocating all the per-architecture memory,
376      then use that to allocate the architecture vector.  */
377   struct obstack *obstack = XMALLOC (struct obstack);
378   obstack_init (obstack);
379   current_gdbarch = obstack_alloc (obstack, sizeof (*current_gdbarch));
380   memset (current_gdbarch, 0, sizeof (*current_gdbarch));
381   current_gdbarch->obstack = obstack;
382
383   alloc_gdbarch_data (current_gdbarch);
384
385   current_gdbarch->tdep = tdep;
386
387   current_gdbarch->bfd_arch_info = info->bfd_arch_info;
388   current_gdbarch->byte_order = info->byte_order;
389   current_gdbarch->osabi = info->osabi;
390   current_gdbarch->target_desc = info->target_desc;
391
392   /* Force the explicit initialization of these. */
393   current_gdbarch->short_bit = 2*TARGET_CHAR_BIT;
394   current_gdbarch->int_bit = 4*TARGET_CHAR_BIT;
395   current_gdbarch->long_bit = 4*TARGET_CHAR_BIT;
396   current_gdbarch->long_long_bit = 2*current_gdbarch->long_bit;
397   current_gdbarch->float_bit = 4*TARGET_CHAR_BIT;
398   current_gdbarch->double_bit = 8*TARGET_CHAR_BIT;
399   current_gdbarch->long_double_bit = 8*TARGET_CHAR_BIT;
400   current_gdbarch->ptr_bit = current_gdbarch->int_bit;
401   current_gdbarch->char_signed = -1;
402   current_gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer;
403   current_gdbarch->num_regs = -1;
404   current_gdbarch->sp_regnum = -1;
405   current_gdbarch->pc_regnum = -1;
406   current_gdbarch->ps_regnum = -1;
407   current_gdbarch->fp0_regnum = -1;
408   current_gdbarch->stab_reg_to_regnum = no_op_reg_to_regnum;
409   current_gdbarch->ecoff_reg_to_regnum = no_op_reg_to_regnum;
410   current_gdbarch->dwarf_reg_to_regnum = no_op_reg_to_regnum;
411   current_gdbarch->sdb_reg_to_regnum = no_op_reg_to_regnum;
412   current_gdbarch->dwarf2_reg_to_regnum = no_op_reg_to_regnum;
413   current_gdbarch->deprecated_fp_regnum = -1;
414   current_gdbarch->call_dummy_location = AT_ENTRY_POINT;
415   current_gdbarch->print_registers_info = default_print_registers_info;
416   current_gdbarch->register_sim_regno = legacy_register_sim_regno;
417   current_gdbarch->cannot_fetch_register = cannot_register_not;
418   current_gdbarch->cannot_store_register = cannot_register_not;
419   current_gdbarch->convert_register_p = generic_convert_register_p;
420   current_gdbarch->value_from_register = default_value_from_register;
421   current_gdbarch->pointer_to_address = unsigned_pointer_to_address;
422   current_gdbarch->address_to_pointer = unsigned_address_to_pointer;
423   current_gdbarch->return_value = legacy_return_value;
424   current_gdbarch->deprecated_use_struct_convention = generic_use_struct_convention;
425   current_gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
426   current_gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
427   current_gdbarch->remote_register_number = default_remote_register_number;
428   current_gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
429   current_gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
430   current_gdbarch->addr_bits_remove = core_addr_identity;
431   current_gdbarch->smash_text_address = core_addr_identity;
432   current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
433   current_gdbarch->skip_solib_resolver = generic_skip_solib_resolver;
434   current_gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
435   current_gdbarch->in_function_epilogue_p = generic_in_function_epilogue_p;
436   current_gdbarch->construct_inferior_arguments = construct_inferior_arguments;
437   current_gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special;
438   current_gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
439   current_gdbarch->name_of_malloc = "malloc";
440   current_gdbarch->register_reggroup_p = default_register_reggroup_p;
441   /* gdbarch_alloc() */
442
443   return current_gdbarch;
444 }
445
446
447 /* Allocate extra space using the per-architecture obstack.  */
448
449 void *
450 gdbarch_obstack_zalloc (struct gdbarch *arch, long size)
451 {
452   void *data = obstack_alloc (arch->obstack, size);
453   memset (data, 0, size);
454   return data;
455 }
456
457
458 /* Free a gdbarch struct.  This should never happen in normal
459    operation --- once you've created a gdbarch, you keep it around.
460    However, if an architecture's init function encounters an error
461    building the structure, it may need to clean up a partially
462    constructed gdbarch.  */
463
464 void
465 gdbarch_free (struct gdbarch *arch)
466 {
467   struct obstack *obstack;
468   gdb_assert (arch != NULL);
469   gdb_assert (!arch->initialized_p);
470   obstack = arch->obstack;
471   obstack_free (obstack, 0); /* Includes the ARCH.  */
472   xfree (obstack);
473 }
474
475
476 /* Ensure that all values in a GDBARCH are reasonable.  */
477
478 /* NOTE/WARNING: The parameter is called ``current_gdbarch'' so that it
479    just happens to match the global variable ``current_gdbarch''.  That
480    way macros refering to that variable get the local and not the global
481    version - ulgh.  Once everything is parameterised with gdbarch, this
482    will go away. */
483
484 static void
485 verify_gdbarch (struct gdbarch *current_gdbarch)
486 {
487   struct ui_file *log;
488   struct cleanup *cleanups;
489   long dummy;
490   char *buf;
491   log = mem_fileopen ();
492   cleanups = make_cleanup_ui_file_delete (log);
493   /* fundamental */
494   if (current_gdbarch->byte_order == BFD_ENDIAN_UNKNOWN)
495     fprintf_unfiltered (log, "\n\tbyte-order");
496   if (current_gdbarch->bfd_arch_info == NULL)
497     fprintf_unfiltered (log, "\n\tbfd_arch_info");
498   /* Check those that need to be defined for the given multi-arch level. */
499   /* Skip verify of short_bit, invalid_p == 0 */
500   /* Skip verify of int_bit, invalid_p == 0 */
501   /* Skip verify of long_bit, invalid_p == 0 */
502   /* Skip verify of long_long_bit, invalid_p == 0 */
503   /* Skip verify of float_bit, invalid_p == 0 */
504   if (current_gdbarch->float_format == 0)
505     current_gdbarch->float_format = floatformats_ieee_single;
506   /* Skip verify of double_bit, invalid_p == 0 */
507   if (current_gdbarch->double_format == 0)
508     current_gdbarch->double_format = floatformats_ieee_double;
509   /* Skip verify of long_double_bit, invalid_p == 0 */
510   if (current_gdbarch->long_double_format == 0)
511     current_gdbarch->long_double_format = floatformats_ieee_double;
512   /* Skip verify of ptr_bit, invalid_p == 0 */
513   if (current_gdbarch->addr_bit == 0)
514     current_gdbarch->addr_bit = gdbarch_ptr_bit (current_gdbarch);
515   if (current_gdbarch->char_signed == -1)
516     current_gdbarch->char_signed = 1;
517   /* Skip verify of read_pc, has predicate */
518   /* Skip verify of write_pc, has predicate */
519   /* Skip verify of virtual_frame_pointer, invalid_p == 0 */
520   /* Skip verify of pseudo_register_read, has predicate */
521   /* Skip verify of pseudo_register_write, has predicate */
522   if (current_gdbarch->num_regs == -1)
523     fprintf_unfiltered (log, "\n\tnum_regs");
524   /* Skip verify of num_pseudo_regs, invalid_p == 0 */
525   /* Skip verify of sp_regnum, invalid_p == 0 */
526   /* Skip verify of pc_regnum, invalid_p == 0 */
527   /* Skip verify of ps_regnum, invalid_p == 0 */
528   /* Skip verify of fp0_regnum, invalid_p == 0 */
529   /* Skip verify of stab_reg_to_regnum, invalid_p == 0 */
530   /* Skip verify of ecoff_reg_to_regnum, invalid_p == 0 */
531   /* Skip verify of dwarf_reg_to_regnum, invalid_p == 0 */
532   /* Skip verify of sdb_reg_to_regnum, invalid_p == 0 */
533   /* Skip verify of dwarf2_reg_to_regnum, invalid_p == 0 */
534   /* Skip verify of register_type, has predicate */
535   /* Skip verify of unwind_dummy_id, has predicate */
536   /* Skip verify of deprecated_fp_regnum, invalid_p == 0 */
537   /* Skip verify of push_dummy_call, has predicate */
538   /* Skip verify of call_dummy_location, invalid_p == 0 */
539   /* Skip verify of push_dummy_code, has predicate */
540   /* Skip verify of print_registers_info, invalid_p == 0 */
541   /* Skip verify of print_float_info, has predicate */
542   /* Skip verify of print_vector_info, has predicate */
543   /* Skip verify of register_sim_regno, invalid_p == 0 */
544   /* Skip verify of cannot_fetch_register, invalid_p == 0 */
545   /* Skip verify of cannot_store_register, invalid_p == 0 */
546   /* Skip verify of get_longjmp_target, has predicate */
547   /* Skip verify of convert_register_p, invalid_p == 0 */
548   /* Skip verify of value_from_register, invalid_p == 0 */
549   /* Skip verify of pointer_to_address, invalid_p == 0 */
550   /* Skip verify of address_to_pointer, invalid_p == 0 */
551   /* Skip verify of integer_to_address, has predicate */
552   /* Skip verify of return_value, has predicate */
553   /* Skip verify of deprecated_use_struct_convention, invalid_p == 0 */
554   if (current_gdbarch->skip_prologue == 0)
555     fprintf_unfiltered (log, "\n\tskip_prologue");
556   if (current_gdbarch->inner_than == 0)
557     fprintf_unfiltered (log, "\n\tinner_than");
558   if (current_gdbarch->breakpoint_from_pc == 0)
559     fprintf_unfiltered (log, "\n\tbreakpoint_from_pc");
560   /* Skip verify of adjust_breakpoint_address, has predicate */
561   /* Skip verify of memory_insert_breakpoint, invalid_p == 0 */
562   /* Skip verify of memory_remove_breakpoint, invalid_p == 0 */
563   /* Skip verify of decr_pc_after_break, invalid_p == 0 */
564   /* Skip verify of deprecated_function_start_offset, invalid_p == 0 */
565   /* Skip verify of remote_register_number, invalid_p == 0 */
566   /* Skip verify of fetch_tls_load_module_address, has predicate */
567   /* Skip verify of frame_args_skip, invalid_p == 0 */
568   /* Skip verify of unwind_pc, has predicate */
569   /* Skip verify of unwind_sp, has predicate */
570   /* Skip verify of frame_num_args, has predicate */
571   /* Skip verify of frame_align, has predicate */
572   /* Skip verify of deprecated_reg_struct_has_addr, has predicate */
573   /* Skip verify of stabs_argument_has_addr, invalid_p == 0 */
574   /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */
575   /* Skip verify of addr_bits_remove, invalid_p == 0 */
576   /* Skip verify of smash_text_address, invalid_p == 0 */
577   /* Skip verify of software_single_step, has predicate */
578   /* Skip verify of single_step_through_delay, has predicate */
579   if (current_gdbarch->print_insn == 0)
580     fprintf_unfiltered (log, "\n\tprint_insn");
581   /* Skip verify of skip_trampoline_code, invalid_p == 0 */
582   /* Skip verify of skip_solib_resolver, invalid_p == 0 */
583   /* Skip verify of in_solib_return_trampoline, invalid_p == 0 */
584   /* Skip verify of in_function_epilogue_p, invalid_p == 0 */
585   /* Skip verify of construct_inferior_arguments, invalid_p == 0 */
586   /* Skip verify of elf_make_msymbol_special, invalid_p == 0 */
587   /* Skip verify of coff_make_msymbol_special, invalid_p == 0 */
588   /* Skip verify of name_of_malloc, invalid_p == 0 */
589   /* Skip verify of cannot_step_breakpoint, invalid_p == 0 */
590   /* Skip verify of have_nonsteppable_watchpoint, invalid_p == 0 */
591   /* Skip verify of address_class_type_flags, has predicate */
592   /* Skip verify of address_class_type_flags_to_name, has predicate */
593   /* Skip verify of address_class_name_to_type_flags, has predicate */
594   /* Skip verify of register_reggroup_p, invalid_p == 0 */
595   /* Skip verify of fetch_pointer_argument, has predicate */
596   /* Skip verify of regset_from_core_section, has predicate */
597   /* Skip verify of vtable_function_descriptors, invalid_p == 0 */
598   /* Skip verify of vbit_in_delta, invalid_p == 0 */
599   /* Skip verify of skip_permanent_breakpoint, has predicate */
600   /* Skip verify of overlay_update, has predicate */
601   buf = ui_file_xstrdup (log, &dummy);
602   make_cleanup (xfree, buf);
603   if (strlen (buf) > 0)
604     internal_error (__FILE__, __LINE__,
605                     _("verify_gdbarch: the following are invalid ...%s"),
606                     buf);
607   do_cleanups (cleanups);
608 }
609
610
611 /* Print out the details of the current architecture. */
612
613 /* NOTE/WARNING: The parameter is called ``current_gdbarch'' so that it
614    just happens to match the global variable ``current_gdbarch''.  That
615    way macros refering to that variable get the local and not the global
616    version - ulgh.  Once everything is parameterised with gdbarch, this
617    will go away. */
618
619 void
620 gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
621 {
622   const char *gdb_xm_file = "<not-defined>";
623   const char *gdb_nm_file = "<not-defined>";
624   const char *gdb_tm_file = "<not-defined>";
625 #if defined (GDB_XM_FILE)
626   gdb_xm_file = GDB_XM_FILE;
627 #endif
628   fprintf_unfiltered (file,
629                       "gdbarch_dump: GDB_XM_FILE = %s\n",
630                       gdb_xm_file);
631 #if defined (GDB_NM_FILE)
632   gdb_nm_file = GDB_NM_FILE;
633 #endif
634   fprintf_unfiltered (file,
635                       "gdbarch_dump: GDB_NM_FILE = %s\n",
636                       gdb_nm_file);
637 #if defined (GDB_TM_FILE)
638   gdb_tm_file = GDB_TM_FILE;
639 #endif
640   fprintf_unfiltered (file,
641                       "gdbarch_dump: GDB_TM_FILE = %s\n",
642                       gdb_tm_file);
643   fprintf_unfiltered (file,
644                       "gdbarch_dump: addr_bit = %s\n",
645                       paddr_d (current_gdbarch->addr_bit));
646   fprintf_unfiltered (file,
647                       "gdbarch_dump: addr_bits_remove = <0x%lx>\n",
648                       (long) current_gdbarch->addr_bits_remove);
649   fprintf_unfiltered (file,
650                       "gdbarch_dump: gdbarch_address_class_name_to_type_flags_p() = %d\n",
651                       gdbarch_address_class_name_to_type_flags_p (current_gdbarch));
652   fprintf_unfiltered (file,
653                       "gdbarch_dump: address_class_name_to_type_flags = <0x%lx>\n",
654                       (long) current_gdbarch->address_class_name_to_type_flags);
655   fprintf_unfiltered (file,
656                       "gdbarch_dump: gdbarch_address_class_type_flags_p() = %d\n",
657                       gdbarch_address_class_type_flags_p (current_gdbarch));
658   fprintf_unfiltered (file,
659                       "gdbarch_dump: address_class_type_flags = <0x%lx>\n",
660                       (long) current_gdbarch->address_class_type_flags);
661   fprintf_unfiltered (file,
662                       "gdbarch_dump: gdbarch_address_class_type_flags_to_name_p() = %d\n",
663                       gdbarch_address_class_type_flags_to_name_p (current_gdbarch));
664   fprintf_unfiltered (file,
665                       "gdbarch_dump: address_class_type_flags_to_name = <0x%lx>\n",
666                       (long) current_gdbarch->address_class_type_flags_to_name);
667   fprintf_unfiltered (file,
668                       "gdbarch_dump: address_to_pointer = <0x%lx>\n",
669                       (long) current_gdbarch->address_to_pointer);
670   fprintf_unfiltered (file,
671                       "gdbarch_dump: gdbarch_adjust_breakpoint_address_p() = %d\n",
672                       gdbarch_adjust_breakpoint_address_p (current_gdbarch));
673   fprintf_unfiltered (file,
674                       "gdbarch_dump: adjust_breakpoint_address = <0x%lx>\n",
675                       (long) current_gdbarch->adjust_breakpoint_address);
676   fprintf_unfiltered (file,
677                       "gdbarch_dump: believe_pcc_promotion = %s\n",
678                       paddr_d (current_gdbarch->believe_pcc_promotion));
679   fprintf_unfiltered (file,
680                       "gdbarch_dump: bfd_arch_info = %s\n",
681                       gdbarch_bfd_arch_info (current_gdbarch)->printable_name);
682   fprintf_unfiltered (file,
683                       "gdbarch_dump: breakpoint_from_pc = <0x%lx>\n",
684                       (long) current_gdbarch->breakpoint_from_pc);
685   fprintf_unfiltered (file,
686                       "gdbarch_dump: byte_order = %s\n",
687                       paddr_d (current_gdbarch->byte_order));
688   fprintf_unfiltered (file,
689                       "gdbarch_dump: call_dummy_location = %s\n",
690                       paddr_d (current_gdbarch->call_dummy_location));
691   fprintf_unfiltered (file,
692                       "gdbarch_dump: cannot_fetch_register = <0x%lx>\n",
693                       (long) current_gdbarch->cannot_fetch_register);
694   fprintf_unfiltered (file,
695                       "gdbarch_dump: cannot_step_breakpoint = %s\n",
696                       paddr_d (current_gdbarch->cannot_step_breakpoint));
697   fprintf_unfiltered (file,
698                       "gdbarch_dump: cannot_store_register = <0x%lx>\n",
699                       (long) current_gdbarch->cannot_store_register);
700   fprintf_unfiltered (file,
701                       "gdbarch_dump: char_signed = %s\n",
702                       paddr_d (current_gdbarch->char_signed));
703   fprintf_unfiltered (file,
704                       "gdbarch_dump: coff_make_msymbol_special = <0x%lx>\n",
705                       (long) current_gdbarch->coff_make_msymbol_special);
706   fprintf_unfiltered (file,
707                       "gdbarch_dump: construct_inferior_arguments = <0x%lx>\n",
708                       (long) current_gdbarch->construct_inferior_arguments);
709   fprintf_unfiltered (file,
710                       "gdbarch_dump: convert_from_func_ptr_addr = <0x%lx>\n",
711                       (long) current_gdbarch->convert_from_func_ptr_addr);
712   fprintf_unfiltered (file,
713                       "gdbarch_dump: convert_register_p = <0x%lx>\n",
714                       (long) current_gdbarch->convert_register_p);
715   fprintf_unfiltered (file,
716                       "gdbarch_dump: decr_pc_after_break = 0x%s\n",
717                       paddr_nz (current_gdbarch->decr_pc_after_break));
718   fprintf_unfiltered (file,
719                       "gdbarch_dump: deprecated_fp_regnum = %s\n",
720                       paddr_d (current_gdbarch->deprecated_fp_regnum));
721   fprintf_unfiltered (file,
722                       "gdbarch_dump: deprecated_function_start_offset = 0x%s\n",
723                       paddr_nz (current_gdbarch->deprecated_function_start_offset));
724   fprintf_unfiltered (file,
725                       "gdbarch_dump: gdbarch_deprecated_reg_struct_has_addr_p() = %d\n",
726                       gdbarch_deprecated_reg_struct_has_addr_p (current_gdbarch));
727   fprintf_unfiltered (file,
728                       "gdbarch_dump: deprecated_reg_struct_has_addr = <0x%lx>\n",
729                       (long) current_gdbarch->deprecated_reg_struct_has_addr);
730   fprintf_unfiltered (file,
731                       "gdbarch_dump: deprecated_use_struct_convention = <0x%lx>\n",
732                       (long) current_gdbarch->deprecated_use_struct_convention);
733   fprintf_unfiltered (file,
734                       "gdbarch_dump: double_bit = %s\n",
735                       paddr_d (current_gdbarch->double_bit));
736   fprintf_unfiltered (file,
737                       "gdbarch_dump: double_format = %s\n",
738                       pformat (current_gdbarch->double_format));
739   fprintf_unfiltered (file,
740                       "gdbarch_dump: dwarf2_reg_to_regnum = <0x%lx>\n",
741                       (long) current_gdbarch->dwarf2_reg_to_regnum);
742   fprintf_unfiltered (file,
743                       "gdbarch_dump: dwarf_reg_to_regnum = <0x%lx>\n",
744                       (long) current_gdbarch->dwarf_reg_to_regnum);
745   fprintf_unfiltered (file,
746                       "gdbarch_dump: ecoff_reg_to_regnum = <0x%lx>\n",
747                       (long) current_gdbarch->ecoff_reg_to_regnum);
748   fprintf_unfiltered (file,
749                       "gdbarch_dump: elf_make_msymbol_special = <0x%lx>\n",
750                       (long) current_gdbarch->elf_make_msymbol_special);
751   fprintf_unfiltered (file,
752                       "gdbarch_dump: extract_return_value = <0x%lx>\n",
753                       (long) current_gdbarch->extract_return_value);
754   fprintf_unfiltered (file,
755                       "gdbarch_dump: gdbarch_fetch_pointer_argument_p() = %d\n",
756                       gdbarch_fetch_pointer_argument_p (current_gdbarch));
757   fprintf_unfiltered (file,
758                       "gdbarch_dump: fetch_pointer_argument = <0x%lx>\n",
759                       (long) current_gdbarch->fetch_pointer_argument);
760   fprintf_unfiltered (file,
761                       "gdbarch_dump: gdbarch_fetch_tls_load_module_address_p() = %d\n",
762                       gdbarch_fetch_tls_load_module_address_p (current_gdbarch));
763   fprintf_unfiltered (file,
764                       "gdbarch_dump: fetch_tls_load_module_address = <0x%lx>\n",
765                       (long) current_gdbarch->fetch_tls_load_module_address);
766   fprintf_unfiltered (file,
767                       "gdbarch_dump: float_bit = %s\n",
768                       paddr_d (current_gdbarch->float_bit));
769   fprintf_unfiltered (file,
770                       "gdbarch_dump: float_format = %s\n",
771                       pformat (current_gdbarch->float_format));
772   fprintf_unfiltered (file,
773                       "gdbarch_dump: fp0_regnum = %s\n",
774                       paddr_d (current_gdbarch->fp0_regnum));
775   fprintf_unfiltered (file,
776                       "gdbarch_dump: gdbarch_frame_align_p() = %d\n",
777                       gdbarch_frame_align_p (current_gdbarch));
778   fprintf_unfiltered (file,
779                       "gdbarch_dump: frame_align = <0x%lx>\n",
780                       (long) current_gdbarch->frame_align);
781   fprintf_unfiltered (file,
782                       "gdbarch_dump: frame_args_skip = 0x%s\n",
783                       paddr_nz (current_gdbarch->frame_args_skip));
784   fprintf_unfiltered (file,
785                       "gdbarch_dump: gdbarch_frame_num_args_p() = %d\n",
786                       gdbarch_frame_num_args_p (current_gdbarch));
787   fprintf_unfiltered (file,
788                       "gdbarch_dump: frame_num_args = <0x%lx>\n",
789                       (long) current_gdbarch->frame_num_args);
790   fprintf_unfiltered (file,
791                       "gdbarch_dump: frame_red_zone_size = %s\n",
792                       paddr_d (current_gdbarch->frame_red_zone_size));
793   fprintf_unfiltered (file,
794                       "gdbarch_dump: gdbarch_get_longjmp_target_p() = %d\n",
795                       gdbarch_get_longjmp_target_p (current_gdbarch));
796   fprintf_unfiltered (file,
797                       "gdbarch_dump: get_longjmp_target = <0x%lx>\n",
798                       (long) current_gdbarch->get_longjmp_target);
799   fprintf_unfiltered (file,
800                       "gdbarch_dump: have_nonsteppable_watchpoint = %s\n",
801                       paddr_d (current_gdbarch->have_nonsteppable_watchpoint));
802   fprintf_unfiltered (file,
803                       "gdbarch_dump: in_function_epilogue_p = <0x%lx>\n",
804                       (long) current_gdbarch->in_function_epilogue_p);
805   fprintf_unfiltered (file,
806                       "gdbarch_dump: in_solib_return_trampoline = <0x%lx>\n",
807                       (long) current_gdbarch->in_solib_return_trampoline);
808   fprintf_unfiltered (file,
809                       "gdbarch_dump: inner_than = <0x%lx>\n",
810                       (long) current_gdbarch->inner_than);
811   fprintf_unfiltered (file,
812                       "gdbarch_dump: int_bit = %s\n",
813                       paddr_d (current_gdbarch->int_bit));
814   fprintf_unfiltered (file,
815                       "gdbarch_dump: gdbarch_integer_to_address_p() = %d\n",
816                       gdbarch_integer_to_address_p (current_gdbarch));
817   fprintf_unfiltered (file,
818                       "gdbarch_dump: integer_to_address = <0x%lx>\n",
819                       (long) current_gdbarch->integer_to_address);
820   fprintf_unfiltered (file,
821                       "gdbarch_dump: long_bit = %s\n",
822                       paddr_d (current_gdbarch->long_bit));
823   fprintf_unfiltered (file,
824                       "gdbarch_dump: long_double_bit = %s\n",
825                       paddr_d (current_gdbarch->long_double_bit));
826   fprintf_unfiltered (file,
827                       "gdbarch_dump: long_double_format = %s\n",
828                       pformat (current_gdbarch->long_double_format));
829   fprintf_unfiltered (file,
830                       "gdbarch_dump: long_long_bit = %s\n",
831                       paddr_d (current_gdbarch->long_long_bit));
832   fprintf_unfiltered (file,
833                       "gdbarch_dump: memory_insert_breakpoint = <0x%lx>\n",
834                       (long) current_gdbarch->memory_insert_breakpoint);
835   fprintf_unfiltered (file,
836                       "gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
837                       (long) current_gdbarch->memory_remove_breakpoint);
838   fprintf_unfiltered (file,
839                       "gdbarch_dump: name_of_malloc = %s\n",
840                       current_gdbarch->name_of_malloc);
841   fprintf_unfiltered (file,
842                       "gdbarch_dump: num_pseudo_regs = %s\n",
843                       paddr_d (current_gdbarch->num_pseudo_regs));
844   fprintf_unfiltered (file,
845                       "gdbarch_dump: num_regs = %s\n",
846                       paddr_d (current_gdbarch->num_regs));
847   fprintf_unfiltered (file,
848                       "gdbarch_dump: osabi = %s\n",
849                       paddr_d (current_gdbarch->osabi));
850   fprintf_unfiltered (file,
851                       "gdbarch_dump: gdbarch_overlay_update_p() = %d\n",
852                       gdbarch_overlay_update_p (current_gdbarch));
853   fprintf_unfiltered (file,
854                       "gdbarch_dump: overlay_update = <0x%lx>\n",
855                       (long) current_gdbarch->overlay_update);
856   fprintf_unfiltered (file,
857                       "gdbarch_dump: pc_regnum = %s\n",
858                       paddr_d (current_gdbarch->pc_regnum));
859   fprintf_unfiltered (file,
860                       "gdbarch_dump: pointer_to_address = <0x%lx>\n",
861                       (long) current_gdbarch->pointer_to_address);
862   fprintf_unfiltered (file,
863                       "gdbarch_dump: gdbarch_print_float_info_p() = %d\n",
864                       gdbarch_print_float_info_p (current_gdbarch));
865   fprintf_unfiltered (file,
866                       "gdbarch_dump: print_float_info = <0x%lx>\n",
867                       (long) current_gdbarch->print_float_info);
868 #ifdef TARGET_PRINT_INSN
869   fprintf_unfiltered (file,
870                       "gdbarch_dump: %s # %s\n",
871                       "TARGET_PRINT_INSN(vma, info)",
872                       XSTRING (TARGET_PRINT_INSN (vma, info)));
873 #endif
874   fprintf_unfiltered (file,
875                       "gdbarch_dump: print_insn = <0x%lx>\n",
876                       (long) current_gdbarch->print_insn);
877   fprintf_unfiltered (file,
878                       "gdbarch_dump: print_registers_info = <0x%lx>\n",
879                       (long) current_gdbarch->print_registers_info);
880   fprintf_unfiltered (file,
881                       "gdbarch_dump: gdbarch_print_vector_info_p() = %d\n",
882                       gdbarch_print_vector_info_p (current_gdbarch));
883   fprintf_unfiltered (file,
884                       "gdbarch_dump: print_vector_info = <0x%lx>\n",
885                       (long) current_gdbarch->print_vector_info);
886   fprintf_unfiltered (file,
887                       "gdbarch_dump: ps_regnum = %s\n",
888                       paddr_d (current_gdbarch->ps_regnum));
889   fprintf_unfiltered (file,
890                       "gdbarch_dump: gdbarch_pseudo_register_read_p() = %d\n",
891                       gdbarch_pseudo_register_read_p (current_gdbarch));
892   fprintf_unfiltered (file,
893                       "gdbarch_dump: pseudo_register_read = <0x%lx>\n",
894                       (long) current_gdbarch->pseudo_register_read);
895   fprintf_unfiltered (file,
896                       "gdbarch_dump: gdbarch_pseudo_register_write_p() = %d\n",
897                       gdbarch_pseudo_register_write_p (current_gdbarch));
898   fprintf_unfiltered (file,
899                       "gdbarch_dump: pseudo_register_write = <0x%lx>\n",
900                       (long) current_gdbarch->pseudo_register_write);
901   fprintf_unfiltered (file,
902                       "gdbarch_dump: ptr_bit = %s\n",
903                       paddr_d (current_gdbarch->ptr_bit));
904   fprintf_unfiltered (file,
905                       "gdbarch_dump: gdbarch_push_dummy_call_p() = %d\n",
906                       gdbarch_push_dummy_call_p (current_gdbarch));
907   fprintf_unfiltered (file,
908                       "gdbarch_dump: push_dummy_call = <0x%lx>\n",
909                       (long) current_gdbarch->push_dummy_call);
910   fprintf_unfiltered (file,
911                       "gdbarch_dump: gdbarch_push_dummy_code_p() = %d\n",
912                       gdbarch_push_dummy_code_p (current_gdbarch));
913   fprintf_unfiltered (file,
914                       "gdbarch_dump: push_dummy_code = <0x%lx>\n",
915                       (long) current_gdbarch->push_dummy_code);
916   fprintf_unfiltered (file,
917                       "gdbarch_dump: gdbarch_read_pc_p() = %d\n",
918                       gdbarch_read_pc_p (current_gdbarch));
919   fprintf_unfiltered (file,
920                       "gdbarch_dump: read_pc = <0x%lx>\n",
921                       (long) current_gdbarch->read_pc);
922   fprintf_unfiltered (file,
923                       "gdbarch_dump: register_name = <0x%lx>\n",
924                       (long) current_gdbarch->register_name);
925   fprintf_unfiltered (file,
926                       "gdbarch_dump: register_reggroup_p = <0x%lx>\n",
927                       (long) current_gdbarch->register_reggroup_p);
928   fprintf_unfiltered (file,
929                       "gdbarch_dump: register_sim_regno = <0x%lx>\n",
930                       (long) current_gdbarch->register_sim_regno);
931   fprintf_unfiltered (file,
932                       "gdbarch_dump: register_to_value = <0x%lx>\n",
933                       (long) current_gdbarch->register_to_value);
934   fprintf_unfiltered (file,
935                       "gdbarch_dump: gdbarch_register_type_p() = %d\n",
936                       gdbarch_register_type_p (current_gdbarch));
937   fprintf_unfiltered (file,
938                       "gdbarch_dump: register_type = <0x%lx>\n",
939                       (long) current_gdbarch->register_type);
940   fprintf_unfiltered (file,
941                       "gdbarch_dump: gdbarch_regset_from_core_section_p() = %d\n",
942                       gdbarch_regset_from_core_section_p (current_gdbarch));
943   fprintf_unfiltered (file,
944                       "gdbarch_dump: regset_from_core_section = <0x%lx>\n",
945                       (long) current_gdbarch->regset_from_core_section);
946   fprintf_unfiltered (file,
947                       "gdbarch_dump: remote_register_number = <0x%lx>\n",
948                       (long) current_gdbarch->remote_register_number);
949   fprintf_unfiltered (file,
950                       "gdbarch_dump: gdbarch_return_value_p() = %d\n",
951                       gdbarch_return_value_p (current_gdbarch));
952   fprintf_unfiltered (file,
953                       "gdbarch_dump: return_value = <0x%lx>\n",
954                       (long) current_gdbarch->return_value);
955   fprintf_unfiltered (file,
956                       "gdbarch_dump: sdb_reg_to_regnum = <0x%lx>\n",
957                       (long) current_gdbarch->sdb_reg_to_regnum);
958   fprintf_unfiltered (file,
959                       "gdbarch_dump: short_bit = %s\n",
960                       paddr_d (current_gdbarch->short_bit));
961   fprintf_unfiltered (file,
962                       "gdbarch_dump: gdbarch_single_step_through_delay_p() = %d\n",
963                       gdbarch_single_step_through_delay_p (current_gdbarch));
964   fprintf_unfiltered (file,
965                       "gdbarch_dump: single_step_through_delay = <0x%lx>\n",
966                       (long) current_gdbarch->single_step_through_delay);
967   fprintf_unfiltered (file,
968                       "gdbarch_dump: gdbarch_skip_permanent_breakpoint_p() = %d\n",
969                       gdbarch_skip_permanent_breakpoint_p (current_gdbarch));
970   fprintf_unfiltered (file,
971                       "gdbarch_dump: skip_permanent_breakpoint = <0x%lx>\n",
972                       (long) current_gdbarch->skip_permanent_breakpoint);
973   fprintf_unfiltered (file,
974                       "gdbarch_dump: skip_prologue = <0x%lx>\n",
975                       (long) current_gdbarch->skip_prologue);
976   fprintf_unfiltered (file,
977                       "gdbarch_dump: skip_solib_resolver = <0x%lx>\n",
978                       (long) current_gdbarch->skip_solib_resolver);
979   fprintf_unfiltered (file,
980                       "gdbarch_dump: skip_trampoline_code = <0x%lx>\n",
981                       (long) current_gdbarch->skip_trampoline_code);
982   fprintf_unfiltered (file,
983                       "gdbarch_dump: smash_text_address = <0x%lx>\n",
984                       (long) current_gdbarch->smash_text_address);
985 #ifdef SOFTWARE_SINGLE_STEP_P
986   fprintf_unfiltered (file,
987                       "gdbarch_dump: %s # %s\n",
988                       "SOFTWARE_SINGLE_STEP_P()",
989                       XSTRING (SOFTWARE_SINGLE_STEP_P ()));
990 #endif
991   fprintf_unfiltered (file,
992                       "gdbarch_dump: gdbarch_software_single_step_p() = %d\n",
993                       gdbarch_software_single_step_p (current_gdbarch));
994 #ifdef SOFTWARE_SINGLE_STEP
995   fprintf_unfiltered (file,
996                       "gdbarch_dump: %s # %s\n",
997                       "SOFTWARE_SINGLE_STEP(frame)",
998                       XSTRING (SOFTWARE_SINGLE_STEP (frame)));
999 #endif
1000   fprintf_unfiltered (file,
1001                       "gdbarch_dump: software_single_step = <0x%lx>\n",
1002                       (long) current_gdbarch->software_single_step);
1003   fprintf_unfiltered (file,
1004                       "gdbarch_dump: sp_regnum = %s\n",
1005                       paddr_d (current_gdbarch->sp_regnum));
1006   fprintf_unfiltered (file,
1007                       "gdbarch_dump: stab_reg_to_regnum = <0x%lx>\n",
1008                       (long) current_gdbarch->stab_reg_to_regnum);
1009   fprintf_unfiltered (file,
1010                       "gdbarch_dump: stabs_argument_has_addr = <0x%lx>\n",
1011                       (long) current_gdbarch->stabs_argument_has_addr);
1012   fprintf_unfiltered (file,
1013                       "gdbarch_dump: store_return_value = <0x%lx>\n",
1014                       (long) current_gdbarch->store_return_value);
1015   fprintf_unfiltered (file,
1016                       "gdbarch_dump: target_desc = %s\n",
1017                       paddr_d ((long) current_gdbarch->target_desc));
1018   fprintf_unfiltered (file,
1019                       "gdbarch_dump: gdbarch_unwind_dummy_id_p() = %d\n",
1020                       gdbarch_unwind_dummy_id_p (current_gdbarch));
1021   fprintf_unfiltered (file,
1022                       "gdbarch_dump: unwind_dummy_id = <0x%lx>\n",
1023                       (long) current_gdbarch->unwind_dummy_id);
1024   fprintf_unfiltered (file,
1025                       "gdbarch_dump: gdbarch_unwind_pc_p() = %d\n",
1026                       gdbarch_unwind_pc_p (current_gdbarch));
1027   fprintf_unfiltered (file,
1028                       "gdbarch_dump: unwind_pc = <0x%lx>\n",
1029                       (long) current_gdbarch->unwind_pc);
1030   fprintf_unfiltered (file,
1031                       "gdbarch_dump: gdbarch_unwind_sp_p() = %d\n",
1032                       gdbarch_unwind_sp_p (current_gdbarch));
1033   fprintf_unfiltered (file,
1034                       "gdbarch_dump: unwind_sp = <0x%lx>\n",
1035                       (long) current_gdbarch->unwind_sp);
1036   fprintf_unfiltered (file,
1037                       "gdbarch_dump: value_from_register = <0x%lx>\n",
1038                       (long) current_gdbarch->value_from_register);
1039   fprintf_unfiltered (file,
1040                       "gdbarch_dump: value_to_register = <0x%lx>\n",
1041                       (long) current_gdbarch->value_to_register);
1042   fprintf_unfiltered (file,
1043                       "gdbarch_dump: vbit_in_delta = %s\n",
1044                       paddr_d (current_gdbarch->vbit_in_delta));
1045   fprintf_unfiltered (file,
1046                       "gdbarch_dump: virtual_frame_pointer = <0x%lx>\n",
1047                       (long) current_gdbarch->virtual_frame_pointer);
1048   fprintf_unfiltered (file,
1049                       "gdbarch_dump: vtable_function_descriptors = %s\n",
1050                       paddr_d (current_gdbarch->vtable_function_descriptors));
1051   fprintf_unfiltered (file,
1052                       "gdbarch_dump: gdbarch_write_pc_p() = %d\n",
1053                       gdbarch_write_pc_p (current_gdbarch));
1054   fprintf_unfiltered (file,
1055                       "gdbarch_dump: write_pc = <0x%lx>\n",
1056                       (long) current_gdbarch->write_pc);
1057   if (current_gdbarch->dump_tdep != NULL)
1058     current_gdbarch->dump_tdep (current_gdbarch, file);
1059 }
1060
1061 struct gdbarch_tdep *
1062 gdbarch_tdep (struct gdbarch *gdbarch)
1063 {
1064   if (gdbarch_debug >= 2)
1065     fprintf_unfiltered (gdb_stdlog, "gdbarch_tdep called\n");
1066   return gdbarch->tdep;
1067 }
1068
1069
1070 const struct bfd_arch_info *
1071 gdbarch_bfd_arch_info (struct gdbarch *gdbarch)
1072 {
1073   gdb_assert (gdbarch != NULL);
1074   if (gdbarch_debug >= 2)
1075     fprintf_unfiltered (gdb_stdlog, "gdbarch_bfd_arch_info called\n");
1076   return gdbarch->bfd_arch_info;
1077 }
1078
1079 int
1080 gdbarch_byte_order (struct gdbarch *gdbarch)
1081 {
1082   gdb_assert (gdbarch != NULL);
1083   if (gdbarch_debug >= 2)
1084     fprintf_unfiltered (gdb_stdlog, "gdbarch_byte_order called\n");
1085   return gdbarch->byte_order;
1086 }
1087
1088 enum gdb_osabi
1089 gdbarch_osabi (struct gdbarch *gdbarch)
1090 {
1091   gdb_assert (gdbarch != NULL);
1092   if (gdbarch_debug >= 2)
1093     fprintf_unfiltered (gdb_stdlog, "gdbarch_osabi called\n");
1094   return gdbarch->osabi;
1095 }
1096
1097 const struct target_desc *
1098 gdbarch_target_desc (struct gdbarch *gdbarch)
1099 {
1100   gdb_assert (gdbarch != NULL);
1101   if (gdbarch_debug >= 2)
1102     fprintf_unfiltered (gdb_stdlog, "gdbarch_target_desc called\n");
1103   return gdbarch->target_desc;
1104 }
1105
1106 int
1107 gdbarch_short_bit (struct gdbarch *gdbarch)
1108 {
1109   gdb_assert (gdbarch != NULL);
1110   /* Skip verify of short_bit, invalid_p == 0 */
1111   if (gdbarch_debug >= 2)
1112     fprintf_unfiltered (gdb_stdlog, "gdbarch_short_bit called\n");
1113   return gdbarch->short_bit;
1114 }
1115
1116 void
1117 set_gdbarch_short_bit (struct gdbarch *gdbarch,
1118                        int short_bit)
1119 {
1120   gdbarch->short_bit = short_bit;
1121 }
1122
1123 int
1124 gdbarch_int_bit (struct gdbarch *gdbarch)
1125 {
1126   gdb_assert (gdbarch != NULL);
1127   /* Skip verify of int_bit, invalid_p == 0 */
1128   if (gdbarch_debug >= 2)
1129     fprintf_unfiltered (gdb_stdlog, "gdbarch_int_bit called\n");
1130   return gdbarch->int_bit;
1131 }
1132
1133 void
1134 set_gdbarch_int_bit (struct gdbarch *gdbarch,
1135                      int int_bit)
1136 {
1137   gdbarch->int_bit = int_bit;
1138 }
1139
1140 int
1141 gdbarch_long_bit (struct gdbarch *gdbarch)
1142 {
1143   gdb_assert (gdbarch != NULL);
1144   /* Skip verify of long_bit, invalid_p == 0 */
1145   if (gdbarch_debug >= 2)
1146     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_bit called\n");
1147   return gdbarch->long_bit;
1148 }
1149
1150 void
1151 set_gdbarch_long_bit (struct gdbarch *gdbarch,
1152                       int long_bit)
1153 {
1154   gdbarch->long_bit = long_bit;
1155 }
1156
1157 int
1158 gdbarch_long_long_bit (struct gdbarch *gdbarch)
1159 {
1160   gdb_assert (gdbarch != NULL);
1161   /* Skip verify of long_long_bit, invalid_p == 0 */
1162   if (gdbarch_debug >= 2)
1163     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_long_bit called\n");
1164   return gdbarch->long_long_bit;
1165 }
1166
1167 void
1168 set_gdbarch_long_long_bit (struct gdbarch *gdbarch,
1169                            int long_long_bit)
1170 {
1171   gdbarch->long_long_bit = long_long_bit;
1172 }
1173
1174 int
1175 gdbarch_float_bit (struct gdbarch *gdbarch)
1176 {
1177   gdb_assert (gdbarch != NULL);
1178   /* Skip verify of float_bit, invalid_p == 0 */
1179   if (gdbarch_debug >= 2)
1180     fprintf_unfiltered (gdb_stdlog, "gdbarch_float_bit called\n");
1181   return gdbarch->float_bit;
1182 }
1183
1184 void
1185 set_gdbarch_float_bit (struct gdbarch *gdbarch,
1186                        int float_bit)
1187 {
1188   gdbarch->float_bit = float_bit;
1189 }
1190
1191 const struct floatformat **
1192 gdbarch_float_format (struct gdbarch *gdbarch)
1193 {
1194   gdb_assert (gdbarch != NULL);
1195   if (gdbarch_debug >= 2)
1196     fprintf_unfiltered (gdb_stdlog, "gdbarch_float_format called\n");
1197   return gdbarch->float_format;
1198 }
1199
1200 void
1201 set_gdbarch_float_format (struct gdbarch *gdbarch,
1202                           const struct floatformat ** float_format)
1203 {
1204   gdbarch->float_format = float_format;
1205 }
1206
1207 int
1208 gdbarch_double_bit (struct gdbarch *gdbarch)
1209 {
1210   gdb_assert (gdbarch != NULL);
1211   /* Skip verify of double_bit, invalid_p == 0 */
1212   if (gdbarch_debug >= 2)
1213     fprintf_unfiltered (gdb_stdlog, "gdbarch_double_bit called\n");
1214   return gdbarch->double_bit;
1215 }
1216
1217 void
1218 set_gdbarch_double_bit (struct gdbarch *gdbarch,
1219                         int double_bit)
1220 {
1221   gdbarch->double_bit = double_bit;
1222 }
1223
1224 const struct floatformat **
1225 gdbarch_double_format (struct gdbarch *gdbarch)
1226 {
1227   gdb_assert (gdbarch != NULL);
1228   if (gdbarch_debug >= 2)
1229     fprintf_unfiltered (gdb_stdlog, "gdbarch_double_format called\n");
1230   return gdbarch->double_format;
1231 }
1232
1233 void
1234 set_gdbarch_double_format (struct gdbarch *gdbarch,
1235                            const struct floatformat ** double_format)
1236 {
1237   gdbarch->double_format = double_format;
1238 }
1239
1240 int
1241 gdbarch_long_double_bit (struct gdbarch *gdbarch)
1242 {
1243   gdb_assert (gdbarch != NULL);
1244   /* Skip verify of long_double_bit, invalid_p == 0 */
1245   if (gdbarch_debug >= 2)
1246     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_double_bit called\n");
1247   return gdbarch->long_double_bit;
1248 }
1249
1250 void
1251 set_gdbarch_long_double_bit (struct gdbarch *gdbarch,
1252                              int long_double_bit)
1253 {
1254   gdbarch->long_double_bit = long_double_bit;
1255 }
1256
1257 const struct floatformat **
1258 gdbarch_long_double_format (struct gdbarch *gdbarch)
1259 {
1260   gdb_assert (gdbarch != NULL);
1261   if (gdbarch_debug >= 2)
1262     fprintf_unfiltered (gdb_stdlog, "gdbarch_long_double_format called\n");
1263   return gdbarch->long_double_format;
1264 }
1265
1266 void
1267 set_gdbarch_long_double_format (struct gdbarch *gdbarch,
1268                                 const struct floatformat ** long_double_format)
1269 {
1270   gdbarch->long_double_format = long_double_format;
1271 }
1272
1273 int
1274 gdbarch_ptr_bit (struct gdbarch *gdbarch)
1275 {
1276   gdb_assert (gdbarch != NULL);
1277   /* Skip verify of ptr_bit, invalid_p == 0 */
1278   if (gdbarch_debug >= 2)
1279     fprintf_unfiltered (gdb_stdlog, "gdbarch_ptr_bit called\n");
1280   return gdbarch->ptr_bit;
1281 }
1282
1283 void
1284 set_gdbarch_ptr_bit (struct gdbarch *gdbarch,
1285                      int ptr_bit)
1286 {
1287   gdbarch->ptr_bit = ptr_bit;
1288 }
1289
1290 int
1291 gdbarch_addr_bit (struct gdbarch *gdbarch)
1292 {
1293   gdb_assert (gdbarch != NULL);
1294   /* Check variable changed from pre-default.  */
1295   gdb_assert (gdbarch->addr_bit != 0);
1296   if (gdbarch_debug >= 2)
1297     fprintf_unfiltered (gdb_stdlog, "gdbarch_addr_bit called\n");
1298   return gdbarch->addr_bit;
1299 }
1300
1301 void
1302 set_gdbarch_addr_bit (struct gdbarch *gdbarch,
1303                       int addr_bit)
1304 {
1305   gdbarch->addr_bit = addr_bit;
1306 }
1307
1308 int
1309 gdbarch_char_signed (struct gdbarch *gdbarch)
1310 {
1311   gdb_assert (gdbarch != NULL);
1312   /* Check variable changed from pre-default.  */
1313   gdb_assert (gdbarch->char_signed != -1);
1314   if (gdbarch_debug >= 2)
1315     fprintf_unfiltered (gdb_stdlog, "gdbarch_char_signed called\n");
1316   return gdbarch->char_signed;
1317 }
1318
1319 void
1320 set_gdbarch_char_signed (struct gdbarch *gdbarch,
1321                          int char_signed)
1322 {
1323   gdbarch->char_signed = char_signed;
1324 }
1325
1326 int
1327 gdbarch_read_pc_p (struct gdbarch *gdbarch)
1328 {
1329   gdb_assert (gdbarch != NULL);
1330   return gdbarch->read_pc != NULL;
1331 }
1332
1333 CORE_ADDR
1334 gdbarch_read_pc (struct gdbarch *gdbarch, struct regcache *regcache)
1335 {
1336   gdb_assert (gdbarch != NULL);
1337   gdb_assert (gdbarch->read_pc != NULL);
1338   if (gdbarch_debug >= 2)
1339     fprintf_unfiltered (gdb_stdlog, "gdbarch_read_pc called\n");
1340   return gdbarch->read_pc (regcache);
1341 }
1342
1343 void
1344 set_gdbarch_read_pc (struct gdbarch *gdbarch,
1345                      gdbarch_read_pc_ftype read_pc)
1346 {
1347   gdbarch->read_pc = read_pc;
1348 }
1349
1350 int
1351 gdbarch_write_pc_p (struct gdbarch *gdbarch)
1352 {
1353   gdb_assert (gdbarch != NULL);
1354   return gdbarch->write_pc != NULL;
1355 }
1356
1357 void
1358 gdbarch_write_pc (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR val)
1359 {
1360   gdb_assert (gdbarch != NULL);
1361   gdb_assert (gdbarch->write_pc != NULL);
1362   if (gdbarch_debug >= 2)
1363     fprintf_unfiltered (gdb_stdlog, "gdbarch_write_pc called\n");
1364   gdbarch->write_pc (regcache, val);
1365 }
1366
1367 void
1368 set_gdbarch_write_pc (struct gdbarch *gdbarch,
1369                       gdbarch_write_pc_ftype write_pc)
1370 {
1371   gdbarch->write_pc = write_pc;
1372 }
1373
1374 void
1375 gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset)
1376 {
1377   gdb_assert (gdbarch != NULL);
1378   gdb_assert (gdbarch->virtual_frame_pointer != NULL);
1379   if (gdbarch_debug >= 2)
1380     fprintf_unfiltered (gdb_stdlog, "gdbarch_virtual_frame_pointer called\n");
1381   gdbarch->virtual_frame_pointer (pc, frame_regnum, frame_offset);
1382 }
1383
1384 void
1385 set_gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch,
1386                                    gdbarch_virtual_frame_pointer_ftype virtual_frame_pointer)
1387 {
1388   gdbarch->virtual_frame_pointer = virtual_frame_pointer;
1389 }
1390
1391 int
1392 gdbarch_pseudo_register_read_p (struct gdbarch *gdbarch)
1393 {
1394   gdb_assert (gdbarch != NULL);
1395   return gdbarch->pseudo_register_read != NULL;
1396 }
1397
1398 void
1399 gdbarch_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, gdb_byte *buf)
1400 {
1401   gdb_assert (gdbarch != NULL);
1402   gdb_assert (gdbarch->pseudo_register_read != NULL);
1403   if (gdbarch_debug >= 2)
1404     fprintf_unfiltered (gdb_stdlog, "gdbarch_pseudo_register_read called\n");
1405   gdbarch->pseudo_register_read (gdbarch, regcache, cookednum, buf);
1406 }
1407
1408 void
1409 set_gdbarch_pseudo_register_read (struct gdbarch *gdbarch,
1410                                   gdbarch_pseudo_register_read_ftype pseudo_register_read)
1411 {
1412   gdbarch->pseudo_register_read = pseudo_register_read;
1413 }
1414
1415 int
1416 gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch)
1417 {
1418   gdb_assert (gdbarch != NULL);
1419   return gdbarch->pseudo_register_write != NULL;
1420 }
1421
1422 void
1423 gdbarch_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, const gdb_byte *buf)
1424 {
1425   gdb_assert (gdbarch != NULL);
1426   gdb_assert (gdbarch->pseudo_register_write != NULL);
1427   if (gdbarch_debug >= 2)
1428     fprintf_unfiltered (gdb_stdlog, "gdbarch_pseudo_register_write called\n");
1429   gdbarch->pseudo_register_write (gdbarch, regcache, cookednum, buf);
1430 }
1431
1432 void
1433 set_gdbarch_pseudo_register_write (struct gdbarch *gdbarch,
1434                                    gdbarch_pseudo_register_write_ftype pseudo_register_write)
1435 {
1436   gdbarch->pseudo_register_write = pseudo_register_write;
1437 }
1438
1439 int
1440 gdbarch_num_regs (struct gdbarch *gdbarch)
1441 {
1442   gdb_assert (gdbarch != NULL);
1443   /* Check variable changed from pre-default.  */
1444   gdb_assert (gdbarch->num_regs != -1);
1445   if (gdbarch_debug >= 2)
1446     fprintf_unfiltered (gdb_stdlog, "gdbarch_num_regs called\n");
1447   return gdbarch->num_regs;
1448 }
1449
1450 void
1451 set_gdbarch_num_regs (struct gdbarch *gdbarch,
1452                       int num_regs)
1453 {
1454   gdbarch->num_regs = num_regs;
1455 }
1456
1457 int
1458 gdbarch_num_pseudo_regs (struct gdbarch *gdbarch)
1459 {
1460   gdb_assert (gdbarch != NULL);
1461   /* Skip verify of num_pseudo_regs, invalid_p == 0 */
1462   if (gdbarch_debug >= 2)
1463     fprintf_unfiltered (gdb_stdlog, "gdbarch_num_pseudo_regs called\n");
1464   return gdbarch->num_pseudo_regs;
1465 }
1466
1467 void
1468 set_gdbarch_num_pseudo_regs (struct gdbarch *gdbarch,
1469                              int num_pseudo_regs)
1470 {
1471   gdbarch->num_pseudo_regs = num_pseudo_regs;
1472 }
1473
1474 int
1475 gdbarch_sp_regnum (struct gdbarch *gdbarch)
1476 {
1477   gdb_assert (gdbarch != NULL);
1478   /* Skip verify of sp_regnum, invalid_p == 0 */
1479   if (gdbarch_debug >= 2)
1480     fprintf_unfiltered (gdb_stdlog, "gdbarch_sp_regnum called\n");
1481   return gdbarch->sp_regnum;
1482 }
1483
1484 void
1485 set_gdbarch_sp_regnum (struct gdbarch *gdbarch,
1486                        int sp_regnum)
1487 {
1488   gdbarch->sp_regnum = sp_regnum;
1489 }
1490
1491 int
1492 gdbarch_pc_regnum (struct gdbarch *gdbarch)
1493 {
1494   gdb_assert (gdbarch != NULL);
1495   /* Skip verify of pc_regnum, invalid_p == 0 */
1496   if (gdbarch_debug >= 2)
1497     fprintf_unfiltered (gdb_stdlog, "gdbarch_pc_regnum called\n");
1498   return gdbarch->pc_regnum;
1499 }
1500
1501 void
1502 set_gdbarch_pc_regnum (struct gdbarch *gdbarch,
1503                        int pc_regnum)
1504 {
1505   gdbarch->pc_regnum = pc_regnum;
1506 }
1507
1508 int
1509 gdbarch_ps_regnum (struct gdbarch *gdbarch)
1510 {
1511   gdb_assert (gdbarch != NULL);
1512   /* Skip verify of ps_regnum, invalid_p == 0 */
1513   if (gdbarch_debug >= 2)
1514     fprintf_unfiltered (gdb_stdlog, "gdbarch_ps_regnum called\n");
1515   return gdbarch->ps_regnum;
1516 }
1517
1518 void
1519 set_gdbarch_ps_regnum (struct gdbarch *gdbarch,
1520                        int ps_regnum)
1521 {
1522   gdbarch->ps_regnum = ps_regnum;
1523 }
1524
1525 int
1526 gdbarch_fp0_regnum (struct gdbarch *gdbarch)
1527 {
1528   gdb_assert (gdbarch != NULL);
1529   /* Skip verify of fp0_regnum, invalid_p == 0 */
1530   if (gdbarch_debug >= 2)
1531     fprintf_unfiltered (gdb_stdlog, "gdbarch_fp0_regnum called\n");
1532   return gdbarch->fp0_regnum;
1533 }
1534
1535 void
1536 set_gdbarch_fp0_regnum (struct gdbarch *gdbarch,
1537                         int fp0_regnum)
1538 {
1539   gdbarch->fp0_regnum = fp0_regnum;
1540 }
1541
1542 int
1543 gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch, int stab_regnr)
1544 {
1545   gdb_assert (gdbarch != NULL);
1546   gdb_assert (gdbarch->stab_reg_to_regnum != NULL);
1547   if (gdbarch_debug >= 2)
1548     fprintf_unfiltered (gdb_stdlog, "gdbarch_stab_reg_to_regnum called\n");
1549   return gdbarch->stab_reg_to_regnum (stab_regnr);
1550 }
1551
1552 void
1553 set_gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch,
1554                                 gdbarch_stab_reg_to_regnum_ftype stab_reg_to_regnum)
1555 {
1556   gdbarch->stab_reg_to_regnum = stab_reg_to_regnum;
1557 }
1558
1559 int
1560 gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch, int ecoff_regnr)
1561 {
1562   gdb_assert (gdbarch != NULL);
1563   gdb_assert (gdbarch->ecoff_reg_to_regnum != NULL);
1564   if (gdbarch_debug >= 2)
1565     fprintf_unfiltered (gdb_stdlog, "gdbarch_ecoff_reg_to_regnum called\n");
1566   return gdbarch->ecoff_reg_to_regnum (ecoff_regnr);
1567 }
1568
1569 void
1570 set_gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch,
1571                                  gdbarch_ecoff_reg_to_regnum_ftype ecoff_reg_to_regnum)
1572 {
1573   gdbarch->ecoff_reg_to_regnum = ecoff_reg_to_regnum;
1574 }
1575
1576 int
1577 gdbarch_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int dwarf_regnr)
1578 {
1579   gdb_assert (gdbarch != NULL);
1580   gdb_assert (gdbarch->dwarf_reg_to_regnum != NULL);
1581   if (gdbarch_debug >= 2)
1582     fprintf_unfiltered (gdb_stdlog, "gdbarch_dwarf_reg_to_regnum called\n");
1583   return gdbarch->dwarf_reg_to_regnum (dwarf_regnr);
1584 }
1585
1586 void
1587 set_gdbarch_dwarf_reg_to_regnum (struct gdbarch *gdbarch,
1588                                  gdbarch_dwarf_reg_to_regnum_ftype dwarf_reg_to_regnum)
1589 {
1590   gdbarch->dwarf_reg_to_regnum = dwarf_reg_to_regnum;
1591 }
1592
1593 int
1594 gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch, int sdb_regnr)
1595 {
1596   gdb_assert (gdbarch != NULL);
1597   gdb_assert (gdbarch->sdb_reg_to_regnum != NULL);
1598   if (gdbarch_debug >= 2)
1599     fprintf_unfiltered (gdb_stdlog, "gdbarch_sdb_reg_to_regnum called\n");
1600   return gdbarch->sdb_reg_to_regnum (sdb_regnr);
1601 }
1602
1603 void
1604 set_gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch,
1605                                gdbarch_sdb_reg_to_regnum_ftype sdb_reg_to_regnum)
1606 {
1607   gdbarch->sdb_reg_to_regnum = sdb_reg_to_regnum;
1608 }
1609
1610 int
1611 gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int dwarf2_regnr)
1612 {
1613   gdb_assert (gdbarch != NULL);
1614   gdb_assert (gdbarch->dwarf2_reg_to_regnum != NULL);
1615   if (gdbarch_debug >= 2)
1616     fprintf_unfiltered (gdb_stdlog, "gdbarch_dwarf2_reg_to_regnum called\n");
1617   return gdbarch->dwarf2_reg_to_regnum (dwarf2_regnr);
1618 }
1619
1620 void
1621 set_gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch,
1622                                   gdbarch_dwarf2_reg_to_regnum_ftype dwarf2_reg_to_regnum)
1623 {
1624   gdbarch->dwarf2_reg_to_regnum = dwarf2_reg_to_regnum;
1625 }
1626
1627 const char *
1628 gdbarch_register_name (struct gdbarch *gdbarch, int regnr)
1629 {
1630   gdb_assert (gdbarch != NULL);
1631   gdb_assert (gdbarch->register_name != NULL);
1632   if (gdbarch_debug >= 2)
1633     fprintf_unfiltered (gdb_stdlog, "gdbarch_register_name called\n");
1634   return gdbarch->register_name (regnr);
1635 }
1636
1637 void
1638 set_gdbarch_register_name (struct gdbarch *gdbarch,
1639                            gdbarch_register_name_ftype register_name)
1640 {
1641   gdbarch->register_name = register_name;
1642 }
1643
1644 int
1645 gdbarch_register_type_p (struct gdbarch *gdbarch)
1646 {
1647   gdb_assert (gdbarch != NULL);
1648   return gdbarch->register_type != NULL;
1649 }
1650
1651 struct type *
1652 gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr)
1653 {
1654   gdb_assert (gdbarch != NULL);
1655   gdb_assert (gdbarch->register_type != NULL);
1656   if (gdbarch_debug >= 2)
1657     fprintf_unfiltered (gdb_stdlog, "gdbarch_register_type called\n");
1658   return gdbarch->register_type (gdbarch, reg_nr);
1659 }
1660
1661 void
1662 set_gdbarch_register_type (struct gdbarch *gdbarch,
1663                            gdbarch_register_type_ftype register_type)
1664 {
1665   gdbarch->register_type = register_type;
1666 }
1667
1668 int
1669 gdbarch_unwind_dummy_id_p (struct gdbarch *gdbarch)
1670 {
1671   gdb_assert (gdbarch != NULL);
1672   return gdbarch->unwind_dummy_id != NULL;
1673 }
1674
1675 struct frame_id
1676 gdbarch_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *info)
1677 {
1678   gdb_assert (gdbarch != NULL);
1679   gdb_assert (gdbarch->unwind_dummy_id != NULL);
1680   if (gdbarch_debug >= 2)
1681     fprintf_unfiltered (gdb_stdlog, "gdbarch_unwind_dummy_id called\n");
1682   return gdbarch->unwind_dummy_id (gdbarch, info);
1683 }
1684
1685 void
1686 set_gdbarch_unwind_dummy_id (struct gdbarch *gdbarch,
1687                              gdbarch_unwind_dummy_id_ftype unwind_dummy_id)
1688 {
1689   gdbarch->unwind_dummy_id = unwind_dummy_id;
1690 }
1691
1692 int
1693 gdbarch_deprecated_fp_regnum (struct gdbarch *gdbarch)
1694 {
1695   gdb_assert (gdbarch != NULL);
1696   /* Skip verify of deprecated_fp_regnum, invalid_p == 0 */
1697   if (gdbarch_debug >= 2)
1698     fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_fp_regnum called\n");
1699   return gdbarch->deprecated_fp_regnum;
1700 }
1701
1702 void
1703 set_gdbarch_deprecated_fp_regnum (struct gdbarch *gdbarch,
1704                                   int deprecated_fp_regnum)
1705 {
1706   gdbarch->deprecated_fp_regnum = deprecated_fp_regnum;
1707 }
1708
1709 int
1710 gdbarch_push_dummy_call_p (struct gdbarch *gdbarch)
1711 {
1712   gdb_assert (gdbarch != NULL);
1713   return gdbarch->push_dummy_call != NULL;
1714 }
1715
1716 CORE_ADDR
1717 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)
1718 {
1719   gdb_assert (gdbarch != NULL);
1720   gdb_assert (gdbarch->push_dummy_call != NULL);
1721   if (gdbarch_debug >= 2)
1722     fprintf_unfiltered (gdb_stdlog, "gdbarch_push_dummy_call called\n");
1723   return gdbarch->push_dummy_call (gdbarch, function, regcache, bp_addr, nargs, args, sp, struct_return, struct_addr);
1724 }
1725
1726 void
1727 set_gdbarch_push_dummy_call (struct gdbarch *gdbarch,
1728                              gdbarch_push_dummy_call_ftype push_dummy_call)
1729 {
1730   gdbarch->push_dummy_call = push_dummy_call;
1731 }
1732
1733 int
1734 gdbarch_call_dummy_location (struct gdbarch *gdbarch)
1735 {
1736   gdb_assert (gdbarch != NULL);
1737   /* Skip verify of call_dummy_location, invalid_p == 0 */
1738   if (gdbarch_debug >= 2)
1739     fprintf_unfiltered (gdb_stdlog, "gdbarch_call_dummy_location called\n");
1740   return gdbarch->call_dummy_location;
1741 }
1742
1743 void
1744 set_gdbarch_call_dummy_location (struct gdbarch *gdbarch,
1745                                  int call_dummy_location)
1746 {
1747   gdbarch->call_dummy_location = call_dummy_location;
1748 }
1749
1750 int
1751 gdbarch_push_dummy_code_p (struct gdbarch *gdbarch)
1752 {
1753   gdb_assert (gdbarch != NULL);
1754   return gdbarch->push_dummy_code != NULL;
1755 }
1756
1757 CORE_ADDR
1758 gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache)
1759 {
1760   gdb_assert (gdbarch != NULL);
1761   gdb_assert (gdbarch->push_dummy_code != NULL);
1762   if (gdbarch_debug >= 2)
1763     fprintf_unfiltered (gdb_stdlog, "gdbarch_push_dummy_code called\n");
1764   return gdbarch->push_dummy_code (gdbarch, sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr, regcache);
1765 }
1766
1767 void
1768 set_gdbarch_push_dummy_code (struct gdbarch *gdbarch,
1769                              gdbarch_push_dummy_code_ftype push_dummy_code)
1770 {
1771   gdbarch->push_dummy_code = push_dummy_code;
1772 }
1773
1774 void
1775 gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all)
1776 {
1777   gdb_assert (gdbarch != NULL);
1778   gdb_assert (gdbarch->print_registers_info != NULL);
1779   if (gdbarch_debug >= 2)
1780     fprintf_unfiltered (gdb_stdlog, "gdbarch_print_registers_info called\n");
1781   gdbarch->print_registers_info (gdbarch, file, frame, regnum, all);
1782 }
1783
1784 void
1785 set_gdbarch_print_registers_info (struct gdbarch *gdbarch,
1786                                   gdbarch_print_registers_info_ftype print_registers_info)
1787 {
1788   gdbarch->print_registers_info = print_registers_info;
1789 }
1790
1791 int
1792 gdbarch_print_float_info_p (struct gdbarch *gdbarch)
1793 {
1794   gdb_assert (gdbarch != NULL);
1795   return gdbarch->print_float_info != NULL;
1796 }
1797
1798 void
1799 gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args)
1800 {
1801   gdb_assert (gdbarch != NULL);
1802   gdb_assert (gdbarch->print_float_info != NULL);
1803   if (gdbarch_debug >= 2)
1804     fprintf_unfiltered (gdb_stdlog, "gdbarch_print_float_info called\n");
1805   gdbarch->print_float_info (gdbarch, file, frame, args);
1806 }
1807
1808 void
1809 set_gdbarch_print_float_info (struct gdbarch *gdbarch,
1810                               gdbarch_print_float_info_ftype print_float_info)
1811 {
1812   gdbarch->print_float_info = print_float_info;
1813 }
1814
1815 int
1816 gdbarch_print_vector_info_p (struct gdbarch *gdbarch)
1817 {
1818   gdb_assert (gdbarch != NULL);
1819   return gdbarch->print_vector_info != NULL;
1820 }
1821
1822 void
1823 gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args)
1824 {
1825   gdb_assert (gdbarch != NULL);
1826   gdb_assert (gdbarch->print_vector_info != NULL);
1827   if (gdbarch_debug >= 2)
1828     fprintf_unfiltered (gdb_stdlog, "gdbarch_print_vector_info called\n");
1829   gdbarch->print_vector_info (gdbarch, file, frame, args);
1830 }
1831
1832 void
1833 set_gdbarch_print_vector_info (struct gdbarch *gdbarch,
1834                                gdbarch_print_vector_info_ftype print_vector_info)
1835 {
1836   gdbarch->print_vector_info = print_vector_info;
1837 }
1838
1839 int
1840 gdbarch_register_sim_regno (struct gdbarch *gdbarch, int reg_nr)
1841 {
1842   gdb_assert (gdbarch != NULL);
1843   gdb_assert (gdbarch->register_sim_regno != NULL);
1844   if (gdbarch_debug >= 2)
1845     fprintf_unfiltered (gdb_stdlog, "gdbarch_register_sim_regno called\n");
1846   return gdbarch->register_sim_regno (reg_nr);
1847 }
1848
1849 void
1850 set_gdbarch_register_sim_regno (struct gdbarch *gdbarch,
1851                                 gdbarch_register_sim_regno_ftype register_sim_regno)
1852 {
1853   gdbarch->register_sim_regno = register_sim_regno;
1854 }
1855
1856 int
1857 gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
1858 {
1859   gdb_assert (gdbarch != NULL);
1860   gdb_assert (gdbarch->cannot_fetch_register != NULL);
1861   if (gdbarch_debug >= 2)
1862     fprintf_unfiltered (gdb_stdlog, "gdbarch_cannot_fetch_register called\n");
1863   return gdbarch->cannot_fetch_register (regnum);
1864 }
1865
1866 void
1867 set_gdbarch_cannot_fetch_register (struct gdbarch *gdbarch,
1868                                    gdbarch_cannot_fetch_register_ftype cannot_fetch_register)
1869 {
1870   gdbarch->cannot_fetch_register = cannot_fetch_register;
1871 }
1872
1873 int
1874 gdbarch_cannot_store_register (struct gdbarch *gdbarch, int regnum)
1875 {
1876   gdb_assert (gdbarch != NULL);
1877   gdb_assert (gdbarch->cannot_store_register != NULL);
1878   if (gdbarch_debug >= 2)
1879     fprintf_unfiltered (gdb_stdlog, "gdbarch_cannot_store_register called\n");
1880   return gdbarch->cannot_store_register (regnum);
1881 }
1882
1883 void
1884 set_gdbarch_cannot_store_register (struct gdbarch *gdbarch,
1885                                    gdbarch_cannot_store_register_ftype cannot_store_register)
1886 {
1887   gdbarch->cannot_store_register = cannot_store_register;
1888 }
1889
1890 int
1891 gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch)
1892 {
1893   gdb_assert (gdbarch != NULL);
1894   return gdbarch->get_longjmp_target != NULL;
1895 }
1896
1897 int
1898 gdbarch_get_longjmp_target (struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR *pc)
1899 {
1900   gdb_assert (gdbarch != NULL);
1901   gdb_assert (gdbarch->get_longjmp_target != NULL);
1902   if (gdbarch_debug >= 2)
1903     fprintf_unfiltered (gdb_stdlog, "gdbarch_get_longjmp_target called\n");
1904   return gdbarch->get_longjmp_target (frame, pc);
1905 }
1906
1907 void
1908 set_gdbarch_get_longjmp_target (struct gdbarch *gdbarch,
1909                                 gdbarch_get_longjmp_target_ftype get_longjmp_target)
1910 {
1911   gdbarch->get_longjmp_target = get_longjmp_target;
1912 }
1913
1914 int
1915 gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch)
1916 {
1917   gdb_assert (gdbarch != NULL);
1918   if (gdbarch_debug >= 2)
1919     fprintf_unfiltered (gdb_stdlog, "gdbarch_believe_pcc_promotion called\n");
1920   return gdbarch->believe_pcc_promotion;
1921 }
1922
1923 void
1924 set_gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch,
1925                                    int believe_pcc_promotion)
1926 {
1927   gdbarch->believe_pcc_promotion = believe_pcc_promotion;
1928 }
1929
1930 int
1931 gdbarch_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type)
1932 {
1933   gdb_assert (gdbarch != NULL);
1934   gdb_assert (gdbarch->convert_register_p != NULL);
1935   if (gdbarch_debug >= 2)
1936     fprintf_unfiltered (gdb_stdlog, "gdbarch_convert_register_p called\n");
1937   return gdbarch->convert_register_p (regnum, type);
1938 }
1939
1940 void
1941 set_gdbarch_convert_register_p (struct gdbarch *gdbarch,
1942                                 gdbarch_convert_register_p_ftype convert_register_p)
1943 {
1944   gdbarch->convert_register_p = convert_register_p;
1945 }
1946
1947 void
1948 gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, gdb_byte *buf)
1949 {
1950   gdb_assert (gdbarch != NULL);
1951   gdb_assert (gdbarch->register_to_value != NULL);
1952   if (gdbarch_debug >= 2)
1953     fprintf_unfiltered (gdb_stdlog, "gdbarch_register_to_value called\n");
1954   gdbarch->register_to_value (frame, regnum, type, buf);
1955 }
1956
1957 void
1958 set_gdbarch_register_to_value (struct gdbarch *gdbarch,
1959                                gdbarch_register_to_value_ftype register_to_value)
1960 {
1961   gdbarch->register_to_value = register_to_value;
1962 }
1963
1964 void
1965 gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, const gdb_byte *buf)
1966 {
1967   gdb_assert (gdbarch != NULL);
1968   gdb_assert (gdbarch->value_to_register != NULL);
1969   if (gdbarch_debug >= 2)
1970     fprintf_unfiltered (gdb_stdlog, "gdbarch_value_to_register called\n");
1971   gdbarch->value_to_register (frame, regnum, type, buf);
1972 }
1973
1974 void
1975 set_gdbarch_value_to_register (struct gdbarch *gdbarch,
1976                                gdbarch_value_to_register_ftype value_to_register)
1977 {
1978   gdbarch->value_to_register = value_to_register;
1979 }
1980
1981 struct value *
1982 gdbarch_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_info *frame)
1983 {
1984   gdb_assert (gdbarch != NULL);
1985   gdb_assert (gdbarch->value_from_register != NULL);
1986   if (gdbarch_debug >= 2)
1987     fprintf_unfiltered (gdb_stdlog, "gdbarch_value_from_register called\n");
1988   return gdbarch->value_from_register (type, regnum, frame);
1989 }
1990
1991 void
1992 set_gdbarch_value_from_register (struct gdbarch *gdbarch,
1993                                  gdbarch_value_from_register_ftype value_from_register)
1994 {
1995   gdbarch->value_from_register = value_from_register;
1996 }
1997
1998 CORE_ADDR
1999 gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
2000 {
2001   gdb_assert (gdbarch != NULL);
2002   gdb_assert (gdbarch->pointer_to_address != NULL);
2003   if (gdbarch_debug >= 2)
2004     fprintf_unfiltered (gdb_stdlog, "gdbarch_pointer_to_address called\n");
2005   return gdbarch->pointer_to_address (type, buf);
2006 }
2007
2008 void
2009 set_gdbarch_pointer_to_address (struct gdbarch *gdbarch,
2010                                 gdbarch_pointer_to_address_ftype pointer_to_address)
2011 {
2012   gdbarch->pointer_to_address = pointer_to_address;
2013 }
2014
2015 void
2016 gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr)
2017 {
2018   gdb_assert (gdbarch != NULL);
2019   gdb_assert (gdbarch->address_to_pointer != NULL);
2020   if (gdbarch_debug >= 2)
2021     fprintf_unfiltered (gdb_stdlog, "gdbarch_address_to_pointer called\n");
2022   gdbarch->address_to_pointer (type, buf, addr);
2023 }
2024
2025 void
2026 set_gdbarch_address_to_pointer (struct gdbarch *gdbarch,
2027                                 gdbarch_address_to_pointer_ftype address_to_pointer)
2028 {
2029   gdbarch->address_to_pointer = address_to_pointer;
2030 }
2031
2032 int
2033 gdbarch_integer_to_address_p (struct gdbarch *gdbarch)
2034 {
2035   gdb_assert (gdbarch != NULL);
2036   return gdbarch->integer_to_address != NULL;
2037 }
2038
2039 CORE_ADDR
2040 gdbarch_integer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
2041 {
2042   gdb_assert (gdbarch != NULL);
2043   gdb_assert (gdbarch->integer_to_address != NULL);
2044   if (gdbarch_debug >= 2)
2045     fprintf_unfiltered (gdb_stdlog, "gdbarch_integer_to_address called\n");
2046   return gdbarch->integer_to_address (gdbarch, type, buf);
2047 }
2048
2049 void
2050 set_gdbarch_integer_to_address (struct gdbarch *gdbarch,
2051                                 gdbarch_integer_to_address_ftype integer_to_address)
2052 {
2053   gdbarch->integer_to_address = integer_to_address;
2054 }
2055
2056 int
2057 gdbarch_return_value_p (struct gdbarch *gdbarch)
2058 {
2059   gdb_assert (gdbarch != NULL);
2060   return gdbarch->return_value != legacy_return_value;
2061 }
2062
2063 enum return_value_convention
2064 gdbarch_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
2065 {
2066   gdb_assert (gdbarch != NULL);
2067   gdb_assert (gdbarch->return_value != NULL);
2068   /* Do not check predicate: gdbarch->return_value != legacy_return_value, allow call.  */
2069   if (gdbarch_debug >= 2)
2070     fprintf_unfiltered (gdb_stdlog, "gdbarch_return_value called\n");
2071   return gdbarch->return_value (gdbarch, valtype, regcache, readbuf, writebuf);
2072 }
2073
2074 void
2075 set_gdbarch_return_value (struct gdbarch *gdbarch,
2076                           gdbarch_return_value_ftype return_value)
2077 {
2078   gdbarch->return_value = return_value;
2079 }
2080
2081 void
2082 gdbarch_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, gdb_byte *valbuf)
2083 {
2084   gdb_assert (gdbarch != NULL);
2085   gdb_assert (gdbarch->extract_return_value != NULL);
2086   if (gdbarch_debug >= 2)
2087     fprintf_unfiltered (gdb_stdlog, "gdbarch_extract_return_value called\n");
2088   gdbarch->extract_return_value (type, regcache, valbuf);
2089 }
2090
2091 void
2092 set_gdbarch_extract_return_value (struct gdbarch *gdbarch,
2093                                   gdbarch_extract_return_value_ftype extract_return_value)
2094 {
2095   gdbarch->extract_return_value = extract_return_value;
2096 }
2097
2098 void
2099 gdbarch_store_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
2100 {
2101   gdb_assert (gdbarch != NULL);
2102   gdb_assert (gdbarch->store_return_value != NULL);
2103   if (gdbarch_debug >= 2)
2104     fprintf_unfiltered (gdb_stdlog, "gdbarch_store_return_value called\n");
2105   gdbarch->store_return_value (type, regcache, valbuf);
2106 }
2107
2108 void
2109 set_gdbarch_store_return_value (struct gdbarch *gdbarch,
2110                                 gdbarch_store_return_value_ftype store_return_value)
2111 {
2112   gdbarch->store_return_value = store_return_value;
2113 }
2114
2115 int
2116 gdbarch_deprecated_use_struct_convention (struct gdbarch *gdbarch, int gcc_p, struct type *value_type)
2117 {
2118   gdb_assert (gdbarch != NULL);
2119   gdb_assert (gdbarch->deprecated_use_struct_convention != NULL);
2120   if (gdbarch_debug >= 2)
2121     fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_use_struct_convention called\n");
2122   return gdbarch->deprecated_use_struct_convention (gcc_p, value_type);
2123 }
2124
2125 void
2126 set_gdbarch_deprecated_use_struct_convention (struct gdbarch *gdbarch,
2127                                               gdbarch_deprecated_use_struct_convention_ftype deprecated_use_struct_convention)
2128 {
2129   gdbarch->deprecated_use_struct_convention = deprecated_use_struct_convention;
2130 }
2131
2132 CORE_ADDR
2133 gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip)
2134 {
2135   gdb_assert (gdbarch != NULL);
2136   gdb_assert (gdbarch->skip_prologue != NULL);
2137   if (gdbarch_debug >= 2)
2138     fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_prologue called\n");
2139   return gdbarch->skip_prologue (ip);
2140 }
2141
2142 void
2143 set_gdbarch_skip_prologue (struct gdbarch *gdbarch,
2144                            gdbarch_skip_prologue_ftype skip_prologue)
2145 {
2146   gdbarch->skip_prologue = skip_prologue;
2147 }
2148
2149 int
2150 gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs)
2151 {
2152   gdb_assert (gdbarch != NULL);
2153   gdb_assert (gdbarch->inner_than != NULL);
2154   if (gdbarch_debug >= 2)
2155     fprintf_unfiltered (gdb_stdlog, "gdbarch_inner_than called\n");
2156   return gdbarch->inner_than (lhs, rhs);
2157 }
2158
2159 void
2160 set_gdbarch_inner_than (struct gdbarch *gdbarch,
2161                         gdbarch_inner_than_ftype inner_than)
2162 {
2163   gdbarch->inner_than = inner_than;
2164 }
2165
2166 const gdb_byte *
2167 gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
2168 {
2169   gdb_assert (gdbarch != NULL);
2170   gdb_assert (gdbarch->breakpoint_from_pc != NULL);
2171   if (gdbarch_debug >= 2)
2172     fprintf_unfiltered (gdb_stdlog, "gdbarch_breakpoint_from_pc called\n");
2173   return gdbarch->breakpoint_from_pc (pcptr, lenptr);
2174 }
2175
2176 void
2177 set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch,
2178                                 gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
2179 {
2180   gdbarch->breakpoint_from_pc = breakpoint_from_pc;
2181 }
2182
2183 int
2184 gdbarch_adjust_breakpoint_address_p (struct gdbarch *gdbarch)
2185 {
2186   gdb_assert (gdbarch != NULL);
2187   return gdbarch->adjust_breakpoint_address != NULL;
2188 }
2189
2190 CORE_ADDR
2191 gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
2192 {
2193   gdb_assert (gdbarch != NULL);
2194   gdb_assert (gdbarch->adjust_breakpoint_address != NULL);
2195   if (gdbarch_debug >= 2)
2196     fprintf_unfiltered (gdb_stdlog, "gdbarch_adjust_breakpoint_address called\n");
2197   return gdbarch->adjust_breakpoint_address (gdbarch, bpaddr);
2198 }
2199
2200 void
2201 set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch,
2202                                        gdbarch_adjust_breakpoint_address_ftype adjust_breakpoint_address)
2203 {
2204   gdbarch->adjust_breakpoint_address = adjust_breakpoint_address;
2205 }
2206
2207 int
2208 gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
2209 {
2210   gdb_assert (gdbarch != NULL);
2211   gdb_assert (gdbarch->memory_insert_breakpoint != NULL);
2212   if (gdbarch_debug >= 2)
2213     fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_insert_breakpoint called\n");
2214   return gdbarch->memory_insert_breakpoint (bp_tgt);
2215 }
2216
2217 void
2218 set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch,
2219                                       gdbarch_memory_insert_breakpoint_ftype memory_insert_breakpoint)
2220 {
2221   gdbarch->memory_insert_breakpoint = memory_insert_breakpoint;
2222 }
2223
2224 int
2225 gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
2226 {
2227   gdb_assert (gdbarch != NULL);
2228   gdb_assert (gdbarch->memory_remove_breakpoint != NULL);
2229   if (gdbarch_debug >= 2)
2230     fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_remove_breakpoint called\n");
2231   return gdbarch->memory_remove_breakpoint (bp_tgt);
2232 }
2233
2234 void
2235 set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch,
2236                                       gdbarch_memory_remove_breakpoint_ftype memory_remove_breakpoint)
2237 {
2238   gdbarch->memory_remove_breakpoint = memory_remove_breakpoint;
2239 }
2240
2241 CORE_ADDR
2242 gdbarch_decr_pc_after_break (struct gdbarch *gdbarch)
2243 {
2244   gdb_assert (gdbarch != NULL);
2245   /* Skip verify of decr_pc_after_break, invalid_p == 0 */
2246   if (gdbarch_debug >= 2)
2247     fprintf_unfiltered (gdb_stdlog, "gdbarch_decr_pc_after_break called\n");
2248   return gdbarch->decr_pc_after_break;
2249 }
2250
2251 void
2252 set_gdbarch_decr_pc_after_break (struct gdbarch *gdbarch,
2253                                  CORE_ADDR decr_pc_after_break)
2254 {
2255   gdbarch->decr_pc_after_break = decr_pc_after_break;
2256 }
2257
2258 CORE_ADDR
2259 gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch)
2260 {
2261   gdb_assert (gdbarch != NULL);
2262   /* Skip verify of deprecated_function_start_offset, invalid_p == 0 */
2263   if (gdbarch_debug >= 2)
2264     fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_function_start_offset called\n");
2265   return gdbarch->deprecated_function_start_offset;
2266 }
2267
2268 void
2269 set_gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch,
2270                                               CORE_ADDR deprecated_function_start_offset)
2271 {
2272   gdbarch->deprecated_function_start_offset = deprecated_function_start_offset;
2273 }
2274
2275 int
2276 gdbarch_remote_register_number (struct gdbarch *gdbarch, int regno)
2277 {
2278   gdb_assert (gdbarch != NULL);
2279   gdb_assert (gdbarch->remote_register_number != NULL);
2280   if (gdbarch_debug >= 2)
2281     fprintf_unfiltered (gdb_stdlog, "gdbarch_remote_register_number called\n");
2282   return gdbarch->remote_register_number (gdbarch, regno);
2283 }
2284
2285 void
2286 set_gdbarch_remote_register_number (struct gdbarch *gdbarch,
2287                                     gdbarch_remote_register_number_ftype remote_register_number)
2288 {
2289   gdbarch->remote_register_number = remote_register_number;
2290 }
2291
2292 int
2293 gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch)
2294 {
2295   gdb_assert (gdbarch != NULL);
2296   return gdbarch->fetch_tls_load_module_address != NULL;
2297 }
2298
2299 CORE_ADDR
2300 gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, struct objfile *objfile)
2301 {
2302   gdb_assert (gdbarch != NULL);
2303   gdb_assert (gdbarch->fetch_tls_load_module_address != NULL);
2304   if (gdbarch_debug >= 2)
2305     fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_tls_load_module_address called\n");
2306   return gdbarch->fetch_tls_load_module_address (objfile);
2307 }
2308
2309 void
2310 set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch,
2311                                            gdbarch_fetch_tls_load_module_address_ftype fetch_tls_load_module_address)
2312 {
2313   gdbarch->fetch_tls_load_module_address = fetch_tls_load_module_address;
2314 }
2315
2316 CORE_ADDR
2317 gdbarch_frame_args_skip (struct gdbarch *gdbarch)
2318 {
2319   gdb_assert (gdbarch != NULL);
2320   /* Skip verify of frame_args_skip, invalid_p == 0 */
2321   if (gdbarch_debug >= 2)
2322     fprintf_unfiltered (gdb_stdlog, "gdbarch_frame_args_skip called\n");
2323   return gdbarch->frame_args_skip;
2324 }
2325
2326 void
2327 set_gdbarch_frame_args_skip (struct gdbarch *gdbarch,
2328                              CORE_ADDR frame_args_skip)
2329 {
2330   gdbarch->frame_args_skip = frame_args_skip;
2331 }
2332
2333 int
2334 gdbarch_unwind_pc_p (struct gdbarch *gdbarch)
2335 {
2336   gdb_assert (gdbarch != NULL);
2337   return gdbarch->unwind_pc != NULL;
2338 }
2339
2340 CORE_ADDR
2341 gdbarch_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
2342 {
2343   gdb_assert (gdbarch != NULL);
2344   gdb_assert (gdbarch->unwind_pc != NULL);
2345   if (gdbarch_debug >= 2)
2346     fprintf_unfiltered (gdb_stdlog, "gdbarch_unwind_pc called\n");
2347   return gdbarch->unwind_pc (gdbarch, next_frame);
2348 }
2349
2350 void
2351 set_gdbarch_unwind_pc (struct gdbarch *gdbarch,
2352                        gdbarch_unwind_pc_ftype unwind_pc)
2353 {
2354   gdbarch->unwind_pc = unwind_pc;
2355 }
2356
2357 int
2358 gdbarch_unwind_sp_p (struct gdbarch *gdbarch)
2359 {
2360   gdb_assert (gdbarch != NULL);
2361   return gdbarch->unwind_sp != NULL;
2362 }
2363
2364 CORE_ADDR
2365 gdbarch_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
2366 {
2367   gdb_assert (gdbarch != NULL);
2368   gdb_assert (gdbarch->unwind_sp != NULL);
2369   if (gdbarch_debug >= 2)
2370     fprintf_unfiltered (gdb_stdlog, "gdbarch_unwind_sp called\n");
2371   return gdbarch->unwind_sp (gdbarch, next_frame);
2372 }
2373
2374 void
2375 set_gdbarch_unwind_sp (struct gdbarch *gdbarch,
2376                        gdbarch_unwind_sp_ftype unwind_sp)
2377 {
2378   gdbarch->unwind_sp = unwind_sp;
2379 }
2380
2381 int
2382 gdbarch_frame_num_args_p (struct gdbarch *gdbarch)
2383 {
2384   gdb_assert (gdbarch != NULL);
2385   return gdbarch->frame_num_args != NULL;
2386 }
2387
2388 int
2389 gdbarch_frame_num_args (struct gdbarch *gdbarch, struct frame_info *frame)
2390 {
2391   gdb_assert (gdbarch != NULL);
2392   gdb_assert (gdbarch->frame_num_args != NULL);
2393   if (gdbarch_debug >= 2)
2394     fprintf_unfiltered (gdb_stdlog, "gdbarch_frame_num_args called\n");
2395   return gdbarch->frame_num_args (frame);
2396 }
2397
2398 void
2399 set_gdbarch_frame_num_args (struct gdbarch *gdbarch,
2400                             gdbarch_frame_num_args_ftype frame_num_args)
2401 {
2402   gdbarch->frame_num_args = frame_num_args;
2403 }
2404
2405 int
2406 gdbarch_frame_align_p (struct gdbarch *gdbarch)
2407 {
2408   gdb_assert (gdbarch != NULL);
2409   return gdbarch->frame_align != NULL;
2410 }
2411
2412 CORE_ADDR
2413 gdbarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR address)
2414 {
2415   gdb_assert (gdbarch != NULL);
2416   gdb_assert (gdbarch->frame_align != NULL);
2417   if (gdbarch_debug >= 2)
2418     fprintf_unfiltered (gdb_stdlog, "gdbarch_frame_align called\n");
2419   return gdbarch->frame_align (gdbarch, address);
2420 }
2421
2422 void
2423 set_gdbarch_frame_align (struct gdbarch *gdbarch,
2424                          gdbarch_frame_align_ftype frame_align)
2425 {
2426   gdbarch->frame_align = frame_align;
2427 }
2428
2429 int
2430 gdbarch_deprecated_reg_struct_has_addr_p (struct gdbarch *gdbarch)
2431 {
2432   gdb_assert (gdbarch != NULL);
2433   return gdbarch->deprecated_reg_struct_has_addr != NULL;
2434 }
2435
2436 int
2437 gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch, int gcc_p, struct type *type)
2438 {
2439   gdb_assert (gdbarch != NULL);
2440   gdb_assert (gdbarch->deprecated_reg_struct_has_addr != NULL);
2441   if (gdbarch_debug >= 2)
2442     fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_reg_struct_has_addr called\n");
2443   return gdbarch->deprecated_reg_struct_has_addr (gcc_p, type);
2444 }
2445
2446 void
2447 set_gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch,
2448                                             gdbarch_deprecated_reg_struct_has_addr_ftype deprecated_reg_struct_has_addr)
2449 {
2450   gdbarch->deprecated_reg_struct_has_addr = deprecated_reg_struct_has_addr;
2451 }
2452
2453 int
2454 gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
2455 {
2456   gdb_assert (gdbarch != NULL);
2457   gdb_assert (gdbarch->stabs_argument_has_addr != NULL);
2458   if (gdbarch_debug >= 2)
2459     fprintf_unfiltered (gdb_stdlog, "gdbarch_stabs_argument_has_addr called\n");
2460   return gdbarch->stabs_argument_has_addr (gdbarch, type);
2461 }
2462
2463 void
2464 set_gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch,
2465                                      gdbarch_stabs_argument_has_addr_ftype stabs_argument_has_addr)
2466 {
2467   gdbarch->stabs_argument_has_addr = stabs_argument_has_addr;
2468 }
2469
2470 int
2471 gdbarch_frame_red_zone_size (struct gdbarch *gdbarch)
2472 {
2473   gdb_assert (gdbarch != NULL);
2474   if (gdbarch_debug >= 2)
2475     fprintf_unfiltered (gdb_stdlog, "gdbarch_frame_red_zone_size called\n");
2476   return gdbarch->frame_red_zone_size;
2477 }
2478
2479 void
2480 set_gdbarch_frame_red_zone_size (struct gdbarch *gdbarch,
2481                                  int frame_red_zone_size)
2482 {
2483   gdbarch->frame_red_zone_size = frame_red_zone_size;
2484 }
2485
2486 CORE_ADDR
2487 gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
2488 {
2489   gdb_assert (gdbarch != NULL);
2490   gdb_assert (gdbarch->convert_from_func_ptr_addr != NULL);
2491   if (gdbarch_debug >= 2)
2492     fprintf_unfiltered (gdb_stdlog, "gdbarch_convert_from_func_ptr_addr called\n");
2493   return gdbarch->convert_from_func_ptr_addr (gdbarch, addr, targ);
2494 }
2495
2496 void
2497 set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
2498                                         gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr)
2499 {
2500   gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr;
2501 }
2502
2503 CORE_ADDR
2504 gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
2505 {
2506   gdb_assert (gdbarch != NULL);
2507   gdb_assert (gdbarch->addr_bits_remove != NULL);
2508   if (gdbarch_debug >= 2)
2509     fprintf_unfiltered (gdb_stdlog, "gdbarch_addr_bits_remove called\n");
2510   return gdbarch->addr_bits_remove (addr);
2511 }
2512
2513 void
2514 set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch,
2515                               gdbarch_addr_bits_remove_ftype addr_bits_remove)
2516 {
2517   gdbarch->addr_bits_remove = addr_bits_remove;
2518 }
2519
2520 CORE_ADDR
2521 gdbarch_smash_text_address (struct gdbarch *gdbarch, CORE_ADDR addr)
2522 {
2523   gdb_assert (gdbarch != NULL);
2524   gdb_assert (gdbarch->smash_text_address != NULL);
2525   if (gdbarch_debug >= 2)
2526     fprintf_unfiltered (gdb_stdlog, "gdbarch_smash_text_address called\n");
2527   return gdbarch->smash_text_address (addr);
2528 }
2529
2530 void
2531 set_gdbarch_smash_text_address (struct gdbarch *gdbarch,
2532                                 gdbarch_smash_text_address_ftype smash_text_address)
2533 {
2534   gdbarch->smash_text_address = smash_text_address;
2535 }
2536
2537 int
2538 gdbarch_software_single_step_p (struct gdbarch *gdbarch)
2539 {
2540   gdb_assert (gdbarch != NULL);
2541   return gdbarch->software_single_step != NULL;
2542 }
2543
2544 int
2545 gdbarch_software_single_step (struct gdbarch *gdbarch, struct frame_info *frame)
2546 {
2547   gdb_assert (gdbarch != NULL);
2548   gdb_assert (gdbarch->software_single_step != NULL);
2549   if (gdbarch_debug >= 2)
2550     fprintf_unfiltered (gdb_stdlog, "gdbarch_software_single_step called\n");
2551   return gdbarch->software_single_step (frame);
2552 }
2553
2554 void
2555 set_gdbarch_software_single_step (struct gdbarch *gdbarch,
2556                                   gdbarch_software_single_step_ftype software_single_step)
2557 {
2558   gdbarch->software_single_step = software_single_step;
2559 }
2560
2561 int
2562 gdbarch_single_step_through_delay_p (struct gdbarch *gdbarch)
2563 {
2564   gdb_assert (gdbarch != NULL);
2565   return gdbarch->single_step_through_delay != NULL;
2566 }
2567
2568 int
2569 gdbarch_single_step_through_delay (struct gdbarch *gdbarch, struct frame_info *frame)
2570 {
2571   gdb_assert (gdbarch != NULL);
2572   gdb_assert (gdbarch->single_step_through_delay != NULL);
2573   if (gdbarch_debug >= 2)
2574     fprintf_unfiltered (gdb_stdlog, "gdbarch_single_step_through_delay called\n");
2575   return gdbarch->single_step_through_delay (gdbarch, frame);
2576 }
2577
2578 void
2579 set_gdbarch_single_step_through_delay (struct gdbarch *gdbarch,
2580                                        gdbarch_single_step_through_delay_ftype single_step_through_delay)
2581 {
2582   gdbarch->single_step_through_delay = single_step_through_delay;
2583 }
2584
2585 int
2586 gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, struct disassemble_info *info)
2587 {
2588   gdb_assert (gdbarch != NULL);
2589   gdb_assert (gdbarch->print_insn != NULL);
2590   if (gdbarch_debug >= 2)
2591     fprintf_unfiltered (gdb_stdlog, "gdbarch_print_insn called\n");
2592   return gdbarch->print_insn (vma, info);
2593 }
2594
2595 void
2596 set_gdbarch_print_insn (struct gdbarch *gdbarch,
2597                         gdbarch_print_insn_ftype print_insn)
2598 {
2599   gdbarch->print_insn = print_insn;
2600 }
2601
2602 CORE_ADDR
2603 gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR pc)
2604 {
2605   gdb_assert (gdbarch != NULL);
2606   gdb_assert (gdbarch->skip_trampoline_code != NULL);
2607   if (gdbarch_debug >= 2)
2608     fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_trampoline_code called\n");
2609   return gdbarch->skip_trampoline_code (frame, pc);
2610 }
2611
2612 void
2613 set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch,
2614                                   gdbarch_skip_trampoline_code_ftype skip_trampoline_code)
2615 {
2616   gdbarch->skip_trampoline_code = skip_trampoline_code;
2617 }
2618
2619 CORE_ADDR
2620 gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
2621 {
2622   gdb_assert (gdbarch != NULL);
2623   gdb_assert (gdbarch->skip_solib_resolver != NULL);
2624   if (gdbarch_debug >= 2)
2625     fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_solib_resolver called\n");
2626   return gdbarch->skip_solib_resolver (gdbarch, pc);
2627 }
2628
2629 void
2630 set_gdbarch_skip_solib_resolver (struct gdbarch *gdbarch,
2631                                  gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
2632 {
2633   gdbarch->skip_solib_resolver = skip_solib_resolver;
2634 }
2635
2636 int
2637 gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char *name)
2638 {
2639   gdb_assert (gdbarch != NULL);
2640   gdb_assert (gdbarch->in_solib_return_trampoline != NULL);
2641   if (gdbarch_debug >= 2)
2642     fprintf_unfiltered (gdb_stdlog, "gdbarch_in_solib_return_trampoline called\n");
2643   return gdbarch->in_solib_return_trampoline (pc, name);
2644 }
2645
2646 void
2647 set_gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch,
2648                                         gdbarch_in_solib_return_trampoline_ftype in_solib_return_trampoline)
2649 {
2650   gdbarch->in_solib_return_trampoline = in_solib_return_trampoline;
2651 }
2652
2653 int
2654 gdbarch_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR addr)
2655 {
2656   gdb_assert (gdbarch != NULL);
2657   gdb_assert (gdbarch->in_function_epilogue_p != NULL);
2658   if (gdbarch_debug >= 2)
2659     fprintf_unfiltered (gdb_stdlog, "gdbarch_in_function_epilogue_p called\n");
2660   return gdbarch->in_function_epilogue_p (gdbarch, addr);
2661 }
2662
2663 void
2664 set_gdbarch_in_function_epilogue_p (struct gdbarch *gdbarch,
2665                                     gdbarch_in_function_epilogue_p_ftype in_function_epilogue_p)
2666 {
2667   gdbarch->in_function_epilogue_p = in_function_epilogue_p;
2668 }
2669
2670 char *
2671 gdbarch_construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
2672 {
2673   gdb_assert (gdbarch != NULL);
2674   gdb_assert (gdbarch->construct_inferior_arguments != NULL);
2675   if (gdbarch_debug >= 2)
2676     fprintf_unfiltered (gdb_stdlog, "gdbarch_construct_inferior_arguments called\n");
2677   return gdbarch->construct_inferior_arguments (gdbarch, argc, argv);
2678 }
2679
2680 void
2681 set_gdbarch_construct_inferior_arguments (struct gdbarch *gdbarch,
2682                                           gdbarch_construct_inferior_arguments_ftype construct_inferior_arguments)
2683 {
2684   gdbarch->construct_inferior_arguments = construct_inferior_arguments;
2685 }
2686
2687 void
2688 gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym)
2689 {
2690   gdb_assert (gdbarch != NULL);
2691   gdb_assert (gdbarch->elf_make_msymbol_special != NULL);
2692   if (gdbarch_debug >= 2)
2693     fprintf_unfiltered (gdb_stdlog, "gdbarch_elf_make_msymbol_special called\n");
2694   gdbarch->elf_make_msymbol_special (sym, msym);
2695 }
2696
2697 void
2698 set_gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch,
2699                                       gdbarch_elf_make_msymbol_special_ftype elf_make_msymbol_special)
2700 {
2701   gdbarch->elf_make_msymbol_special = elf_make_msymbol_special;
2702 }
2703
2704 void
2705 gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, int val, struct minimal_symbol *msym)
2706 {
2707   gdb_assert (gdbarch != NULL);
2708   gdb_assert (gdbarch->coff_make_msymbol_special != NULL);
2709   if (gdbarch_debug >= 2)
2710     fprintf_unfiltered (gdb_stdlog, "gdbarch_coff_make_msymbol_special called\n");
2711   gdbarch->coff_make_msymbol_special (val, msym);
2712 }
2713
2714 void
2715 set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch,
2716                                        gdbarch_coff_make_msymbol_special_ftype coff_make_msymbol_special)
2717 {
2718   gdbarch->coff_make_msymbol_special = coff_make_msymbol_special;
2719 }
2720
2721 const char *
2722 gdbarch_name_of_malloc (struct gdbarch *gdbarch)
2723 {
2724   gdb_assert (gdbarch != NULL);
2725   /* Skip verify of name_of_malloc, invalid_p == 0 */
2726   if (gdbarch_debug >= 2)
2727     fprintf_unfiltered (gdb_stdlog, "gdbarch_name_of_malloc called\n");
2728   return gdbarch->name_of_malloc;
2729 }
2730
2731 void
2732 set_gdbarch_name_of_malloc (struct gdbarch *gdbarch,
2733                             const char * name_of_malloc)
2734 {
2735   gdbarch->name_of_malloc = name_of_malloc;
2736 }
2737
2738 int
2739 gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch)
2740 {
2741   gdb_assert (gdbarch != NULL);
2742   /* Skip verify of cannot_step_breakpoint, invalid_p == 0 */
2743   if (gdbarch_debug >= 2)
2744     fprintf_unfiltered (gdb_stdlog, "gdbarch_cannot_step_breakpoint called\n");
2745   return gdbarch->cannot_step_breakpoint;
2746 }
2747
2748 void
2749 set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch,
2750                                     int cannot_step_breakpoint)
2751 {
2752   gdbarch->cannot_step_breakpoint = cannot_step_breakpoint;
2753 }
2754
2755 int
2756 gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch)
2757 {
2758   gdb_assert (gdbarch != NULL);
2759   /* Skip verify of have_nonsteppable_watchpoint, invalid_p == 0 */
2760   if (gdbarch_debug >= 2)
2761     fprintf_unfiltered (gdb_stdlog, "gdbarch_have_nonsteppable_watchpoint called\n");
2762   return gdbarch->have_nonsteppable_watchpoint;
2763 }
2764
2765 void
2766 set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch,
2767                                           int have_nonsteppable_watchpoint)
2768 {
2769   gdbarch->have_nonsteppable_watchpoint = have_nonsteppable_watchpoint;
2770 }
2771
2772 int
2773 gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch)
2774 {
2775   gdb_assert (gdbarch != NULL);
2776   return gdbarch->address_class_type_flags != NULL;
2777 }
2778
2779 int
2780 gdbarch_address_class_type_flags (struct gdbarch *gdbarch, int byte_size, int dwarf2_addr_class)
2781 {
2782   gdb_assert (gdbarch != NULL);
2783   gdb_assert (gdbarch->address_class_type_flags != NULL);
2784   if (gdbarch_debug >= 2)
2785     fprintf_unfiltered (gdb_stdlog, "gdbarch_address_class_type_flags called\n");
2786   return gdbarch->address_class_type_flags (byte_size, dwarf2_addr_class);
2787 }
2788
2789 void
2790 set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch,
2791                                       gdbarch_address_class_type_flags_ftype address_class_type_flags)
2792 {
2793   gdbarch->address_class_type_flags = address_class_type_flags;
2794 }
2795
2796 int
2797 gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch)
2798 {
2799   gdb_assert (gdbarch != NULL);
2800   return gdbarch->address_class_type_flags_to_name != NULL;
2801 }
2802
2803 const char *
2804 gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
2805 {
2806   gdb_assert (gdbarch != NULL);
2807   gdb_assert (gdbarch->address_class_type_flags_to_name != NULL);
2808   if (gdbarch_debug >= 2)
2809     fprintf_unfiltered (gdb_stdlog, "gdbarch_address_class_type_flags_to_name called\n");
2810   return gdbarch->address_class_type_flags_to_name (gdbarch, type_flags);
2811 }
2812
2813 void
2814 set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch,
2815                                               gdbarch_address_class_type_flags_to_name_ftype address_class_type_flags_to_name)
2816 {
2817   gdbarch->address_class_type_flags_to_name = address_class_type_flags_to_name;
2818 }
2819
2820 int
2821 gdbarch_address_class_name_to_type_flags_p (struct gdbarch *gdbarch)
2822 {
2823   gdb_assert (gdbarch != NULL);
2824   return gdbarch->address_class_name_to_type_flags != NULL;
2825 }
2826
2827 int
2828 gdbarch_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char *name, int *type_flags_ptr)
2829 {
2830   gdb_assert (gdbarch != NULL);
2831   gdb_assert (gdbarch->address_class_name_to_type_flags != NULL);
2832   if (gdbarch_debug >= 2)
2833     fprintf_unfiltered (gdb_stdlog, "gdbarch_address_class_name_to_type_flags called\n");
2834   return gdbarch->address_class_name_to_type_flags (gdbarch, name, type_flags_ptr);
2835 }
2836
2837 void
2838 set_gdbarch_address_class_name_to_type_flags (struct gdbarch *gdbarch,
2839                                               gdbarch_address_class_name_to_type_flags_ftype address_class_name_to_type_flags)
2840 {
2841   gdbarch->address_class_name_to_type_flags = address_class_name_to_type_flags;
2842 }
2843
2844 int
2845 gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup)
2846 {
2847   gdb_assert (gdbarch != NULL);
2848   gdb_assert (gdbarch->register_reggroup_p != NULL);
2849   if (gdbarch_debug >= 2)
2850     fprintf_unfiltered (gdb_stdlog, "gdbarch_register_reggroup_p called\n");
2851   return gdbarch->register_reggroup_p (gdbarch, regnum, reggroup);
2852 }
2853
2854 void
2855 set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch,
2856                                  gdbarch_register_reggroup_p_ftype register_reggroup_p)
2857 {
2858   gdbarch->register_reggroup_p = register_reggroup_p;
2859 }
2860
2861 int
2862 gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch)
2863 {
2864   gdb_assert (gdbarch != NULL);
2865   return gdbarch->fetch_pointer_argument != NULL;
2866 }
2867
2868 CORE_ADDR
2869 gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type)
2870 {
2871   gdb_assert (gdbarch != NULL);
2872   gdb_assert (gdbarch->fetch_pointer_argument != NULL);
2873   if (gdbarch_debug >= 2)
2874     fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_pointer_argument called\n");
2875   return gdbarch->fetch_pointer_argument (frame, argi, type);
2876 }
2877
2878 void
2879 set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch,
2880                                     gdbarch_fetch_pointer_argument_ftype fetch_pointer_argument)
2881 {
2882   gdbarch->fetch_pointer_argument = fetch_pointer_argument;
2883 }
2884
2885 int
2886 gdbarch_regset_from_core_section_p (struct gdbarch *gdbarch)
2887 {
2888   gdb_assert (gdbarch != NULL);
2889   return gdbarch->regset_from_core_section != NULL;
2890 }
2891
2892 const struct regset *
2893 gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size)
2894 {
2895   gdb_assert (gdbarch != NULL);
2896   gdb_assert (gdbarch->regset_from_core_section != NULL);
2897   if (gdbarch_debug >= 2)
2898     fprintf_unfiltered (gdb_stdlog, "gdbarch_regset_from_core_section called\n");
2899   return gdbarch->regset_from_core_section (gdbarch, sect_name, sect_size);
2900 }
2901
2902 void
2903 set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch,
2904                                       gdbarch_regset_from_core_section_ftype regset_from_core_section)
2905 {
2906   gdbarch->regset_from_core_section = regset_from_core_section;
2907 }
2908
2909 int
2910 gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch)
2911 {
2912   gdb_assert (gdbarch != NULL);
2913   /* Skip verify of vtable_function_descriptors, invalid_p == 0 */
2914   if (gdbarch_debug >= 2)
2915     fprintf_unfiltered (gdb_stdlog, "gdbarch_vtable_function_descriptors called\n");
2916   return gdbarch->vtable_function_descriptors;
2917 }
2918
2919 void
2920 set_gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch,
2921                                          int vtable_function_descriptors)
2922 {
2923   gdbarch->vtable_function_descriptors = vtable_function_descriptors;
2924 }
2925
2926 int
2927 gdbarch_vbit_in_delta (struct gdbarch *gdbarch)
2928 {
2929   gdb_assert (gdbarch != NULL);
2930   /* Skip verify of vbit_in_delta, invalid_p == 0 */
2931   if (gdbarch_debug >= 2)
2932     fprintf_unfiltered (gdb_stdlog, "gdbarch_vbit_in_delta called\n");
2933   return gdbarch->vbit_in_delta;
2934 }
2935
2936 void
2937 set_gdbarch_vbit_in_delta (struct gdbarch *gdbarch,
2938                            int vbit_in_delta)
2939 {
2940   gdbarch->vbit_in_delta = vbit_in_delta;
2941 }
2942
2943 int
2944 gdbarch_skip_permanent_breakpoint_p (struct gdbarch *gdbarch)
2945 {
2946   gdb_assert (gdbarch != NULL);
2947   return gdbarch->skip_permanent_breakpoint != NULL;
2948 }
2949
2950 void
2951 gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache)
2952 {
2953   gdb_assert (gdbarch != NULL);
2954   gdb_assert (gdbarch->skip_permanent_breakpoint != NULL);
2955   if (gdbarch_debug >= 2)
2956     fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_permanent_breakpoint called\n");
2957   gdbarch->skip_permanent_breakpoint (regcache);
2958 }
2959
2960 void
2961 set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch,
2962                                        gdbarch_skip_permanent_breakpoint_ftype skip_permanent_breakpoint)
2963 {
2964   gdbarch->skip_permanent_breakpoint = skip_permanent_breakpoint;
2965 }
2966
2967 int
2968 gdbarch_overlay_update_p (struct gdbarch *gdbarch)
2969 {
2970   gdb_assert (gdbarch != NULL);
2971   return gdbarch->overlay_update != NULL;
2972 }
2973
2974 void
2975 gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect)
2976 {
2977   gdb_assert (gdbarch != NULL);
2978   gdb_assert (gdbarch->overlay_update != NULL);
2979   if (gdbarch_debug >= 2)
2980     fprintf_unfiltered (gdb_stdlog, "gdbarch_overlay_update called\n");
2981   gdbarch->overlay_update (osect);
2982 }
2983
2984 void
2985 set_gdbarch_overlay_update (struct gdbarch *gdbarch,
2986                             gdbarch_overlay_update_ftype overlay_update)
2987 {
2988   gdbarch->overlay_update = overlay_update;
2989 }
2990
2991
2992 /* Keep a registry of per-architecture data-pointers required by GDB
2993    modules. */
2994
2995 struct gdbarch_data
2996 {
2997   unsigned index;
2998   int init_p;
2999   gdbarch_data_pre_init_ftype *pre_init;
3000   gdbarch_data_post_init_ftype *post_init;
3001 };
3002
3003 struct gdbarch_data_registration
3004 {
3005   struct gdbarch_data *data;
3006   struct gdbarch_data_registration *next;
3007 };
3008
3009 struct gdbarch_data_registry
3010 {
3011   unsigned nr;
3012   struct gdbarch_data_registration *registrations;
3013 };
3014
3015 struct gdbarch_data_registry gdbarch_data_registry =
3016 {
3017   0, NULL,
3018 };
3019
3020 static struct gdbarch_data *
3021 gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
3022                        gdbarch_data_post_init_ftype *post_init)
3023 {
3024   struct gdbarch_data_registration **curr;
3025   /* Append the new registraration.  */
3026   for (curr = &gdbarch_data_registry.registrations;
3027        (*curr) != NULL;
3028        curr = &(*curr)->next);
3029   (*curr) = XMALLOC (struct gdbarch_data_registration);
3030   (*curr)->next = NULL;
3031   (*curr)->data = XMALLOC (struct gdbarch_data);
3032   (*curr)->data->index = gdbarch_data_registry.nr++;
3033   (*curr)->data->pre_init = pre_init;
3034   (*curr)->data->post_init = post_init;
3035   (*curr)->data->init_p = 1;
3036   return (*curr)->data;
3037 }
3038
3039 struct gdbarch_data *
3040 gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
3041 {
3042   return gdbarch_data_register (pre_init, NULL);
3043 }
3044
3045 struct gdbarch_data *
3046 gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
3047 {
3048   return gdbarch_data_register (NULL, post_init);
3049 }
3050
3051 /* Create/delete the gdbarch data vector. */
3052
3053 static void
3054 alloc_gdbarch_data (struct gdbarch *gdbarch)
3055 {
3056   gdb_assert (gdbarch->data == NULL);
3057   gdbarch->nr_data = gdbarch_data_registry.nr;
3058   gdbarch->data = GDBARCH_OBSTACK_CALLOC (gdbarch, gdbarch->nr_data, void *);
3059 }
3060
3061 /* Initialize the current value of the specified per-architecture
3062    data-pointer. */
3063
3064 void
3065 deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
3066                              struct gdbarch_data *data,
3067                              void *pointer)
3068 {
3069   gdb_assert (data->index < gdbarch->nr_data);
3070   gdb_assert (gdbarch->data[data->index] == NULL);
3071   gdb_assert (data->pre_init == NULL);
3072   gdbarch->data[data->index] = pointer;
3073 }
3074
3075 /* Return the current value of the specified per-architecture
3076    data-pointer. */
3077
3078 void *
3079 gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
3080 {
3081   gdb_assert (data->index < gdbarch->nr_data);
3082   if (gdbarch->data[data->index] == NULL)
3083     {
3084       /* The data-pointer isn't initialized, call init() to get a
3085          value.  */
3086       if (data->pre_init != NULL)
3087         /* Mid architecture creation: pass just the obstack, and not
3088            the entire architecture, as that way it isn't possible for
3089            pre-init code to refer to undefined architecture
3090            fields.  */
3091         gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
3092       else if (gdbarch->initialized_p
3093                && data->post_init != NULL)
3094         /* Post architecture creation: pass the entire architecture
3095            (as all fields are valid), but be careful to also detect
3096            recursive references.  */
3097         {
3098           gdb_assert (data->init_p);
3099           data->init_p = 0;
3100           gdbarch->data[data->index] = data->post_init (gdbarch);
3101           data->init_p = 1;
3102         }
3103       else
3104         /* The architecture initialization hasn't completed - punt -
3105          hope that the caller knows what they are doing.  Once
3106          deprecated_set_gdbarch_data has been initialized, this can be
3107          changed to an internal error.  */
3108         return NULL;
3109       gdb_assert (gdbarch->data[data->index] != NULL);
3110     }
3111   return gdbarch->data[data->index];
3112 }
3113
3114
3115
3116 /* Keep a registry of swapped data required by GDB modules. */
3117
3118 struct gdbarch_swap
3119 {
3120   void *swap;
3121   struct gdbarch_swap_registration *source;
3122   struct gdbarch_swap *next;
3123 };
3124
3125 struct gdbarch_swap_registration
3126 {
3127   void *data;
3128   unsigned long sizeof_data;
3129   gdbarch_swap_ftype *init;
3130   struct gdbarch_swap_registration *next;
3131 };
3132
3133 struct gdbarch_swap_registry
3134 {
3135   int nr;
3136   struct gdbarch_swap_registration *registrations;
3137 };
3138
3139 struct gdbarch_swap_registry gdbarch_swap_registry = 
3140 {
3141   0, NULL,
3142 };
3143
3144 void
3145 deprecated_register_gdbarch_swap (void *data,
3146                                   unsigned long sizeof_data,
3147                                   gdbarch_swap_ftype *init)
3148 {
3149   struct gdbarch_swap_registration **rego;
3150   for (rego = &gdbarch_swap_registry.registrations;
3151        (*rego) != NULL;
3152        rego = &(*rego)->next);
3153   (*rego) = XMALLOC (struct gdbarch_swap_registration);
3154   (*rego)->next = NULL;
3155   (*rego)->init = init;
3156   (*rego)->data = data;
3157   (*rego)->sizeof_data = sizeof_data;
3158 }
3159
3160 static void
3161 current_gdbarch_swap_init_hack (void)
3162 {
3163   struct gdbarch_swap_registration *rego;
3164   struct gdbarch_swap **curr = &current_gdbarch->swap;
3165   for (rego = gdbarch_swap_registry.registrations;
3166        rego != NULL;
3167        rego = rego->next)
3168     {
3169       if (rego->data != NULL)
3170         {
3171           (*curr) = GDBARCH_OBSTACK_ZALLOC (current_gdbarch,
3172                                             struct gdbarch_swap);
3173           (*curr)->source = rego;
3174           (*curr)->swap = gdbarch_obstack_zalloc (current_gdbarch,
3175                                                   rego->sizeof_data);
3176           (*curr)->next = NULL;
3177           curr = &(*curr)->next;
3178         }
3179       if (rego->init != NULL)
3180         rego->init ();
3181     }
3182 }
3183
3184 static struct gdbarch *
3185 current_gdbarch_swap_out_hack (void)
3186 {
3187   struct gdbarch *old_gdbarch = current_gdbarch;
3188   struct gdbarch_swap *curr;
3189
3190   gdb_assert (old_gdbarch != NULL);
3191   for (curr = old_gdbarch->swap;
3192        curr != NULL;
3193        curr = curr->next)
3194     {
3195       memcpy (curr->swap, curr->source->data, curr->source->sizeof_data);
3196       memset (curr->source->data, 0, curr->source->sizeof_data);
3197     }
3198   current_gdbarch = NULL;
3199   return old_gdbarch;
3200 }
3201
3202 static void
3203 current_gdbarch_swap_in_hack (struct gdbarch *new_gdbarch)
3204 {
3205   struct gdbarch_swap *curr;
3206
3207   gdb_assert (current_gdbarch == NULL);
3208   for (curr = new_gdbarch->swap;
3209        curr != NULL;
3210        curr = curr->next)
3211     memcpy (curr->source->data, curr->swap, curr->source->sizeof_data);
3212   current_gdbarch = new_gdbarch;
3213 }
3214
3215
3216 /* Keep a registry of the architectures known by GDB. */
3217
3218 struct gdbarch_registration
3219 {
3220   enum bfd_architecture bfd_architecture;
3221   gdbarch_init_ftype *init;
3222   gdbarch_dump_tdep_ftype *dump_tdep;
3223   struct gdbarch_list *arches;
3224   struct gdbarch_registration *next;
3225 };
3226
3227 static struct gdbarch_registration *gdbarch_registry = NULL;
3228
3229 static void
3230 append_name (const char ***buf, int *nr, const char *name)
3231 {
3232   *buf = xrealloc (*buf, sizeof (char**) * (*nr + 1));
3233   (*buf)[*nr] = name;
3234   *nr += 1;
3235 }
3236
3237 const char **
3238 gdbarch_printable_names (void)
3239 {
3240   /* Accumulate a list of names based on the registed list of
3241      architectures. */
3242   enum bfd_architecture a;
3243   int nr_arches = 0;
3244   const char **arches = NULL;
3245   struct gdbarch_registration *rego;
3246   for (rego = gdbarch_registry;
3247        rego != NULL;
3248        rego = rego->next)
3249     {
3250       const struct bfd_arch_info *ap;
3251       ap = bfd_lookup_arch (rego->bfd_architecture, 0);
3252       if (ap == NULL)
3253         internal_error (__FILE__, __LINE__,
3254                         _("gdbarch_architecture_names: multi-arch unknown"));
3255       do
3256         {
3257           append_name (&arches, &nr_arches, ap->printable_name);
3258           ap = ap->next;
3259         }
3260       while (ap != NULL);
3261     }
3262   append_name (&arches, &nr_arches, NULL);
3263   return arches;
3264 }
3265
3266
3267 void
3268 gdbarch_register (enum bfd_architecture bfd_architecture,
3269                   gdbarch_init_ftype *init,
3270                   gdbarch_dump_tdep_ftype *dump_tdep)
3271 {
3272   struct gdbarch_registration **curr;
3273   const struct bfd_arch_info *bfd_arch_info;
3274   /* Check that BFD recognizes this architecture */
3275   bfd_arch_info = bfd_lookup_arch (bfd_architecture, 0);
3276   if (bfd_arch_info == NULL)
3277     {
3278       internal_error (__FILE__, __LINE__,
3279                       _("gdbarch: Attempt to register unknown architecture (%d)"),
3280                       bfd_architecture);
3281     }
3282   /* Check that we haven't seen this architecture before */
3283   for (curr = &gdbarch_registry;
3284        (*curr) != NULL;
3285        curr = &(*curr)->next)
3286     {
3287       if (bfd_architecture == (*curr)->bfd_architecture)
3288         internal_error (__FILE__, __LINE__,
3289                         _("gdbarch: Duplicate registraration of architecture (%s)"),
3290                         bfd_arch_info->printable_name);
3291     }
3292   /* log it */
3293   if (gdbarch_debug)
3294     fprintf_unfiltered (gdb_stdlog, "register_gdbarch_init (%s, 0x%08lx)\n",
3295                         bfd_arch_info->printable_name,
3296                         (long) init);
3297   /* Append it */
3298   (*curr) = XMALLOC (struct gdbarch_registration);
3299   (*curr)->bfd_architecture = bfd_architecture;
3300   (*curr)->init = init;
3301   (*curr)->dump_tdep = dump_tdep;
3302   (*curr)->arches = NULL;
3303   (*curr)->next = NULL;
3304 }
3305
3306 void
3307 register_gdbarch_init (enum bfd_architecture bfd_architecture,
3308                        gdbarch_init_ftype *init)
3309 {
3310   gdbarch_register (bfd_architecture, init, NULL);
3311 }
3312
3313
3314 /* Look for an architecture using gdbarch_info.  */
3315
3316 struct gdbarch_list *
3317 gdbarch_list_lookup_by_info (struct gdbarch_list *arches,
3318                              const struct gdbarch_info *info)
3319 {
3320   for (; arches != NULL; arches = arches->next)
3321     {
3322       if (info->bfd_arch_info != arches->gdbarch->bfd_arch_info)
3323         continue;
3324       if (info->byte_order != arches->gdbarch->byte_order)
3325         continue;
3326       if (info->osabi != arches->gdbarch->osabi)
3327         continue;
3328       if (info->target_desc != arches->gdbarch->target_desc)
3329         continue;
3330       return arches;
3331     }
3332   return NULL;
3333 }
3334
3335
3336 /* Find an architecture that matches the specified INFO.  Create a new
3337    architecture if needed.  Return that new architecture.  Assumes
3338    that there is no current architecture.  */
3339
3340 static struct gdbarch *
3341 find_arch_by_info (struct gdbarch_info info)
3342 {
3343   struct gdbarch *new_gdbarch;
3344   struct gdbarch_registration *rego;
3345
3346   /* The existing architecture has been swapped out - all this code
3347      works from a clean slate.  */
3348   gdb_assert (current_gdbarch == NULL);
3349
3350   /* Fill in missing parts of the INFO struct using a number of
3351      sources: "set ..."; INFOabfd supplied; and the global
3352      defaults.  */
3353   gdbarch_info_fill (&info);
3354
3355   /* Must have found some sort of architecture. */
3356   gdb_assert (info.bfd_arch_info != NULL);
3357
3358   if (gdbarch_debug)
3359     {
3360       fprintf_unfiltered (gdb_stdlog,
3361                           "find_arch_by_info: info.bfd_arch_info %s\n",
3362                           (info.bfd_arch_info != NULL
3363                            ? info.bfd_arch_info->printable_name
3364                            : "(null)"));
3365       fprintf_unfiltered (gdb_stdlog,
3366                           "find_arch_by_info: info.byte_order %d (%s)\n",
3367                           info.byte_order,
3368                           (info.byte_order == BFD_ENDIAN_BIG ? "big"
3369                            : info.byte_order == BFD_ENDIAN_LITTLE ? "little"
3370                            : "default"));
3371       fprintf_unfiltered (gdb_stdlog,
3372                           "find_arch_by_info: info.osabi %d (%s)\n",
3373                           info.osabi, gdbarch_osabi_name (info.osabi));
3374       fprintf_unfiltered (gdb_stdlog,
3375                           "find_arch_by_info: info.abfd 0x%lx\n",
3376                           (long) info.abfd);
3377       fprintf_unfiltered (gdb_stdlog,
3378                           "find_arch_by_info: info.tdep_info 0x%lx\n",
3379                           (long) info.tdep_info);
3380     }
3381
3382   /* Find the tdep code that knows about this architecture.  */
3383   for (rego = gdbarch_registry;
3384        rego != NULL;
3385        rego = rego->next)
3386     if (rego->bfd_architecture == info.bfd_arch_info->arch)
3387       break;
3388   if (rego == NULL)
3389     {
3390       if (gdbarch_debug)
3391         fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: "
3392                             "No matching architecture\n");
3393       return 0;
3394     }
3395
3396   /* Ask the tdep code for an architecture that matches "info".  */
3397   new_gdbarch = rego->init (info, rego->arches);
3398
3399   /* Did the tdep code like it?  No.  Reject the change and revert to
3400      the old architecture.  */
3401   if (new_gdbarch == NULL)
3402     {
3403       if (gdbarch_debug)
3404         fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: "
3405                             "Target rejected architecture\n");
3406       return NULL;
3407     }
3408
3409   /* Is this a pre-existing architecture (as determined by already
3410      being initialized)?  Move it to the front of the architecture
3411      list (keeping the list sorted Most Recently Used).  */
3412   if (new_gdbarch->initialized_p)
3413     {
3414       struct gdbarch_list **list;
3415       struct gdbarch_list *this;
3416       if (gdbarch_debug)
3417         fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: "
3418                             "Previous architecture 0x%08lx (%s) selected\n",
3419                             (long) new_gdbarch,
3420                             new_gdbarch->bfd_arch_info->printable_name);
3421       /* Find the existing arch in the list.  */
3422       for (list = &rego->arches;
3423            (*list) != NULL && (*list)->gdbarch != new_gdbarch;
3424            list = &(*list)->next);
3425       /* It had better be in the list of architectures.  */
3426       gdb_assert ((*list) != NULL && (*list)->gdbarch == new_gdbarch);
3427       /* Unlink THIS.  */
3428       this = (*list);
3429       (*list) = this->next;
3430       /* Insert THIS at the front.  */
3431       this->next = rego->arches;
3432       rego->arches = this;
3433       /* Return it.  */
3434       return new_gdbarch;
3435     }
3436
3437   /* It's a new architecture.  */
3438   if (gdbarch_debug)
3439     fprintf_unfiltered (gdb_stdlog, "find_arch_by_info: "
3440                         "New architecture 0x%08lx (%s) selected\n",
3441                         (long) new_gdbarch,
3442                         new_gdbarch->bfd_arch_info->printable_name);
3443   
3444   /* Insert the new architecture into the front of the architecture
3445      list (keep the list sorted Most Recently Used).  */
3446   {
3447     struct gdbarch_list *this = XMALLOC (struct gdbarch_list);
3448     this->next = rego->arches;
3449     this->gdbarch = new_gdbarch;
3450     rego->arches = this;
3451   }    
3452
3453   /* Check that the newly installed architecture is valid.  Plug in
3454      any post init values.  */
3455   new_gdbarch->dump_tdep = rego->dump_tdep;
3456   verify_gdbarch (new_gdbarch);
3457   new_gdbarch->initialized_p = 1;
3458
3459   /* Initialize any per-architecture swap areas.  This phase requires
3460      a valid global CURRENT_GDBARCH.  Set it momentarially, and then
3461      swap the entire architecture out.  */
3462   current_gdbarch = new_gdbarch;
3463   current_gdbarch_swap_init_hack ();
3464   current_gdbarch_swap_out_hack ();
3465
3466   if (gdbarch_debug)
3467     gdbarch_dump (new_gdbarch, gdb_stdlog);
3468
3469   return new_gdbarch;
3470 }
3471
3472 struct gdbarch *
3473 gdbarch_find_by_info (struct gdbarch_info info)
3474 {
3475   /* Save the previously selected architecture, setting the global to
3476      NULL.  This stops things like gdbarch->init() trying to use the
3477      previous architecture's configuration.  The previous architecture
3478      may not even be of the same architecture family.  The most recent
3479      architecture of the same family is found at the head of the
3480      rego->arches list.  */
3481   struct gdbarch *old_gdbarch = current_gdbarch_swap_out_hack ();
3482
3483   /* Find the specified architecture.  */
3484   struct gdbarch *new_gdbarch = find_arch_by_info (info);
3485
3486   /* Restore the existing architecture.  */
3487   gdb_assert (current_gdbarch == NULL);
3488   current_gdbarch_swap_in_hack (old_gdbarch);
3489
3490   return new_gdbarch;
3491 }
3492
3493 /* Make the specified architecture current, swapping the existing one
3494    out.  */
3495
3496 void
3497 deprecated_current_gdbarch_select_hack (struct gdbarch *new_gdbarch)
3498 {
3499   gdb_assert (new_gdbarch != NULL);
3500   gdb_assert (current_gdbarch != NULL);
3501   gdb_assert (new_gdbarch->initialized_p);
3502   current_gdbarch_swap_out_hack ();
3503   current_gdbarch_swap_in_hack (new_gdbarch);
3504   architecture_changed_event ();
3505   reinit_frame_cache ();
3506 }
3507
3508 extern void _initialize_gdbarch (void);
3509
3510 void
3511 _initialize_gdbarch (void)
3512 {
3513   struct cmd_list_element *c;
3514
3515   add_setshow_zinteger_cmd ("arch", class_maintenance, &gdbarch_debug, _("\
3516 Set architecture debugging."), _("\
3517 Show architecture debugging."), _("\
3518 When non-zero, architecture debugging is enabled."),
3519                             NULL,
3520                             show_gdbarch_debug,
3521                             &setdebuglist, &showdebuglist);
3522 }