diff options
author | Andrew Cagney <cagney@redhat.com> | 1998-12-14 02:37:16 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 1998-12-14 02:37:16 +0000 |
commit | f7e85b1bc11e564d356933c447070a55ff5fa56d (patch) | |
tree | 676c86e49ebbc3c02e29a16a41cfb7a6ab77138b | |
parent | aaa3c096db1beebb67015bc8711cf908f7f2559b (diff) | |
download | gdb-f7e85b1bc11e564d356933c447070a55ff5fa56d.zip gdb-f7e85b1bc11e564d356933c447070a55ff5fa56d.tar.gz gdb-f7e85b1bc11e564d356933c447070a55ff5fa56d.tar.bz2 |
CARP:
Consolidate the semi-dynamic target system dependant GDB parameters
moving them all into a new file.
-rw-r--r-- | gdb/.Sanitize | 2 | ||||
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/Makefile.in | 8 | ||||
-rw-r--r-- | gdb/gdbarch.c | 341 | ||||
-rw-r--r-- | gdb/gdbarch.h | 109 | ||||
-rw-r--r-- | gdb/top.c | 293 |
6 files changed, 467 insertions, 296 deletions
diff --git a/gdb/.Sanitize b/gdb/.Sanitize index 8ddb33e..e641619 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -226,6 +226,8 @@ gdb.gdb gdb_stat.h gdb_string.h gdba.el +gdbarch.c +gdbarch.h gdbcmd.h gdbcore.h gdbinit.in diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 40c10a8..798cd68 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Mon Dec 14 11:01:39 1998 Andrew Cagney <cagney@b1.cygnus.com> + + * gdbarch.h, gdbarch.c: Consolidate the semi-dynamic target system + dependant GDB parameters. + (set_gdbarch_from_file): Combine set_architecture_from_file and + set_byte_order_from_file. + * top.c, defs.h, printcmd.c: Delete them from here. + * Makefile.in: Add gdbarch.[ch]. + * exec.c (exec_file_command): Call set_gdbarch_from_file. + Sun Dec 13 09:52:51 1998 Andrew Cagney <cagney@b1.cygnus.com> * defs.h (TARGET_PRINT_INSN_INFO, TARGET_PRINT_INSN): Define. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 10f3f59..6831a6e 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -398,7 +398,7 @@ SFILES = ax-general.c ax-gdb.c bcache.c blockframe.c breakpoint.c \ command.c complaints.c corefile.c cp-valprint.c dbxread.c \ demangle.c dwarfread.c dwarf2read.c elfread.c environ.c eval.c \ expprint.c f-exp.y f-lang.c f-typeprint.c f-valprint.c \ - findvar.c gdbtypes.c infcmd.c inflow.c infrun.c language.c \ + findvar.c gdbarch.c gdbtypes.c infcmd.c inflow.c infrun.c language.c \ $(start-sanitize-java) \ jv-exp.y jv-lang.c jv-valprint.c jv-typeprint.c \ $(end-sanitize-java) \ @@ -455,7 +455,7 @@ breakpoint_h = breakpoint.h $(frame_h) $(value_h) command_h = command.h gdbcmd_h = gdbcmd.h $(command_h) -defs_h = defs.h xm.h tm.h nm.h config.status config.h +defs_h = defs.h xm.h tm.h nm.h config.status config.h gdbarch.h inferior_h = inferior.h $(breakpoint_h) tracepoint_h = tracepoint.h @@ -520,7 +520,7 @@ TAGFILES_WITH_SRCDIR = $(HFILES_WITH_SRCDIR) COMMON_OBS = version.o blockframe.o breakpoint.o findvar.o stack.o thread.o \ source.o values.o eval.o valops.o valarith.o valprint.o printcmd.o \ symtab.o symfile.o symmisc.o infcmd.o infrun.o command.o \ - expprint.o environ.o gdbtypes.o copying.o $(DEPFILES) \ + expprint.o environ.o gdbarch.o gdbtypes.o copying.o $(DEPFILES) \ mem-break.o target.o parse.o language.o $(YYOBJ) buildsym.o \ exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \ dbxread.o coffread.o elfread.o \ @@ -1202,6 +1202,8 @@ v850ice.o: v850ice.c $(defs_h) $(symtab_h) $(inferior_h) $(command_h) \ $(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \ $(srcdir)/v850ice.c +gdbarch.o: gdbarch.c $(defs_h) $(bfd_h) $(gdbcmd_h) + gdbtypes.o: gdbtypes.c $(bfd_h) complaints.h $(defs_h) $(expression_h) \ $(gdbtypes_h) language.h objfiles.h symfile.h $(symtab_h) target.h \ $(value_h) gdb_string.h diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c new file mode 100644 index 0000000..7f720a8 --- /dev/null +++ b/gdb/gdbarch.c @@ -0,0 +1,341 @@ +/* Semi-dynamic architecture support for GDB, the GNU debugger. + Copyright 1998, Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "bfd.h" +#include "gdbcmd.h" + + +/* Functions to manipulate the endianness of the target. */ + +#ifdef TARGET_BYTE_ORDER_SELECTABLE +/* compat - Catch old targets that expect a selectable byte-order to + default to BIG_ENDIAN */ +#ifndef TARGET_BYTE_ORDER_DEFAULT +#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN +#endif +#endif +#ifndef TARGET_BYTE_ORDER_DEFAULT +/* compat - Catch old non byte-order selectable targets that do not + define TARGET_BYTE_ORDER_DEFAULT and instead expect + TARGET_BYTE_ORDER to be used as the default. For targets that + defined neither TARGET_BYTE_ORDER nor TARGET_BYTE_ORDER_DEFAULT the + below will get a strange compiler warning. */ +#define TARGET_BYTE_ORDER_DEFAULT TARGET_BYTE_ORDER +#endif +int target_byte_order = TARGET_BYTE_ORDER_DEFAULT; +int target_byte_order_auto = 1; + +/* Chain containing the \"set endian\" commands. */ +static struct cmd_list_element *endianlist = NULL; + +/* Called by ``show endian''. */ +static void show_endian PARAMS ((char *, int)); +static void +show_endian (args, from_tty) + char *args; + int from_tty; +{ + char *msg = + (TARGET_BYTE_ORDER_AUTO + ? "The target endianness is set automatically (currently %s endian)\n" + : "The target is assumed to be %s endian\n"); + printf_unfiltered (msg, (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little")); +} + +/* Called if the user enters ``set endian'' without an argument. */ +static void set_endian PARAMS ((char *, int)); +static void +set_endian (args, from_tty) + char *args; + int from_tty; +{ + printf_unfiltered ("\"set endian\" must be followed by \"auto\", \"big\" or \"little\".\n"); + show_endian (args, from_tty); +} + +/* Called by ``set endian big''. */ +static void set_endian_big PARAMS ((char *, int)); +static void +set_endian_big (args, from_tty) + char *args; + int from_tty; +{ + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + target_byte_order = BIG_ENDIAN; + target_byte_order_auto = 0; + } + else + { + printf_unfiltered ("Byte order is not selectable."); + show_endian (args, from_tty); + } +} + +/* Called by ``set endian little''. */ +static void set_endian_little PARAMS ((char *, int)); +static void +set_endian_little (args, from_tty) + char *args; + int from_tty; +{ + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + target_byte_order = LITTLE_ENDIAN; + target_byte_order_auto = 0; + } + else + { + printf_unfiltered ("Byte order is not selectable."); + show_endian (args, from_tty); + } +} + +/* Called by ``set endian auto''. */ +static void set_endian_auto PARAMS ((char *, int)); +static void +set_endian_auto (args, from_tty) + char *args; + int from_tty; +{ + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + target_byte_order_auto = 1; + } + else + { + printf_unfiltered ("Byte order is not selectable."); + show_endian (args, from_tty); + } +} + +/* Set the endianness from a BFD. */ +static void set_endian_from_file PARAMS ((bfd *)); +static void +set_endian_from_file (abfd) + bfd *abfd; +{ + if (TARGET_BYTE_ORDER_SELECTABLE_P) + { + int want; + + if (bfd_big_endian (abfd)) + want = BIG_ENDIAN; + else + want = LITTLE_ENDIAN; + if (TARGET_BYTE_ORDER_AUTO) + target_byte_order = want; + else if (TARGET_BYTE_ORDER != want) + warning ("%s endian file does not match %s endian target.", + want == BIG_ENDIAN ? "big" : "little", + TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); + } + else + { + if (bfd_big_endian (abfd) + ? TARGET_BYTE_ORDER != BIG_ENDIAN + : TARGET_BYTE_ORDER == BIG_ENDIAN) + warning ("%s endian file does not match %s endian target.", + bfd_big_endian (abfd) ? "big" : "little", + TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); + } +} + + + +/* Functions to manipulate the architecture of the target */ + +int target_architecture_auto = 1; +extern const bfd_arch_info_type bfd_default_arch_struct; +const bfd_arch_info_type *target_architecture = &bfd_default_arch_struct; +int (*target_architecture_hook) PARAMS ((const bfd_arch_info_type *ap)); + +/* Do the real work of changing the current architecture */ +static void +set_arch (arch) + const bfd_arch_info_type *arch; +{ + /* FIXME: Is it compatible with gdb? */ + /* Check with the target on the setting */ + if (target_architecture_hook != NULL + && !target_architecture_hook (arch)) + printf_unfiltered ("Target does not support `%s' architecture.\n", + arch->printable_name); + else + { + target_architecture_auto = 0; + target_architecture = arch; + } +} + +/* Called if the user enters ``show architecture'' without an argument. */ +static void show_architecture PARAMS ((char *, int)); +static void +show_architecture (args, from_tty) + char *args; + int from_tty; +{ + const char *arch; + arch = target_architecture->printable_name; + if (target_architecture_auto) + printf_filtered ("The target architecture is set automatically (currently %s)\n", arch); + else + printf_filtered ("The target architecture is assumed to be %s\n", arch); +} + +/* Called if the user enters ``set architecture'' with or without an + argument. */ +static void set_architecture PARAMS ((char *, int)); +static void +set_architecture (args, from_tty) + char *args; + int from_tty; +{ + if (args == NULL) + { + printf_unfiltered ("\"set architecture\" must be followed by \"auto\" or an architecture name.\n"); + } + else if (strcmp (args, "auto") == 0) + { + target_architecture_auto = 1; + } + else + { + const bfd_arch_info_type *arch = bfd_scan_arch (args); + if (arch != NULL) + set_arch (arch); + else + printf_unfiltered ("Architecture `%s' not reconized.\n", args); + } +} + +/* Called if the user enters ``info architecture'' without an argument. */ +static void info_architecture PARAMS ((char *, int)); +static void +info_architecture (args, from_tty) + char *args; + int from_tty; +{ + enum bfd_architecture a; + printf_filtered ("Available architectures are:\n"); + for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++) + { + const bfd_arch_info_type *ap = bfd_lookup_arch (a, 0); + if (ap != NULL) + { + do + { + printf_filtered (" %s", ap->printable_name); + ap = ap->next; + } + while (ap != NULL); + printf_filtered ("\n"); + } + } +} + +/* Set the architecture from arch/machine */ +void +set_architecture_from_arch_mach (arch, mach) + enum bfd_architecture arch; + unsigned long mach; +{ + const bfd_arch_info_type *wanted = bfd_lookup_arch (arch, mach); + if (wanted != NULL) + set_arch (wanted); + else + fatal ("hardwired architecture/machine not reconized"); +} + +/* Set the architecture from a BFD */ +static void set_architecture_from_file PARAMS ((bfd *)); +static void +set_architecture_from_file (abfd) + bfd *abfd; +{ + const bfd_arch_info_type *wanted = bfd_get_arch_info (abfd); + if (target_architecture_auto) + { + if (target_architecture_hook != NULL + && !target_architecture_hook (wanted)) + warning ("Target may not support %s architecture", + wanted->printable_name); + target_architecture = wanted; + } + else if (wanted != target_architecture) + { + warning ("%s architecture file may be incompatible with %s target.", + wanted->printable_name, + target_architecture->printable_name); + } +} + + + +/* Disassembler */ + +/* Pointer to the target-dependent disassembly function. */ +int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info *)); +disassemble_info tm_print_insn_info; + + + +/* Set the dynamic target-system-dependant parameters (architecture, + byte-order) using information found in the BFD */ + +void +set_gdbarch_from_file (abfd) + bfd *abfd; +{ + set_architecture_from_file (abfd); + set_endian_from_file (abfd); +} + + +extern void _initialize_gdbarch PARAMS ((void)); +void +_initialize_gdbarch () +{ + add_prefix_cmd ("endian", class_support, set_endian, + "Set endianness of target.", + &endianlist, "set endian ", 0, &setlist); + add_cmd ("big", class_support, set_endian_big, + "Set target as being big endian.", &endianlist); + add_cmd ("little", class_support, set_endian_little, + "Set target as being little endian.", &endianlist); + add_cmd ("auto", class_support, set_endian_auto, + "Select target endianness automatically.", &endianlist); + add_cmd ("endian", class_support, show_endian, + "Show endianness of target.", &showlist); + + add_cmd ("architecture", class_support, set_architecture, + "Set architecture of target.", &setlist); + add_alias_cmd ("processor", "architecture", class_support, 1, &setlist); + add_cmd ("architecture", class_support, show_architecture, + "Show architecture of target.", &showlist); + add_cmd ("architecture", class_support, info_architecture, + "List supported target architectures", &infolist); + + INIT_DISASSEMBLE_INFO_NO_ARCH (tm_print_insn_info, gdb_stdout, (fprintf_ftype)fprintf_filtered); + tm_print_insn_info.flavour = bfd_target_unknown_flavour; + tm_print_insn_info.read_memory_func = dis_asm_read_memory; + tm_print_insn_info.memory_error_func = dis_asm_memory_error; + tm_print_insn_info.print_address_func = dis_asm_print_address; +} diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h new file mode 100644 index 0000000..1c93bb3 --- /dev/null +++ b/gdb/gdbarch.h @@ -0,0 +1,109 @@ +/* Architecture commands for GDB, the GNU debugger. + Copyright 1998, Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef GDBARCH_H +#define GDBARCH_H + + +/* The target-system-dependant byte order is dynmaic */ + +/* TARGET_BYTE_ORDER_SELECTABLE_P determines if the target endianness + is selectable at runtime. The user can use the `set endian' + command to change it. TARGET_BYTE_ORDER_AUTO is nonzero when + target_byte_order should be auto-detected (from the program image + say). */ + +#ifndef TARGET_BYTE_ORDER_SELECTABLE_P +/* compat - Catch old targets that define TARGET_BYTE_ORDER_SLECTABLE + when they should have defined TARGET_BYTE_ORDER_SELECTABLE_P 1 */ +#ifdef TARGET_BYTE_ORDER_SELECTABLE +#define TARGET_BYTE_ORDER_SELECTABLE_P 1 +#else +#define TARGET_BYTE_ORDER_SELECTABLE_P 0 +#endif +#endif + +extern int target_byte_order; +#ifdef TARGET_BYTE_ORDER_SELECTABLE +/* compat - Catch old targets that define TARGET_BYTE_ORDER_SELECTABLE + and expect defs.h to re-define TARGET_BYTE_ORDER. */ +#undef TARGET_BYTE_ORDER +#endif +#ifndef TARGET_BYTE_ORDER +#define TARGET_BYTE_ORDER (target_byte_order + 0) +#endif + +extern int target_byte_order_auto; +#ifndef TARGET_BYTE_ORDER_AUTO +#define TARGET_BYTE_ORDER_AUTO (target_byte_order_auto + 0) +#endif + + + +/* The target-system-dependant BFD architecture is dynamic */ + +extern int target_architecture_auto; +#define TARGET_ARCHITECTURE_AUTO (target_architecture_auto + 0) + +extern const bfd_arch_info_type *target_architecture; +#define TARGET_ARCHITECTURE (target_architecture + 0) + +/* Notify the target dependant backend of a change to the selected + architecture. A zero return status indicates that the target did + not like the change. */ + +extern int (*target_architecture_hook) PARAMS ((const bfd_arch_info_type *)); + + + +/* The target-system-dependant disassembler is semi-dynamic */ + +#include "dis-asm.h" /* Get defs for disassemble_info */ + +extern int dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, + int len, disassemble_info *info)); + +extern void dis_asm_memory_error PARAMS ((int status, bfd_vma memaddr, + disassemble_info *info)); + +extern void dis_asm_print_address PARAMS ((bfd_vma addr, + disassemble_info *info)); + +extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*)); +extern disassemble_info tm_print_insn_info; +#ifndef TARGET_PRINT_INSN +#define TARGET_PRINT_INSN(vma, info) (*tm_print_insn) (vma, info) +#endif +#ifndef TARGET_PRINT_INSN_INFO +#define TARGET_PRINT_INSN_INFO (&tm_print_insn_info) +#endif + + + +/* Set the dynamic target-system-dependant parameters (architecture, + byte-order, ...) using information found in the BFD */ + +extern void set_gdbarch_from_file PARAMS ((bfd *)); + +/* Explicitly set the dynamic target-system-dependant parameters based + on bfd_architecture and machine. */ + +extern void set_architecture_from_arch_mach PARAMS ((enum bfd_architecture, unsigned long)); + +#endif @@ -108,22 +108,6 @@ static void init_signals PARAMS ((void)); static void set_verbose PARAMS ((char *, int, struct cmd_list_element *)); -static void set_endian PARAMS ((char *, int)); - -static void set_endian_big PARAMS ((char *, int)); - -static void set_endian_little PARAMS ((char *, int)); - -static void set_endian_auto PARAMS ((char *, int)); - -static void show_endian PARAMS ((char *, int)); - -static void set_architecture PARAMS ((char *, int)); - -static void show_architecture PARAMS ((char *, int)); - -static void info_architecture PARAMS ((char *, int)); - static void show_history PARAMS ((char *, int)); static void set_history PARAMS ((char *, int)); @@ -239,10 +223,6 @@ struct cmd_list_element *unsetlist; struct cmd_list_element *showlist; -/* Chain containing the \"set endian\" commands. */ - -struct cmd_list_element *endianlist; - /* Chain containing all defined \"set history\". */ struct cmd_list_element *sethistlist; @@ -3197,257 +3177,6 @@ dont_repeat_command (ignored, from_tty) necessarily reading from stdin. */ } -/* Functions to manipulate the endianness of the target. */ - -#ifdef TARGET_BYTE_ORDER_SELECTABLE -/* compat - Catch old targets that expect a selectable byte-order to - default to BIG_ENDIAN */ -#ifndef TARGET_BYTE_ORDER_DEFAULT -#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN -#endif -#endif -#ifndef TARGET_BYTE_ORDER_DEFAULT -/* compat - Catch old non byte-order selectable targets that do not - define TARGET_BYTE_ORDER_DEFAULT and instead expect - TARGET_BYTE_ORDER to be used as the default. For targets that - defined neither TARGET_BYTE_ORDER nor TARGET_BYTE_ORDER_DEFAULT the - below will get a strange compiler warning. */ -#define TARGET_BYTE_ORDER_DEFAULT TARGET_BYTE_ORDER -#endif -int target_byte_order = TARGET_BYTE_ORDER_DEFAULT; -int target_byte_order_auto = 1; - -/* Called if the user enters ``set endian'' without an argument. */ -static void -set_endian (args, from_tty) - char *args; - int from_tty; -{ - printf_unfiltered ("\"set endian\" must be followed by \"auto\", \"big\" or \"little\".\n"); - show_endian (args, from_tty); -} - -/* Called by ``set endian big''. */ -static void -set_endian_big (args, from_tty) - char *args; - int from_tty; -{ - if (TARGET_BYTE_ORDER_SELECTABLE_P) - { - target_byte_order = BIG_ENDIAN; - target_byte_order_auto = 0; - } - else - { - printf_unfiltered ("Byte order is not selectable."); - show_endian (args, from_tty); - } -} - -/* Called by ``set endian little''. */ -static void -set_endian_little (args, from_tty) - char *args; - int from_tty; -{ - if (TARGET_BYTE_ORDER_SELECTABLE_P) - { - target_byte_order = LITTLE_ENDIAN; - target_byte_order_auto = 0; - } - else - { - printf_unfiltered ("Byte order is not selectable."); - show_endian (args, from_tty); - } -} - -/* Called by ``set endian auto''. */ -static void -set_endian_auto (args, from_tty) - char *args; - int from_tty; -{ - if (TARGET_BYTE_ORDER_SELECTABLE_P) - { - target_byte_order_auto = 1; - } - else - { - printf_unfiltered ("Byte order is not selectable."); - show_endian (args, from_tty); - } -} - -/* Called by ``show endian''. */ -static void -show_endian (args, from_tty) - char *args; - int from_tty; -{ - char *msg = - (TARGET_BYTE_ORDER_AUTO - ? "The target endianness is set automatically (currently %s endian)\n" - : "The target is assumed to be %s endian\n"); - printf_unfiltered (msg, (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little")); -} - -/* Set the endianness from a BFD. */ -void -set_endian_from_file (abfd) - bfd *abfd; -{ - if (TARGET_BYTE_ORDER_SELECTABLE_P) - { - int want; - - if (bfd_big_endian (abfd)) - want = BIG_ENDIAN; - else - want = LITTLE_ENDIAN; - if (TARGET_BYTE_ORDER_AUTO) - target_byte_order = want; - else if (TARGET_BYTE_ORDER != want) - warning ("%s endian file does not match %s endian target.", - want == BIG_ENDIAN ? "big" : "little", - TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); - } - else - { - if (bfd_big_endian (abfd) - ? TARGET_BYTE_ORDER != BIG_ENDIAN - : TARGET_BYTE_ORDER == BIG_ENDIAN) - warning ("%s endian file does not match %s endian target.", - bfd_big_endian (abfd) ? "big" : "little", - TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"); - } -} - -/* Functions to manipulate the architecture of the target */ - -int target_architecture_auto = 1; -extern const bfd_arch_info_type bfd_default_arch_struct; -const bfd_arch_info_type *target_architecture = &bfd_default_arch_struct; -int (*target_architecture_hook) PARAMS ((const bfd_arch_info_type *ap)); - -static void -set_arch (arch) - const bfd_arch_info_type *arch; -{ - /* FIXME: Is it compatible with gdb? */ - /* Check with the target on the setting */ - if (target_architecture_hook != NULL - && !target_architecture_hook (arch)) - printf_unfiltered ("Target does not support `%s' architecture.\n", - arch->printable_name); - else - { - target_architecture_auto = 0; - target_architecture = arch; - } -} - - -/* Called if the user enters ``set architecture'' with or without an - argument. */ -static void -set_architecture (args, from_tty) - char *args; - int from_tty; -{ - if (args == NULL) - { - printf_unfiltered ("\"set architecture\" must be followed by \"auto\" or an architecture name.\n"); - } - else if (strcmp (args, "auto") == 0) - { - target_architecture_auto = 1; - } - else - { - const bfd_arch_info_type *arch = bfd_scan_arch (args); - if (arch != NULL) - set_arch (arch); - else - printf_unfiltered ("Architecture `%s' not reconized.\n", args); - } -} - -/* Called if the user enters ``show architecture'' without an argument. */ -static void -show_architecture (args, from_tty) - char *args; - int from_tty; -{ - const char *arch; - arch = target_architecture->printable_name; - if (target_architecture_auto) - printf_filtered ("The target architecture is set automatically (currently %s)\n", arch); - else - printf_filtered ("The target architecture is assumed to be %s\n", arch); -} - -/* Called if the user enters ``info architecture'' without an argument. */ -static void -info_architecture (args, from_tty) - char *args; - int from_tty; -{ - enum bfd_architecture a; - printf_filtered ("Available architectures are:\n"); - for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++) - { - const bfd_arch_info_type *ap = bfd_lookup_arch (a, 0); - if (ap != NULL) - { - do - { - printf_filtered (" %s", ap->printable_name); - ap = ap->next; - } - while (ap != NULL); - printf_filtered ("\n"); - } - } -} - -/* Set the architecture from arch/machine */ -void -set_architecture_from_arch_mach (arch, mach) - enum bfd_architecture arch; - unsigned long mach; -{ - const bfd_arch_info_type *wanted = bfd_lookup_arch (arch, mach); - if (wanted != NULL) - set_arch (wanted); - else - fatal ("hardwired architecture/machine not reconized"); -} - - -/* Set the architecture from a BFD */ -void -set_architecture_from_file (abfd) - bfd *abfd; -{ - const bfd_arch_info_type *wanted = bfd_get_arch_info (abfd); - if (target_architecture_auto) - { - if (target_architecture_hook != NULL - && !target_architecture_hook (wanted)) - warning ("Target may not support %s architecture", - wanted->printable_name); - target_architecture = wanted; - } - else if (wanted != target_architecture) - { - warning ("%s architecture file may be incompatible with %s target.", - wanted->printable_name, - target_architecture->printable_name); - } -} - /* Functions to manipulate command line editing control variables. */ /* Number of commands to print in each call to show_commands. */ @@ -3617,7 +3346,6 @@ init_cmd_lists () setlist = NULL; unsetlist = NULL; showlist = NULL; - endianlist = NULL; sethistlist = NULL; showhistlist = NULL; unsethistlist = NULL; @@ -3668,27 +3396,6 @@ init_main () { struct cmd_list_element *c; - add_prefix_cmd ("endian", class_support, set_endian, - "Set endianness of target.", - &endianlist, "set endian ", 0, &setlist); - add_cmd ("big", class_support, set_endian_big, - "Set target as being big endian.", &endianlist); - add_cmd ("little", class_support, set_endian_little, - "Set target as being little endian.", &endianlist); - add_cmd ("auto", class_support, set_endian_auto, - "Select target endianness automatically.", &endianlist); - add_cmd ("endian", class_support, show_endian, - "Show endianness of target.", &showlist); - - add_cmd ("architecture", class_support, set_architecture, - "Set architecture of target.", &setlist); - add_alias_cmd ("processor", "architecture", class_support, 1, &setlist); - add_cmd ("architecture", class_support, show_architecture, - "Show architecture of target.", &showlist); - add_cmd ("architecture", class_support, info_architecture, - "List supported target architectures", &infolist); - - #ifdef DEFAULT_PROMPT prompt = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT)); #else |