aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog26
-rw-r--r--gdb/Makefile.in10
-rw-r--r--gdb/TODO38
-rw-r--r--gdb/arch-utils.c392
-rw-r--r--gdb/arch-utils.h16
-rw-r--r--gdb/gdbarch.c453
-rw-r--r--gdb/gdbarch.h21
-rwxr-xr-xgdb/gdbarch.sh474
-rw-r--r--gdb/i386-tdep.c1
-rw-r--r--gdb/sh-tdep.c4
-rw-r--r--gdb/sh3-rom.c3
-rw-r--r--gdb/v850-tdep.c3
12 files changed, 583 insertions, 858 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0c6d149..083c2ba 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,29 @@
+Wed Jun 7 11:34:54 2000 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * arch-utils.c (target_byte_order, target_byte_order_auto,
+ show_endian, set_endian, set_endian_big, set_endian_little,
+ set_endian_auto, set_endian_from_file, enum set_arch,
+ target_architecture_auto, set_architecture_string,
+ target_architecture_hook, target_architecture, arch_ok, set_arch,
+ set_architecture_from_arch_mach, set_architecture_from_file,
+ show_architecture, set_architecture, info_architecture,
+ set_gdbarch_from_file, initialize_current_architecture): Copy from
+ gdbarch.c. Rewrite ``set architecture'' and ``set endian''
+ commands to use enums.
+ (_initialize_gdbarch_utils): Fix name.
+ * arch-utils.h (set_architecture_from_arch_mach,
+ target_architecture_hook): Copy from gdbarch.h.
+ * gdbarch.sh: Update.
+ * gdbarch.h, gdbarch.c: Re-generate.
+
+ * TODO: Update.
+
+ * v850-tdep.c, sh3-rom.c, sh-tdep.c, i386-tdep.c: Include
+ "arch-utils.h".
+ * Makefile.in (v850-tdep.o): Specify dependencies.
+ (i386-tdep.o, sh3-rom.o, sh-tdep.o): Add arch-utils.h to
+ dependency list.
+
2000-06-06 Michael Snyder <msnyder@seadog.cygnus.com>
* configure.in: Enable autoconf to find curses.h on Solaris 2.8.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 32a1d21..0963cda 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1363,6 +1363,10 @@ v850ice.o: v850ice.c $(defs_h) $(symtab_h) $(inferior_h) $(command_h) \
$(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) $(GDBTK_CFLAGS)\
$(srcdir)/v850ice.c
+v850-tdep.o: v850-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(obstack_h) \
+ $(target_h) $(value_h) $(bfd_h) $(gdb_string_h) $(gdbcore_h) \
+ $(symfile_h) $(arch_utils_h)
+
tracepoint.o: tracepoint.c $(defs_h) $(symtab_h) $(frame_h) $(tracepoint_h) \
$(gdbtypes_h) $(expression_h) $(gdbcmd_h) $(value_h) target.h \
language.h gdb_string.h $(readline_headers) $(remote_h)
@@ -1401,7 +1405,7 @@ i386gnu-nat.o: gnu-nat.h
i386-tdep.o: i386-tdep.c $(defs_h) gdb_string.h $(frame_h) \
$(inferior_h) $(gdbcore_h) target.h $(floatformat_h) \
- $(symtab_h) $(gdbcmd_h) $(command_h)
+ $(symtab_h) $(gdbcmd_h) $(command_h) $(arch_utils_h)
i386aix-nat.o: i386aix-nat.c $(defs_h) $(frame_h) $(inferior_h) \
language.h $(gdbcore_h) $(floatformat_h) target.h
@@ -1790,10 +1794,10 @@ serial.o: serial.c $(defs_h) serial.h gdb_string.h
sh-tdep.o: sh-tdep.c $(bfd_h) $(dis-asm_h) \
$(srcdir)/../opcodes/sh-opc.h $(defs_h) $(expression_h) $(frame_h) \
- $(gdbcmd_h) $(gdbtypes_h) $(symtab_h) $(value_h)
+ $(gdbcmd_h) $(gdbtypes_h) $(symtab_h) $(value_h) $(arch_utils_h)
sh3-rom.o: sh3-rom.c monitor.h $(bfd_h) gdb_wait.h $(defs_h) $(gdbcmd_h) \
- $(inferior_h) target.h serial.h terminal.h
+ $(inferior_h) target.h serial.h terminal.h $(arch_utils_h)
mon960-rom.o: mon960-rom.c monitor.h $(bfd_h) gdb_wait.h $(defs_h) $(gdbcmd_h) \
$(inferior_h) target.h serial.h terminal.h
diff --git a/gdb/TODO b/gdb/TODO
index bef7155..e5398c9 100644
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -297,6 +297,23 @@ http://sourceware.cygnus.com/ml/gdb/2000-q1/msg00845.html
--
+Change the parameter ``char *list[]'' (etc) to ``const char (*)[]'' so
+that dynamic lists from things like gdbarch_printable_names() can be
+passed.
+
+--
+
+The ``maintenance deprecate set endian big'' command doesn't notice
+that it is deprecating ``set endian'' and not ``set endian big'' (big
+is implemented using an enum). Is anyone going to notice this?
+
+--
+
+When tab expanding something like ``set arch<tab>'' ignore the
+deprecated ``set archdebug'' and expand to ``set architecture''.
+
+--
+
New Features and Fixes
======================
@@ -334,6 +351,9 @@ Convert GDB build process to AUTOMAKE.
See also sub-directory configure below.
+The current convention is (kind of) to use $(<header>_h) in all
+dependency lists. It isn't done in a consistent way.
+
--
Cleanup configury support for optional sub-directories.
@@ -425,6 +445,16 @@ http://sourceware.cygnus.com/ml/gdb/2000-q1/msg00034.html
--
+Change the (char *list[]) to (const char (*)[]) so that dynamic lists can
+be passed.
+
+--
+
+When tab expanding something like ``set arch<tab>'' ignore the
+deprecated ``set archdebug'' and expand to ``set architecture''.
+
+--
+
Replace the code that uses the host FPU with an emulator of the target
FPU.
@@ -884,14 +914,6 @@ symtab file.
--
-Fix ``set architecture <tab>''
-
-This command should expand to a list of all supported architectures.
-At present ``info architecture'' needs to be used. That is simply
-wrong. It involves the use of add_set_enum_cmd().
-
---
-
Fix target_signal_from_host() etc.
The name is wrong for starters. ``target_signal'' should probably be
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 1cd8652..d604bd4 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -223,11 +223,399 @@ generic_register_convertible_not (num)
return 0;
}
+
+/* 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
+#if !TARGET_BYTE_ORDER_SELECTABLE_P
+#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
+#endif
+#ifndef TARGET_BYTE_ORDER_DEFAULT
+#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN /* arbitrary */
+#endif
+int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
+int target_byte_order_auto = 1;
+
+static char endian_big[] = "big";
+static char endian_little[] = "little";
+static char endian_auto[] = "auto";
+static char *endian_enum[] =
+{
+ endian_big,
+ endian_little,
+ endian_auto,
+ NULL,
+};
+static char *set_endian_string;
+
+/* Called by ``show endian''. */
+
+static void
+show_endian (char *args, int from_tty)
+{
+ if (TARGET_BYTE_ORDER_AUTO)
+ printf_unfiltered ("The target endianness is set automatically (currently %s endian)\n",
+ (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"));
+ else
+ printf_unfiltered ("The target is assumed to be %s endian\n",
+ (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"));
+}
+
+static void
+set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
+{
+ if (!TARGET_BYTE_ORDER_SELECTABLE_P)
+ {
+ printf_unfiltered ("Byte order is not selectable.");
+ }
+ else if (set_endian_string == endian_auto)
+ {
+ target_byte_order_auto = 1;
+ }
+ else if (set_endian_string == endian_little)
+ {
+ target_byte_order = LITTLE_ENDIAN;
+ target_byte_order_auto = 0;
+ if (GDB_MULTI_ARCH)
+ {
+ struct gdbarch_info info;
+ memset (&info, 0, sizeof info);
+ info.byte_order = LITTLE_ENDIAN;
+ gdbarch_update (info);
+ }
+ }
+ else if (set_endian_string == endian_big)
+ {
+ target_byte_order = BIG_ENDIAN;
+ target_byte_order_auto = 0;
+ if (GDB_MULTI_ARCH)
+ {
+ struct gdbarch_info info;
+ memset (&info, 0, sizeof info);
+ info.byte_order = BIG_ENDIAN;
+ gdbarch_update (info);
+ }
+ }
+ else
+ internal_error ("set_endian: bad value");
+ show_endian (NULL, from_tty);
+}
+
+/* Set the endianness from a BFD. */
+
+static void
+set_endian_from_file (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 */
+
+enum set_arch { set_arch_auto, set_arch_manual };
+
+int target_architecture_auto = 1;
+
+char *set_architecture_string;
+
+/* Old way of changing the current architecture. */
+
+extern const struct bfd_arch_info bfd_default_arch_struct;
+const struct bfd_arch_info *target_architecture = &bfd_default_arch_struct;
+int (*target_architecture_hook) (const struct bfd_arch_info *ap);
+
+static int
+arch_ok (const struct bfd_arch_info *arch)
+{
+ if (GDB_MULTI_ARCH)
+ internal_error ("arch_ok: not multi-arched");
+ /* Should be performing the more basic check that the binary is
+ compatible with GDB. */
+ /* Check with the target that the architecture is valid. */
+ return (target_architecture_hook == NULL
+ || target_architecture_hook (arch));
+}
+
+static void
+set_arch (const struct bfd_arch_info *arch,
+ enum set_arch type)
+{
+ if (GDB_MULTI_ARCH)
+ internal_error ("set_arch: not multi-arched");
+ switch (type)
+ {
+ case set_arch_auto:
+ if (!arch_ok (arch))
+ warning ("Target may not support %s architecture",
+ arch->printable_name);
+ target_architecture = arch;
+ break;
+ case set_arch_manual:
+ if (!arch_ok (arch))
+ {
+ printf_unfiltered ("Target does not support `%s' architecture.\n",
+ arch->printable_name);
+ }
+ else
+ {
+ target_architecture_auto = 0;
+ target_architecture = arch;
+ }
+ break;
+ }
+ if (gdbarch_debug)
+ gdbarch_dump ();
+}
+
+/* Set the architecture from arch/machine (deprecated) */
+
+void
+set_architecture_from_arch_mach (enum bfd_architecture arch,
+ unsigned long mach)
+{
+ const struct bfd_arch_info *wanted = bfd_lookup_arch (arch, mach);
+ if (GDB_MULTI_ARCH)
+ internal_error ("set_architecture_from_arch_mach: not multi-arched");
+ if (wanted != NULL)
+ set_arch (wanted, set_arch_manual);
+ else
+ internal_error ("gdbarch: hardwired architecture/machine not reconized");
+}
+
+/* Set the architecture from a BFD (deprecated) */
+
+static void
+set_architecture_from_file (bfd *abfd)
+{
+ const struct bfd_arch_info *wanted = bfd_get_arch_info (abfd);
+ if (GDB_MULTI_ARCH)
+ internal_error ("set_architecture_from_file: not multi-arched");
+ if (target_architecture_auto)
+ {
+ set_arch (wanted, set_arch_auto);
+ }
+ else if (wanted != target_architecture)
+ {
+ warning ("%s architecture file may be incompatible with %s target.",
+ wanted->printable_name,
+ target_architecture->printable_name);
+ }
+}
+
+
+/* Called if the user enters ``show architecture'' without an
+ argument. */
+
+static void
+show_architecture (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 (char *ignore_args, int from_tty, struct cmd_list_element *c)
+{
+ if (strcmp (set_architecture_string, "auto") == 0)
+ {
+ target_architecture_auto = 1;
+ }
+ else if (GDB_MULTI_ARCH)
+ {
+ struct gdbarch_info info;
+ memset (&info, 0, sizeof info);
+ info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
+ if (info.bfd_arch_info == NULL)
+ internal_error ("set_architecture: bfd_scan_arch failed");
+ if (gdbarch_update (info))
+ target_architecture_auto = 0;
+ else
+ printf_unfiltered ("Architecture `%s' not reconized.\n",
+ set_architecture_string);
+ }
+ else
+ {
+ const struct bfd_arch_info *arch
+ = bfd_scan_arch (set_architecture_string);
+ if (arch == NULL)
+ internal_error ("set_architecture: bfd_scan_arch failed");
+ set_arch (arch, set_arch_manual);
+ }
+ show_architecture (NULL, from_tty);
+}
+
+/* Called if the user enters ``info architecture'' without an argument. */
+
+static void
+info_architecture (char *args, int from_tty)
+{
+ printf_filtered ("Available architectures are:\n");
+ if (GDB_MULTI_ARCH)
+ {
+ const char **arches = gdbarch_printable_names ();
+ const char **arch;
+ for (arch = arches; *arch != NULL; arch++)
+ {
+ printf_filtered (" %s", *arch);
+ }
+ free (arches);
+ }
+ else
+ {
+ enum bfd_architecture a;
+ for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++)
+ {
+ const struct bfd_arch_info *ap;
+ for (ap = bfd_lookup_arch (a, 0);
+ ap != NULL;
+ ap = ap->next)
+ {
+ printf_filtered (" %s", ap->printable_name);
+ ap = ap->next;
+ }
+ }
+ }
+ printf_filtered ("\n");
+}
+
+/* Set the dynamic target-system-dependant parameters (architecture,
+ byte-order) using information found in the BFD */
+
+void
+set_gdbarch_from_file (abfd)
+ bfd *abfd;
+{
+ if (GDB_MULTI_ARCH)
+ {
+ struct gdbarch_info info;
+ memset (&info, 0, sizeof info);
+ info.abfd = abfd;
+ gdbarch_update (info);
+ }
+ else
+ {
+ set_architecture_from_file (abfd);
+ set_endian_from_file (abfd);
+ }
+}
+
+/* Initialize the current architecture. Update the ``set
+ architecture'' command so that it specifies a list of valid
+ architectures. */
+
+void
+initialize_current_architecture (void)
+{
+ const char **arches = gdbarch_printable_names ();
+ const char *chosen = arches[0];
+
+ if (GDB_MULTI_ARCH)
+ {
+ const char **arch;
+ struct gdbarch_info info;
+ for (arch = arches; *arch != NULL; arch++)
+ {
+ /* Choose the first architecture alphabetically. */
+ if (strcmp (*arch, chosen) < 0)
+ chosen = *arch;
+ }
+ if (chosen == NULL)
+ internal_error ("initialize_current_architecture: No arch");
+ memset (&info, 0, sizeof info);
+ info.bfd_arch_info = bfd_scan_arch (chosen);
+ if (info.bfd_arch_info == NULL)
+ internal_error ("initialize_current_architecture: Arch not found");
+ gdbarch_update (info);
+ }
+
+ /* Create the ``set architecture'' command prepending ``auto''. */
+ {
+ struct cmd_list_element *c;
+ /* Append ``auto''. */
+ int nr;
+ for (nr = 0; arches[nr] != NULL; nr++);
+ arches = xrealloc (arches, sizeof (char*) * (nr + 2));
+ arches[nr + 0] = "auto";
+ arches[nr + 1] = NULL;
+ /* FIXME: add_set_enum_cmd() uses an array of ``char *'' instead
+ of ``const char *''. We just happen to know that the casts are
+ safe. */
+ c = add_set_enum_cmd ("architecture", class_support,
+ (char **) arches, (char **) &set_architecture_string,
+ "Set architecture of target.",
+ &setlist);
+ c->function.sfunc = set_architecture;
+ add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);
+ /* Don't use set_from_show - need to print both auto/manual and
+ current setting. */
+ add_cmd ("architecture", class_support, show_architecture,
+ "Show the current target architecture", &showlist);
+ c = add_cmd ("architecture", class_support, info_architecture,
+ "List supported target architectures", &infolist);
+ deprecate_cmd (c, "set architecture");
+ }
+}
+
+
/* */
-extern initialize_file_ftype __initialize_gdbarch_utils;
+extern initialize_file_ftype _initialize_gdbarch_utils;
void
-__initialize_gdbarch_utils (void)
+_initialize_gdbarch_utils (void)
{
+ struct cmd_list_element *c;
+ c = add_set_enum_cmd ("endian", class_support,
+ endian_enum, &set_endian_string,
+ "Set endianness of target.",
+ &setlist);
+ c->function.sfunc = set_endian;
+ /* Don't use set_from_show - need to print both auto/manual and
+ current setting. */
+ add_cmd ("endian", class_support, show_endian,
+ "Show the current byte-order", &showlist);
}
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 86c6054..1a147da 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -72,4 +72,20 @@ extern const struct floatformat *default_double_format (struct gdbarch *gdbarch)
extern int frame_num_args_unknown (struct frame_info *fi);
+/* The following DEPRECATED interfaces are for pre- multi-arch legacy
+ targets. */
+
+/* DEPRECATED pre- multi-arch interface. Explicitly set the dynamic
+ target-system-dependant parameters based on bfd_architecture and
+ machine. This function is deprecated, use
+ set_gdbarch_from_arch_machine(). */
+
+extern void set_architecture_from_arch_mach (enum bfd_architecture, unsigned long);
+
+/* DEPRECATED pre- multi-arch interface. 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) (const struct bfd_arch_info *);
+
#endif
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 18cc181..966db4b 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -3069,6 +3069,50 @@ struct gdbarch_init_registration
static struct gdbarch_init_registration *gdbarch_init_registrary = NULL;
+static void
+append_name (const char ***buf, int *nr, const char *name)
+{
+ *buf = xrealloc (*buf, sizeof (char**) * (*nr + 1));
+ (*buf)[*nr] = name;
+ *nr += 1;
+}
+
+const char **
+gdbarch_printable_names (void)
+{
+ if (GDB_MULTI_ARCH)
+ {
+ /* Accumulate a list of names based on the registed list of
+ architectures. */
+ enum bfd_architecture a;
+ int nr_arches = 0;
+ const char **arches = NULL;
+ struct gdbarch_init_registration *rego;
+ for (rego = gdbarch_init_registrary;
+ rego != NULL;
+ rego = rego->next)
+ {
+ const struct bfd_arch_info *ap;
+ ap = bfd_lookup_arch (rego->bfd_architecture, 0);
+ if (ap == NULL)
+ internal_error ("gdbarch_architecture_names: multi-arch unknown");
+ do
+ {
+ append_name (&arches, &nr_arches, ap->printable_name);
+ ap = ap->next;
+ }
+ while (ap != NULL);
+ }
+ append_name (&arches, &nr_arches, NULL);
+ return arches;
+ }
+ else
+ /* Just return all the architectures that BFD knows. Assume that
+ the legacy architecture framework supports them. */
+ return bfd_arch_list ();
+}
+
+
void
register_gdbarch_init (enum bfd_architecture bfd_architecture,
gdbarch_init_ftype *init)
@@ -3102,7 +3146,6 @@ register_gdbarch_init (enum bfd_architecture bfd_architecture,
(*curr)->arches = NULL;
(*curr)->next = NULL;
}
-
/* Look for an architecture using gdbarch_info. Base search on only
@@ -3276,343 +3319,6 @@ gdbarch_update (struct gdbarch_info info)
-/* 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
-#if !TARGET_BYTE_ORDER_SELECTABLE_P
-#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
-#endif
-#ifndef TARGET_BYTE_ORDER_DEFAULT
-#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN /* arbitrary */
-#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 (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 (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 (char *args, int from_tty)
-{
- if (TARGET_BYTE_ORDER_SELECTABLE_P)
- {
- target_byte_order = BIG_ENDIAN;
- target_byte_order_auto = 0;
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.byte_order = BIG_ENDIAN;
- gdbarch_update (info);
- }
- }
- else
- {
- printf_unfiltered ("Byte order is not selectable.");
- show_endian (args, from_tty);
- }
-}
-
-/* Called by ``set endian little''. */
-static void
-set_endian_little (char *args, int from_tty)
-{
- if (TARGET_BYTE_ORDER_SELECTABLE_P)
- {
- target_byte_order = LITTLE_ENDIAN;
- target_byte_order_auto = 0;
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.byte_order = LITTLE_ENDIAN;
- gdbarch_update (info);
- }
- }
- else
- {
- printf_unfiltered ("Byte order is not selectable.");
- show_endian (args, from_tty);
- }
-}
-
-/* Called by ``set endian auto''. */
-static void
-set_endian_auto (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 (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 */
-
-enum set_arch { set_arch_auto, set_arch_manual };
-
-int target_architecture_auto = 1;
-extern const struct bfd_arch_info bfd_default_arch_struct;
-const struct bfd_arch_info *target_architecture = &bfd_default_arch_struct;
-int (*target_architecture_hook) (const struct bfd_arch_info *ap);
-
-static void show_endian (char *, int);
-static void set_endian (char *, int);
-static void set_endian_big (char *, int);
-static void set_endian_little (char *, int);
-static void set_endian_auto (char *, int);
-static void set_endian_from_file (bfd *);
-static int arch_ok (const struct bfd_arch_info *arch);
-static void set_arch (const struct bfd_arch_info *arch, enum set_arch type);
-static void show_architecture (char *, int);
-static void set_architecture (char *, int);
-static void info_architecture (char *, int);
-static void set_architecture_from_file (bfd *);
-
-/* Do the real work of changing the current architecture */
-
-static int
-arch_ok (const struct bfd_arch_info *arch)
-{
- /* Should be performing the more basic check that the binary is
- compatible with GDB. */
- /* Check with the target that the architecture is valid. */
- return (target_architecture_hook == NULL
- || target_architecture_hook (arch));
-}
-
-static void
-set_arch (const struct bfd_arch_info *arch,
- enum set_arch type)
-{
- switch (type)
- {
- case set_arch_auto:
- if (!arch_ok (arch))
- warning ("Target may not support %s architecture",
- arch->printable_name);
- target_architecture = arch;
- break;
- case set_arch_manual:
- if (!arch_ok (arch))
- {
- printf_unfiltered ("Target does not support `%s' architecture.\n",
- arch->printable_name);
- }
- else
- {
- target_architecture_auto = 0;
- target_architecture = arch;
- }
- break;
- }
- if (gdbarch_debug)
- gdbarch_dump ();
-}
-
-/* Called if the user enters ``show architecture'' without an argument. */
-static void
-show_architecture (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 (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 if (GDB_MULTI_ARCH)
- {
- const struct bfd_arch_info *arch = bfd_scan_arch (args);
- if (arch == NULL)
- printf_unfiltered ("Architecture `%s' not reconized.\n", args);
- else
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.bfd_arch_info = arch;
- if (gdbarch_update (info))
- target_architecture_auto = 0;
- else
- printf_unfiltered ("Architecture `%s' not reconized.\n", args);
- }
- }
- else
- {
- const struct bfd_arch_info *arch = bfd_scan_arch (args);
- if (arch != NULL)
- set_arch (arch, set_arch_manual);
- else
- printf_unfiltered ("Architecture `%s' not reconized.\n", args);
- }
-}
-
-/* Called if the user enters ``info architecture'' without an argument. */
-static void
-info_architecture (char *args, int from_tty)
-{
- enum bfd_architecture a;
- if (GDB_MULTI_ARCH)
- {
- if (gdbarch_init_registrary != NULL)
- {
- struct gdbarch_init_registration *rego;
- printf_filtered ("Available architectures are:\n");
- for (rego = gdbarch_init_registrary;
- rego != NULL;
- rego = rego->next)
- {
- const struct bfd_arch_info *ap;
- ap = bfd_lookup_arch (rego->bfd_architecture, 0);
- if (ap != NULL)
- {
- do
- {
- printf_filtered (" %s", ap->printable_name);
- ap = ap->next;
- }
- while (ap != NULL);
- printf_filtered ("\n");
- }
- }
- }
- else
- {
- printf_filtered ("There are no available architectures.\n");
- }
- return;
- }
- printf_filtered ("Available architectures are:\n");
- for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++)
- {
- const struct bfd_arch_info *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 struct bfd_arch_info *wanted = bfd_lookup_arch (arch, mach);
- if (wanted != NULL)
- set_arch (wanted, set_arch_manual);
- else
- internal_error ("gdbarch: hardwired architecture/machine not reconized");
-}
-
-/* Set the architecture from a BFD */
-static void
-set_architecture_from_file (bfd *abfd)
-{
- const struct bfd_arch_info *wanted = bfd_get_arch_info (abfd);
- if (target_architecture_auto)
- {
- set_arch (wanted, set_arch_auto);
- }
- 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. */
@@ -3620,82 +3326,13 @@ int (*tm_print_insn) (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;
-{
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.abfd = abfd;
- gdbarch_update (info);
- return;
- }
- set_architecture_from_file (abfd);
- set_endian_from_file (abfd);
-}
-
-
-/* Initialize the current architecture. */
-void
-initialize_current_architecture ()
-{
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_init_registration *rego;
- const struct bfd_arch_info *chosen = NULL;
- for (rego = gdbarch_init_registrary; rego != NULL; rego = rego->next)
- {
- const struct bfd_arch_info *ap
- = bfd_lookup_arch (rego->bfd_architecture, 0);
-
- /* Choose the first architecture alphabetically. */
- if (chosen == NULL
- || strcmp (ap->printable_name, chosen->printable_name) < 0)
- chosen = ap;
- }
-
- if (chosen != NULL)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.bfd_arch_info = chosen;
- gdbarch_update (info);
- }
- }
-}
-
extern void _initialize_gdbarch (void);
+
void
_initialize_gdbarch ()
{
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);
-
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;
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index f0453bf..f3f1589 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1212,6 +1212,14 @@ typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct g
extern void register_gdbarch_init (enum bfd_architecture architecture, gdbarch_init_ftype *);
+/* Return a freshly allocated, NULL terminated, array of the valid
+ architecture names. Since architectures are registered during the
+ _initialize phase this function only returns useful information
+ once initialization has been completed. */
+
+extern const char **gdbarch_printable_names (void);
+
+
/* Helper function. Search the list of ARCHES for a GDBARCH that
matches the information provided by INFO. */
@@ -1342,13 +1350,6 @@ extern const struct bfd_arch_info *target_architecture;
#define TARGET_ARCHITECTURE (target_architecture + 0)
#endif
-/* 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) (const struct bfd_arch_info *);
-
-
/* The target-system-dependant disassembler is semi-dynamic */
@@ -1397,12 +1398,6 @@ extern disassemble_info tm_print_insn_info;
extern void set_gdbarch_from_file (bfd *);
-/* Explicitly set the dynamic target-system-dependant parameters based
- on bfd_architecture and machine. */
-
-extern void set_architecture_from_arch_mach (enum bfd_architecture, unsigned long);
-
-
/* Initialize the current architecture to the "first" one we find on
our list. */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index dcf3230..2cc2ee2 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -702,6 +702,14 @@ typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct g
extern void register_gdbarch_init (enum bfd_architecture architecture, gdbarch_init_ftype *);
+/* Return a freshly allocated, NULL terminated, array of the valid
+ architecture names. Since architectures are registered during the
+ _initialize phase this function only returns useful information
+ once initialization has been completed. */
+
+extern const char **gdbarch_printable_names (void);
+
+
/* Helper function. Search the list of ARCHES for a GDBARCH that
matches the information provided by INFO. */
@@ -832,13 +840,6 @@ extern const struct bfd_arch_info *target_architecture;
#define TARGET_ARCHITECTURE (target_architecture + 0)
#endif
-/* 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) (const struct bfd_arch_info *);
-
-
/* The target-system-dependant disassembler is semi-dynamic */
@@ -887,12 +888,6 @@ extern disassemble_info tm_print_insn_info;
extern void set_gdbarch_from_file (bfd *);
-/* Explicitly set the dynamic target-system-dependant parameters based
- on bfd_architecture and machine. */
-
-extern void set_architecture_from_arch_mach (enum bfd_architecture, unsigned long);
-
-
/* Initialize the current architecture to the "first" one we find on
our list. */
@@ -1516,6 +1511,50 @@ struct gdbarch_init_registration
static struct gdbarch_init_registration *gdbarch_init_registrary = NULL;
+static void
+append_name (const char ***buf, int *nr, const char *name)
+{
+ *buf = xrealloc (*buf, sizeof (char**) * (*nr + 1));
+ (*buf)[*nr] = name;
+ *nr += 1;
+}
+
+const char **
+gdbarch_printable_names (void)
+{
+ if (GDB_MULTI_ARCH)
+ {
+ /* Accumulate a list of names based on the registed list of
+ architectures. */
+ enum bfd_architecture a;
+ int nr_arches = 0;
+ const char **arches = NULL;
+ struct gdbarch_init_registration *rego;
+ for (rego = gdbarch_init_registrary;
+ rego != NULL;
+ rego = rego->next)
+ {
+ const struct bfd_arch_info *ap;
+ ap = bfd_lookup_arch (rego->bfd_architecture, 0);
+ if (ap == NULL)
+ internal_error ("gdbarch_architecture_names: multi-arch unknown");
+ do
+ {
+ append_name (&arches, &nr_arches, ap->printable_name);
+ ap = ap->next;
+ }
+ while (ap != NULL);
+ }
+ append_name (&arches, &nr_arches, NULL);
+ return arches;
+ }
+ else
+ /* Just return all the architectures that BFD knows. Assume that
+ the legacy architecture framework supports them. */
+ return bfd_arch_list ();
+}
+
+
void
register_gdbarch_init (enum bfd_architecture bfd_architecture,
gdbarch_init_ftype *init)
@@ -1549,7 +1588,6 @@ register_gdbarch_init (enum bfd_architecture bfd_architecture,
(*curr)->arches = NULL;
(*curr)->next = NULL;
}
-
/* Look for an architecture using gdbarch_info. Base search on only
@@ -1723,343 +1761,6 @@ gdbarch_update (struct gdbarch_info info)
-/* 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
-#if !TARGET_BYTE_ORDER_SELECTABLE_P
-#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
-#endif
-#ifndef TARGET_BYTE_ORDER_DEFAULT
-#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN /* arbitrary */
-#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 (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 (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 (char *args, int from_tty)
-{
- if (TARGET_BYTE_ORDER_SELECTABLE_P)
- {
- target_byte_order = BIG_ENDIAN;
- target_byte_order_auto = 0;
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.byte_order = BIG_ENDIAN;
- gdbarch_update (info);
- }
- }
- else
- {
- printf_unfiltered ("Byte order is not selectable.");
- show_endian (args, from_tty);
- }
-}
-
-/* Called by \`\`set endian little''. */
-static void
-set_endian_little (char *args, int from_tty)
-{
- if (TARGET_BYTE_ORDER_SELECTABLE_P)
- {
- target_byte_order = LITTLE_ENDIAN;
- target_byte_order_auto = 0;
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.byte_order = LITTLE_ENDIAN;
- gdbarch_update (info);
- }
- }
- else
- {
- printf_unfiltered ("Byte order is not selectable.");
- show_endian (args, from_tty);
- }
-}
-
-/* Called by \`\`set endian auto''. */
-static void
-set_endian_auto (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 (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 */
-
-enum set_arch { set_arch_auto, set_arch_manual };
-
-int target_architecture_auto = 1;
-extern const struct bfd_arch_info bfd_default_arch_struct;
-const struct bfd_arch_info *target_architecture = &bfd_default_arch_struct;
-int (*target_architecture_hook) (const struct bfd_arch_info *ap);
-
-static void show_endian (char *, int);
-static void set_endian (char *, int);
-static void set_endian_big (char *, int);
-static void set_endian_little (char *, int);
-static void set_endian_auto (char *, int);
-static void set_endian_from_file (bfd *);
-static int arch_ok (const struct bfd_arch_info *arch);
-static void set_arch (const struct bfd_arch_info *arch, enum set_arch type);
-static void show_architecture (char *, int);
-static void set_architecture (char *, int);
-static void info_architecture (char *, int);
-static void set_architecture_from_file (bfd *);
-
-/* Do the real work of changing the current architecture */
-
-static int
-arch_ok (const struct bfd_arch_info *arch)
-{
- /* Should be performing the more basic check that the binary is
- compatible with GDB. */
- /* Check with the target that the architecture is valid. */
- return (target_architecture_hook == NULL
- || target_architecture_hook (arch));
-}
-
-static void
-set_arch (const struct bfd_arch_info *arch,
- enum set_arch type)
-{
- switch (type)
- {
- case set_arch_auto:
- if (!arch_ok (arch))
- warning ("Target may not support %s architecture",
- arch->printable_name);
- target_architecture = arch;
- break;
- case set_arch_manual:
- if (!arch_ok (arch))
- {
- printf_unfiltered ("Target does not support \`%s' architecture.\n",
- arch->printable_name);
- }
- else
- {
- target_architecture_auto = 0;
- target_architecture = arch;
- }
- break;
- }
- if (gdbarch_debug)
- gdbarch_dump ();
-}
-
-/* Called if the user enters \`\`show architecture'' without an argument. */
-static void
-show_architecture (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 (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 if (GDB_MULTI_ARCH)
- {
- const struct bfd_arch_info *arch = bfd_scan_arch (args);
- if (arch == NULL)
- printf_unfiltered ("Architecture \`%s' not reconized.\n", args);
- else
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.bfd_arch_info = arch;
- if (gdbarch_update (info))
- target_architecture_auto = 0;
- else
- printf_unfiltered ("Architecture \`%s' not reconized.\n", args);
- }
- }
- else
- {
- const struct bfd_arch_info *arch = bfd_scan_arch (args);
- if (arch != NULL)
- set_arch (arch, set_arch_manual);
- else
- printf_unfiltered ("Architecture \`%s' not reconized.\n", args);
- }
-}
-
-/* Called if the user enters \`\`info architecture'' without an argument. */
-static void
-info_architecture (char *args, int from_tty)
-{
- enum bfd_architecture a;
- if (GDB_MULTI_ARCH)
- {
- if (gdbarch_init_registrary != NULL)
- {
- struct gdbarch_init_registration *rego;
- printf_filtered ("Available architectures are:\n");
- for (rego = gdbarch_init_registrary;
- rego != NULL;
- rego = rego->next)
- {
- const struct bfd_arch_info *ap;
- ap = bfd_lookup_arch (rego->bfd_architecture, 0);
- if (ap != NULL)
- {
- do
- {
- printf_filtered (" %s", ap->printable_name);
- ap = ap->next;
- }
- while (ap != NULL);
- printf_filtered ("\n");
- }
- }
- }
- else
- {
- printf_filtered ("There are no available architectures.\n");
- }
- return;
- }
- printf_filtered ("Available architectures are:\n");
- for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++)
- {
- const struct bfd_arch_info *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 struct bfd_arch_info *wanted = bfd_lookup_arch (arch, mach);
- if (wanted != NULL)
- set_arch (wanted, set_arch_manual);
- else
- internal_error ("gdbarch: hardwired architecture/machine not reconized");
-}
-
-/* Set the architecture from a BFD */
-static void
-set_architecture_from_file (bfd *abfd)
-{
- const struct bfd_arch_info *wanted = bfd_get_arch_info (abfd);
- if (target_architecture_auto)
- {
- set_arch (wanted, set_arch_auto);
- }
- 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. */
@@ -2067,82 +1768,13 @@ int (*tm_print_insn) (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;
-{
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.abfd = abfd;
- gdbarch_update (info);
- return;
- }
- set_architecture_from_file (abfd);
- set_endian_from_file (abfd);
-}
-
-
-/* Initialize the current architecture. */
-void
-initialize_current_architecture ()
-{
- if (GDB_MULTI_ARCH)
- {
- struct gdbarch_init_registration *rego;
- const struct bfd_arch_info *chosen = NULL;
- for (rego = gdbarch_init_registrary; rego != NULL; rego = rego->next)
- {
- const struct bfd_arch_info *ap
- = bfd_lookup_arch (rego->bfd_architecture, 0);
-
- /* Choose the first architecture alphabetically. */
- if (chosen == NULL
- || strcmp (ap->printable_name, chosen->printable_name) < 0)
- chosen = ap;
- }
-
- if (chosen != NULL)
- {
- struct gdbarch_info info;
- memset (&info, 0, sizeof info);
- info.bfd_arch_info = chosen;
- gdbarch_update (info);
- }
- }
-}
-
extern void _initialize_gdbarch (void);
+
void
_initialize_gdbarch ()
{
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);
-
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;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index e2ebffa..63f2ba4 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -29,6 +29,7 @@
#include "symtab.h"
#include "gdbcmd.h"
#include "command.h"
+#include "arch-utils.h"
static long i386_get_frame_setup (CORE_ADDR);
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 941e13f..d677725 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1,5 +1,6 @@
/* Target-dependent code for Hitachi Super-H, for GDB.
- Copyright 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 2000 Free Software
+ Foundation, Inc.
This file is part of GDB.
@@ -35,6 +36,7 @@
#include "dis-asm.h"
#include "inferior.h" /* for BEFORE_TEXT_END etc. */
#include "gdb_string.h"
+#include "arch-utils.h"
/* A set of original names, to be used when restoring back to generic
registers from a specific set. */
diff --git a/gdb/sh3-rom.c b/gdb/sh3-rom.c
index b76e8ca..030452c 100644
--- a/gdb/sh3-rom.c
+++ b/gdb/sh3-rom.c
@@ -1,5 +1,5 @@
/* Remote target glue for the Hitachi SH-3 ROM monitor.
- Copyright 1995, 1996 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 2000 Free Software Foundation, Inc.
This file is part of GDB.
@@ -24,6 +24,7 @@
#include "monitor.h"
#include "serial.h"
#include "srec.h"
+#include "arch-utils.h"
static serial_t parallel;
static int parallel_in_use;
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 0501760..41a60d3 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -1,5 +1,5 @@
/* Target-dependent code for the NEC V850 for GDB, the GNU debugger.
- Copyright 1996, Free Software Foundation, Inc.
+ Copyright 1996, 2000 Free Software Foundation, Inc.
This file is part of GDB.
@@ -28,6 +28,7 @@
#include "gdb_string.h"
#include "gdbcore.h"
#include "symfile.h"
+#include "arch-utils.h"
static char *v850_generic_reg_names[] = REGISTER_NAMES;