1 /* Semi-dynamic architecture support for GDB, the GNU debugger.
2 Copyright 1998, Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 /* start-sanitize-carp start-sanitize-vr4xxx */
26 /* Convenience macro for allocting memory. */
29 #define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
32 /* end-sanitize-carp end-sanitize-vr4xxx */
34 /* Non-zero if we want to trace architecture code. */
37 #define GDBARCH_DEBUG 0
39 int gdbarch_debug
= GDBARCH_DEBUG
;
41 /* start-sanitize-carp start-sanitize-vr4xxx */
43 /* Maintain the struct gdbarch object */
47 /* basic architectural information */
48 const struct bfd_arch_info
*bfd_arch_info
;
51 /* target specific vector. */
52 struct gdbarch_tdep
*tdep
;
54 /* per-architecture data-pointers */
58 /* per-architecture swap-regions */
59 struct gdbarch_swap
*swap
;
63 When adding to the below you must also: declare/define set/get
64 value functions; override the corresponding macro in gdbarch.h;
65 if zero/NULL is not a suitable default, initialize the field in
66 gdbarch_alloc(); confirm that the target updated the value
67 correctly in verify_gdbarch(); add a fprintf_unfiltered call to
68 gdbarch_update() so that the new field is dumped out; append an
69 initial value to the static variable ``default_gdbarch'' (base
70 values on the host's c-type system). */
80 gdbarch_tdep (gdbarch
)
81 struct gdbarch
*gdbarch
;
86 const struct bfd_arch_info
*
87 gdbarch_bfd_arch_info (gdbarch
)
88 struct gdbarch
*gdbarch
;
90 return gdbarch
->bfd_arch_info
;
94 gdbarch_byte_order (gdbarch
)
95 struct gdbarch
*gdbarch
;
97 return gdbarch
->byte_order
;
101 gdbarch_long_bit (gdbarch
)
102 struct gdbarch
*gdbarch
;
104 return gdbarch
->long_bit
;
108 set_gdbarch_long_bit (gdbarch
, long_bit
)
109 struct gdbarch
*gdbarch
;
112 gdbarch
->long_bit
= long_bit
;
116 gdbarch_long_long_bit (gdbarch
)
117 struct gdbarch
*gdbarch
;
119 return gdbarch
->long_long_bit
;
123 set_gdbarch_long_long_bit (gdbarch
, long_long_bit
)
124 struct gdbarch
*gdbarch
;
127 gdbarch
->long_long_bit
= long_long_bit
;
131 gdbarch_ptr_bit (gdbarch
)
132 struct gdbarch
*gdbarch
;
134 return gdbarch
->ptr_bit
;
138 set_gdbarch_ptr_bit (gdbarch
, ptr_bit
)
139 struct gdbarch
*gdbarch
;
142 gdbarch
->ptr_bit
= ptr_bit
;
146 /* Ensure that all values in a GDBARCH are reasonable. XXX - should
147 this instead return a success/fail indication? */
150 verify_gdbarch (gdbarch
)
151 struct gdbarch
*gdbarch
;
154 if (gdbarch
->byte_order
== 0)
155 fatal ("verify_gdbarch: byte-order unset");
156 if (gdbarch
->bfd_arch_info
== NULL
)
157 fatal ("verify_gdbarch: bfd_arch_info unset");
159 if (gdbarch
->long_bit
== 0)
160 fatal ("verify_gdbarch: long_bit invalid");
161 if (gdbarch
->long_long_bit
== 0)
162 fatal ("verify_gdbarch: long_long_bit invalid");
163 if (gdbarch
->ptr_bit
== 0)
164 fatal ("verify_gdbarch: ptr_bit invalid");
168 /* Keep a registrary of per-architecture data-pointers required by GDB
176 struct gdbarch_data_registration
178 gdbarch_data_ftype
*init
;
179 struct gdbarch_data
*data
;
180 struct gdbarch_data_registration
*next
;
183 struct gdbarch_data_registrary
186 struct gdbarch_data_registration
*registrations
;
189 struct gdbarch_data_registrary gdbarch_data_registrary
=
194 struct gdbarch_data
*
195 register_gdbarch_data (init
)
196 gdbarch_data_ftype
*init
;
198 struct gdbarch_data_registration
**curr
;
199 for (curr
= &gdbarch_data_registrary
.registrations
;
201 curr
= &(*curr
)->next
);
202 (*curr
) = XMALLOC (struct gdbarch_data_registration
);
203 (*curr
)->next
= NULL
;
204 (*curr
)->init
= init
;
205 (*curr
)->data
= XMALLOC (struct gdbarch_data
);
206 (*curr
)->data
->index
= gdbarch_data_registrary
.nr
++;
207 return (*curr
)->data
;
211 /* Walk through all the registered users initializing each in turn. */
213 static void init_gdbarch_data
PARAMS ((struct gdbarch
*));
215 init_gdbarch_data (gdbarch
)
216 struct gdbarch
*gdbarch
;
218 struct gdbarch_data_registration
*rego
;
219 gdbarch
->nr_data
= gdbarch_data_registrary
.nr
+ 1;
220 gdbarch
->data
= xmalloc (sizeof (void*) * gdbarch
->nr_data
);
221 for (rego
= gdbarch_data_registrary
.registrations
;
225 if (rego
->data
->index
< gdbarch
->nr_data
)
226 gdbarch
->data
[rego
->data
->index
] = rego
->init ();
231 /* Return the current value of the specified per-architecture
236 struct gdbarch_data
*data
;
238 if (data
->index
>= current_gdbarch
->nr_data
)
239 fatal ("gdbarch_data: request for non-existant data.");
240 return current_gdbarch
->data
[data
->index
];
245 /* Keep a registrary of swaped data required by GDB modules. */
250 struct gdbarch_swap_registration
*source
;
251 struct gdbarch_swap
*next
;
254 struct gdbarch_swap_registration
257 unsigned long sizeof_data
;
258 gdbarch_swap_ftype
*init
;
259 struct gdbarch_swap_registration
*next
;
262 struct gdbarch_swap_registrary
265 struct gdbarch_swap_registration
*registrations
;
268 struct gdbarch_swap_registrary gdbarch_swap_registrary
=
274 register_gdbarch_swap (data
, sizeof_data
, init
)
276 unsigned long sizeof_data
;
277 gdbarch_swap_ftype
*init
;
279 struct gdbarch_swap_registration
**rego
;
280 for (rego
= &gdbarch_swap_registrary
.registrations
;
282 rego
= &(*rego
)->next
);
283 (*rego
) = XMALLOC (struct gdbarch_swap_registration
);
284 (*rego
)->next
= NULL
;
285 (*rego
)->init
= init
;
286 (*rego
)->data
= data
;
287 (*rego
)->sizeof_data
= sizeof_data
;
291 static void init_gdbarch_swap
PARAMS ((struct gdbarch
*));
293 init_gdbarch_swap (gdbarch
)
294 struct gdbarch
*gdbarch
;
296 struct gdbarch_swap_registration
*rego
;
297 struct gdbarch_swap
**curr
= &gdbarch
->swap
;
298 for (rego
= gdbarch_swap_registrary
.registrations
;
302 if (rego
->data
!= NULL
)
304 (*curr
) = XMALLOC (struct gdbarch_swap
);
305 (*curr
)->source
= rego
;
306 (*curr
)->swap
= xmalloc (rego
->sizeof_data
);
307 (*curr
)->next
= NULL
;
308 memset (rego
->data
, 0, rego
->sizeof_data
);
309 curr
= &(*curr
)->next
;
311 if (rego
->init
!= NULL
)
316 static void swapout_gdbarch_swap
PARAMS ((struct gdbarch
*));
318 swapout_gdbarch_swap (gdbarch
)
319 struct gdbarch
*gdbarch
;
321 struct gdbarch_swap
*curr
;
322 for (curr
= gdbarch
->swap
;
325 memcpy (curr
->swap
, curr
->source
->data
, curr
->source
->sizeof_data
);
328 static void swapin_gdbarch_swap
PARAMS ((struct gdbarch
*));
330 swapin_gdbarch_swap (gdbarch
)
331 struct gdbarch
*gdbarch
;
333 struct gdbarch_swap
*curr
;
334 for (curr
= gdbarch
->swap
;
337 memcpy (curr
->source
->data
, curr
->swap
, curr
->source
->sizeof_data
);
341 /* Keep a registrary of the architectures known by GDB. */
343 struct gdbarch_init_registration
345 enum bfd_architecture bfd_architecture
;
346 gdbarch_init_ftype
*init
;
347 struct gdbarch_list
*arches
;
348 struct gdbarch_init_registration
*next
;
351 static struct gdbarch_init_registration
*gdbarch_init_registrary
= NULL
;
354 register_gdbarch_init (bfd_architecture
, init
)
355 enum bfd_architecture bfd_architecture
;
356 gdbarch_init_ftype
*init
;
358 struct gdbarch_init_registration
**curr
;
359 const struct bfd_arch_info
*bfd_arch_info
;
360 /* Check that BFD reconizes this architecture */
361 bfd_arch_info
= bfd_lookup_arch (bfd_architecture
, 0);
362 if (bfd_arch_info
== NULL
)
364 fatal ("Attempt to register unknown architecture (%d)", bfd_architecture
);
366 /* Check that we haven't seen this architecture before */
367 for (curr
= &gdbarch_init_registrary
;
369 curr
= &(*curr
)->next
)
371 if (bfd_architecture
== (*curr
)->bfd_architecture
)
372 fatal ("Duplicate registraration of architecture (%s)",
373 bfd_arch_info
->printable_name
);
377 fprintf_unfiltered (gdb_stderr
, "register_gdbarch_init (%s, 0x%08lx)\n",
378 bfd_arch_info
->printable_name
,
381 (*curr
) = XMALLOC (struct gdbarch_init_registration
);
382 (*curr
)->bfd_architecture
= bfd_architecture
;
383 (*curr
)->init
= init
;
384 (*curr
)->arches
= NULL
;
385 (*curr
)->next
= NULL
;
390 /* Look for an architecture using gdbarch_info. Base search on only
391 BFD_ARCH_INFO and BYTE_ORDER. */
393 struct gdbarch_list
*
394 gdbarch_list_lookup_by_info (arches
, info
)
395 struct gdbarch_list
*arches
;
396 const struct gdbarch_info
*info
;
398 for (; arches
!= NULL
; arches
= arches
->next
)
400 if (info
->bfd_arch_info
!= arches
->gdbarch
->bfd_arch_info
)
402 if (info
->byte_order
!= arches
->gdbarch
->byte_order
)
410 /* Create a new ``struct gdbarch'' based in information provied by
411 ``struct gdbarch_info'' */
414 gdbarch_alloc (info
, tdep
)
415 const struct gdbarch_info
*info
;
416 struct gdbarch_tdep
*tdep
;
418 struct gdbarch
*gdbarch
= XMALLOC (struct gdbarch
);
419 memset (gdbarch
, 0, sizeof (*gdbarch
));
421 gdbarch
->tdep
= tdep
;
423 gdbarch
->bfd_arch_info
= info
->bfd_arch_info
;
424 gdbarch
->byte_order
= info
->byte_order
;
429 /* Update the current architecture. Return ZERO if the update request
433 gdbarch_update (info
)
434 struct gdbarch_info info
;
436 struct gdbarch
*new_gdbarch
;
437 struct gdbarch_list
**list
;
438 struct gdbarch_init_registration
*rego
;
440 /* Fill in any missing bits. Most important is the bfd_architecture
441 which is used to select the target architecture. */
442 if (info
.bfd_architecture
== bfd_arch_unknown
)
444 if (info
.bfd_arch_info
!= NULL
)
445 info
.bfd_architecture
= info
.bfd_arch_info
->arch
;
446 else if (info
.abfd
!= NULL
)
447 info
.bfd_architecture
= bfd_get_arch (info
.abfd
);
448 /* FIXME - should query BFD for its default architecture. */
450 info
.bfd_architecture
= current_gdbarch
->bfd_arch_info
->arch
;
452 if (info
.bfd_arch_info
== NULL
)
454 if (target_architecture_auto
&& info
.abfd
!= NULL
)
455 info
.bfd_arch_info
= bfd_get_arch_info (info
.abfd
);
457 info
.bfd_arch_info
= current_gdbarch
->bfd_arch_info
;
459 if (info
.byte_order
== 0)
461 if (target_byte_order_auto
&& info
.abfd
!= NULL
)
462 info
.byte_order
= (bfd_big_endian (info
.abfd
) ? BIG_ENDIAN
463 : bfd_little_endian (info
.abfd
) ? LITTLE_ENDIAN
466 info
.byte_order
= current_gdbarch
->byte_order
;
468 /* A default for abfd? */
470 /* Find the target that knows about this architecture. */
471 for (rego
= gdbarch_init_registrary
;
472 rego
!= NULL
&& rego
->bfd_architecture
!= info
.bfd_architecture
;
477 fprintf_unfiltered (gdb_stderr
, "gdbarch_update: No matching architecture\n");
483 fprintf_unfiltered (gdb_stderr
,
484 "gdbarch_update: info.bfd_architecture %d (%s)\n",
485 info
.bfd_architecture
,
486 bfd_lookup_arch (info
.bfd_architecture
, 0)->printable_name
);
487 fprintf_unfiltered (gdb_stderr
,
488 "gdbarch_update: info.bfd_arch_info %s\n",
489 (info
.bfd_arch_info
!= NULL
490 ? info
.bfd_arch_info
->printable_name
492 fprintf_unfiltered (gdb_stderr
,
493 "gdbarch_update: info.byte_order %d (%s)\n",
495 (info
.byte_order
== BIG_ENDIAN
? "big"
496 : info
.byte_order
== LITTLE_ENDIAN
? "little"
498 fprintf_unfiltered (gdb_stderr
,
499 "gdbarch_update: info.abfd 0x%lx\n",
501 fprintf_unfiltered (gdb_stderr
,
502 "gdbarch_update: info.tdep_info 0x%lx\n",
503 (long) info
.tdep_info
);
506 /* Ask the target for a replacement architecture. */
507 new_gdbarch
= rego
->init (info
, rego
->arches
);
509 /* Did the target like it? No. Reject the change. */
510 if (new_gdbarch
== NULL
)
513 fprintf_unfiltered (gdb_stderr
, "gdbarch_update: Target rejected architecture\n");
517 /* Did the architecture change? No. Do nothing. */
518 if (current_gdbarch
== new_gdbarch
)
521 fprintf_unfiltered (gdb_stderr
, "gdbarch_update: Architecture 0x%08lx (%s) unchanged\n",
523 new_gdbarch
->bfd_arch_info
->printable_name
);
527 /* Swap all data belonging to the old target out */
528 swapout_gdbarch_swap (current_gdbarch
);
530 /* Is this a pre-existing architecture? Yes. Swap it in. */
531 for (list
= ®o
->arches
;
533 list
= &(*list
)->next
)
535 if ((*list
)->gdbarch
== new_gdbarch
)
538 fprintf_unfiltered (gdb_stderr
, "gdbarch_update: Previous architecture 0x%08lx (%s) selected\n",
540 new_gdbarch
->bfd_arch_info
->printable_name
);
541 current_gdbarch
= new_gdbarch
;
542 swapin_gdbarch_swap (new_gdbarch
);
547 /* Append this new architecture to this targets list. */
548 (*list
) = XMALLOC (struct gdbarch_list
);
549 (*list
)->next
= NULL
;
550 (*list
)->gdbarch
= new_gdbarch
;
552 /* Switch to this new architecture. Dump it out. */
553 current_gdbarch
= new_gdbarch
;
556 fprintf_unfiltered (gdb_stderr
,
557 "gdbarch_update: New architecture 0x%08lx (%s) selected\n",
559 new_gdbarch
->bfd_arch_info
->printable_name
);
560 fprintf_unfiltered (gdb_stderr
,
561 "gdbarch_update: TARGET_BYTE_ORDER = %d (%s)\n",
563 (TARGET_BYTE_ORDER
== BIG_ENDIAN
? "big"
564 : TARGET_BYTE_ORDER
== LITTLE_ENDIAN
? "little"
566 fprintf_unfiltered (gdb_stderr
,
567 "gdbarch_update: TARGET_LONG_BIT = %d\n",
569 fprintf_unfiltered (gdb_stderr
,
570 "gdbarch_update: TARGET_LONG_LONG_BIT = %d\n",
571 TARGET_LONG_LONG_BIT
);
572 fprintf_unfiltered (gdb_stderr
,
573 "gdbarch_update: TARGET_PTR_BIT = %d\n",
577 /* Check that the newly installed architecture is valid. */
578 verify_gdbarch (new_gdbarch
);
580 /* Initialize the per-architecture memory (swap) areas.
581 CURRENT_GDBARCH must be update before these modules are
583 init_gdbarch_swap (new_gdbarch
);
585 /* Initialize the per-architecture data-pointer of all parties that
586 registered an interest in this architecture. CURRENT_GDBARCH
587 must be updated before these modules are called. */
588 init_gdbarch_data (new_gdbarch
);
594 /* end-sanitize-carp end-sanitize-vr4xxx */
596 /* Functions to manipulate the endianness of the target. */
598 #ifdef TARGET_BYTE_ORDER_SELECTABLE
599 /* compat - Catch old targets that expect a selectable byte-order to
600 default to BIG_ENDIAN */
601 #ifndef TARGET_BYTE_ORDER_DEFAULT
602 #define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
605 #ifndef TARGET_BYTE_ORDER_DEFAULT
606 /* compat - Catch old non byte-order selectable targets that do not
607 define TARGET_BYTE_ORDER_DEFAULT and instead expect
608 TARGET_BYTE_ORDER to be used as the default. For targets that
609 defined neither TARGET_BYTE_ORDER nor TARGET_BYTE_ORDER_DEFAULT the
610 below will get a strange compiler warning. */
611 #define TARGET_BYTE_ORDER_DEFAULT TARGET_BYTE_ORDER
613 int target_byte_order
= TARGET_BYTE_ORDER_DEFAULT
;
614 int target_byte_order_auto
= 1;
616 /* Chain containing the \"set endian\" commands. */
617 static struct cmd_list_element
*endianlist
= NULL
;
619 /* Called by ``show endian''. */
620 static void show_endian
PARAMS ((char *, int));
622 show_endian (args
, from_tty
)
627 (TARGET_BYTE_ORDER_AUTO
628 ? "The target endianness is set automatically (currently %s endian)\n"
629 : "The target is assumed to be %s endian\n");
630 printf_unfiltered (msg
, (TARGET_BYTE_ORDER
== BIG_ENDIAN
? "big" : "little"));
633 /* Called if the user enters ``set endian'' without an argument. */
634 static void set_endian
PARAMS ((char *, int));
636 set_endian (args
, from_tty
)
640 printf_unfiltered ("\"set endian\" must be followed by \"auto\", \"big\" or \"little\".\n");
641 show_endian (args
, from_tty
);
644 /* Called by ``set endian big''. */
645 static void set_endian_big
PARAMS ((char *, int));
647 set_endian_big (args
, from_tty
)
651 if (TARGET_BYTE_ORDER_SELECTABLE_P
)
653 target_byte_order
= BIG_ENDIAN
;
654 target_byte_order_auto
= 0;
655 /* start-sanitize-carp start-sanitize-vr4xxx */
658 struct gdbarch_info info
;
659 memset (&info
, 0, sizeof info
);
660 info
.byte_order
= BIG_ENDIAN
;
661 gdbarch_update (info
);
663 /* end-sanitize-carp end-sanitize-vr4xxx */
667 printf_unfiltered ("Byte order is not selectable.");
668 show_endian (args
, from_tty
);
672 /* Called by ``set endian little''. */
673 static void set_endian_little
PARAMS ((char *, int));
675 set_endian_little (args
, from_tty
)
679 if (TARGET_BYTE_ORDER_SELECTABLE_P
)
681 target_byte_order
= LITTLE_ENDIAN
;
682 target_byte_order_auto
= 0;
683 /* start-sanitize-carp start-sanitize-vr4xxx */
686 struct gdbarch_info info
;
687 memset (&info
, 0, sizeof info
);
688 info
.byte_order
= LITTLE_ENDIAN
;
689 gdbarch_update (info
);
691 /* end-sanitize-carp end-sanitize-vr4xxx */
695 printf_unfiltered ("Byte order is not selectable.");
696 show_endian (args
, from_tty
);
700 /* Called by ``set endian auto''. */
701 static void set_endian_auto
PARAMS ((char *, int));
703 set_endian_auto (args
, from_tty
)
707 if (TARGET_BYTE_ORDER_SELECTABLE_P
)
709 target_byte_order_auto
= 1;
713 printf_unfiltered ("Byte order is not selectable.");
714 show_endian (args
, from_tty
);
718 /* Set the endianness from a BFD. */
719 static void set_endian_from_file
PARAMS ((bfd
*));
721 set_endian_from_file (abfd
)
724 if (TARGET_BYTE_ORDER_SELECTABLE_P
)
728 if (bfd_big_endian (abfd
))
731 want
= LITTLE_ENDIAN
;
732 if (TARGET_BYTE_ORDER_AUTO
)
733 target_byte_order
= want
;
734 else if (TARGET_BYTE_ORDER
!= want
)
735 warning ("%s endian file does not match %s endian target.",
736 want
== BIG_ENDIAN
? "big" : "little",
737 TARGET_BYTE_ORDER
== BIG_ENDIAN
? "big" : "little");
741 if (bfd_big_endian (abfd
)
742 ? TARGET_BYTE_ORDER
!= BIG_ENDIAN
743 : TARGET_BYTE_ORDER
== BIG_ENDIAN
)
744 warning ("%s endian file does not match %s endian target.",
745 bfd_big_endian (abfd
) ? "big" : "little",
746 TARGET_BYTE_ORDER
== BIG_ENDIAN
? "big" : "little");
752 /* Functions to manipulate the architecture of the target */
754 int target_architecture_auto
= 1;
755 extern const struct bfd_arch_info bfd_default_arch_struct
;
756 const struct bfd_arch_info
*target_architecture
= &bfd_default_arch_struct
;
757 int (*target_architecture_hook
) PARAMS ((const struct bfd_arch_info
*ap
));
759 /* Do the real work of changing the current architecture */
762 const struct bfd_arch_info
*arch
;
764 /* FIXME: Is it compatible with gdb? */
765 /* Check with the target on the setting */
766 if (target_architecture_hook
!= NULL
767 && !target_architecture_hook (arch
))
768 printf_unfiltered ("Target does not support `%s' architecture.\n",
769 arch
->printable_name
);
772 target_architecture_auto
= 0;
773 target_architecture
= arch
;
777 /* Called if the user enters ``show architecture'' without an argument. */
778 static void show_architecture
PARAMS ((char *, int));
780 show_architecture (args
, from_tty
)
785 arch
= TARGET_ARCHITECTURE
->printable_name
;
786 if (target_architecture_auto
)
787 printf_filtered ("The target architecture is set automatically (currently %s)\n", arch
);
789 printf_filtered ("The target architecture is assumed to be %s\n", arch
);
792 /* Called if the user enters ``set architecture'' with or without an
794 static void set_architecture
PARAMS ((char *, int));
796 set_architecture (args
, from_tty
)
802 printf_unfiltered ("\"set architecture\" must be followed by \"auto\" or an architecture name.\n");
804 else if (strcmp (args
, "auto") == 0)
806 target_architecture_auto
= 1;
808 /* start-sanitize-carp start-sanitize-vr4xxx */
809 else if (GDB_MULTI_ARCH
)
811 const struct bfd_arch_info
*arch
= bfd_scan_arch (args
);
813 printf_unfiltered ("Architecture `%s' not reconized.\n", args
);
816 struct gdbarch_info info
;
817 memset (&info
, 0, sizeof info
);
818 info
.bfd_arch_info
= arch
;
819 if (gdbarch_update (info
))
820 target_architecture_auto
= 0;
822 printf_unfiltered ("Architecture `%s' not reconized.\n", args
);
825 /* end-sanitize-carp end-sanitize-vr4xxx */
828 const struct bfd_arch_info
*arch
= bfd_scan_arch (args
);
832 printf_unfiltered ("Architecture `%s' not reconized.\n", args
);
836 /* Called if the user enters ``info architecture'' without an argument. */
837 static void info_architecture
PARAMS ((char *, int));
839 info_architecture (args
, from_tty
)
843 enum bfd_architecture a
;
844 /* start-sanitize-carp start-sanitize-vr4xxx */
847 if (gdbarch_init_registrary
!= NULL
)
849 struct gdbarch_init_registration
*rego
;
850 printf_filtered ("Available architectures are:\n");
851 for (rego
= gdbarch_init_registrary
;
855 const struct bfd_arch_info
*ap
;
856 ap
= bfd_lookup_arch (rego
->bfd_architecture
, 0);
861 printf_filtered (" %s", ap
->printable_name
);
865 printf_filtered ("\n");
871 printf_filtered ("There are no available architectures.\n");
875 /* end-sanitize-carp end-sanitize-vr4xxx */
876 printf_filtered ("Available architectures are:\n");
877 for (a
= bfd_arch_obscure
+ 1; a
< bfd_arch_last
; a
++)
879 const struct bfd_arch_info
*ap
= bfd_lookup_arch (a
, 0);
884 printf_filtered (" %s", ap
->printable_name
);
888 printf_filtered ("\n");
893 /* Set the architecture from arch/machine */
895 set_architecture_from_arch_mach (arch
, mach
)
896 enum bfd_architecture arch
;
899 const struct bfd_arch_info
*wanted
= bfd_lookup_arch (arch
, mach
);
903 fatal ("hardwired architecture/machine not reconized");
906 /* Set the architecture from a BFD */
907 static void set_architecture_from_file
PARAMS ((bfd
*));
909 set_architecture_from_file (abfd
)
912 const struct bfd_arch_info
*wanted
= bfd_get_arch_info (abfd
);
913 if (target_architecture_auto
)
915 if (target_architecture_hook
!= NULL
916 && !target_architecture_hook (wanted
))
917 warning ("Target may not support %s architecture",
918 wanted
->printable_name
);
919 target_architecture
= wanted
;
921 else if (wanted
!= target_architecture
)
923 warning ("%s architecture file may be incompatible with %s target.",
924 wanted
->printable_name
,
925 target_architecture
->printable_name
);
933 /* Pointer to the target-dependent disassembly function. */
934 int (*tm_print_insn
) PARAMS ((bfd_vma
, disassemble_info
*));
935 disassemble_info tm_print_insn_info
;
939 /* Set the dynamic target-system-dependant parameters (architecture,
940 byte-order) using information found in the BFD */
943 set_gdbarch_from_file (abfd
)
946 /* start-sanitize-carp start-sanitize-vr4xxx */
949 struct gdbarch_info info
;
950 memset (&info
, 0, sizeof info
);
952 gdbarch_update (info
);
955 /* end-sanitize-carp end-sanitize-vr4xxx */
956 set_architecture_from_file (abfd
);
957 set_endian_from_file (abfd
);
960 /* start-sanitize-carp start-sanitize-vr4xxx */
962 /* The default architecture uses host values (for want of a better
965 struct gdbarch default_gdbarch
= {
966 /* basic architecture information */
967 &bfd_default_arch_struct
,
968 TARGET_BYTE_ORDER_DEFAULT
,
969 /* target specific vector */
971 /*per-architecture data-pointers and swap regions */
973 /* Multi-arch values */
974 8 * sizeof (long), /* long */
975 8 * sizeof (LONGEST
), /* long long */
976 8 * sizeof (void*), /* ptr */
978 struct gdbarch
*current_gdbarch
= &default_gdbarch
;
980 /* end-sanitize-carp end-sanitize-vr4xxx */
982 extern void _initialize_gdbarch
PARAMS ((void));
984 _initialize_gdbarch ()
986 add_prefix_cmd ("endian", class_support
, set_endian
,
987 "Set endianness of target.",
988 &endianlist
, "set endian ", 0, &setlist
);
989 add_cmd ("big", class_support
, set_endian_big
,
990 "Set target as being big endian.", &endianlist
);
991 add_cmd ("little", class_support
, set_endian_little
,
992 "Set target as being little endian.", &endianlist
);
993 add_cmd ("auto", class_support
, set_endian_auto
,
994 "Select target endianness automatically.", &endianlist
);
995 add_cmd ("endian", class_support
, show_endian
,
996 "Show endianness of target.", &showlist
);
998 add_cmd ("architecture", class_support
, set_architecture
,
999 "Set architecture of target.", &setlist
);
1000 add_alias_cmd ("processor", "architecture", class_support
, 1, &setlist
);
1001 add_cmd ("architecture", class_support
, show_architecture
,
1002 "Show architecture of target.", &showlist
);
1003 add_cmd ("architecture", class_support
, info_architecture
,
1004 "List supported target architectures", &infolist
);
1006 INIT_DISASSEMBLE_INFO_NO_ARCH (tm_print_insn_info
, gdb_stdout
, (fprintf_ftype
)fprintf_filtered
);
1007 tm_print_insn_info
.flavour
= bfd_target_unknown_flavour
;
1008 tm_print_insn_info
.read_memory_func
= dis_asm_read_memory
;
1009 tm_print_insn_info
.memory_error_func
= dis_asm_memory_error
;
1010 tm_print_insn_info
.print_address_func
= dis_asm_print_address
;
1012 #ifdef MAINTENANCE_CMDS
1013 add_show_from_set (add_set_cmd ("archdebug",
1016 (char *)&gdbarch_debug
,
1017 "Set architecture debugging.\n\
1018 When non-zero, architecture debugging is enabled.", &setlist
),