#include "symfile.h" /* for overlay functions */
#endif
+#include "version.h"
+
#include "floatformat.h"
/* Convenience macro for allocting typesafe memory. */
/* Helper functions for INNER_THAN */
int
-core_addr_lessthan (lhs, rhs)
- CORE_ADDR lhs;
- CORE_ADDR rhs;
+core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs)
{
return (lhs < rhs);
}
int
-core_addr_greaterthan (lhs, rhs)
- CORE_ADDR lhs;
- CORE_ADDR rhs;
+core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs)
{
return (lhs > rhs);
}
/* Misc helper functions for targets. */
int
-frame_num_args_unknown (fi)
- struct frame_info *fi;
+frame_num_args_unknown (struct frame_info *fi)
{
return -1;
}
int
-generic_register_convertible_not (num)
- int num;
+generic_register_convertible_not (int num)
{
return 0;
}
+int
+default_register_sim_regno (int num)
+{
+ return num;
+}
+
+
+CORE_ADDR
+default_convert_from_func_ptr_addr (CORE_ADDR addr)
+{
+ return addr;
+}
+
+int
+no_op_reg_to_regnum (int reg)
+{
+ return reg;
+}
+
+/* For use by frame_args_address and frame_locals_address. */
+CORE_ADDR
+default_frame_address (struct frame_info *fi)
+{
+ return fi->frame;
+}
+
/* Functions to manipulate the endianness of the target. */
#ifdef TARGET_BYTE_ORDER_SELECTABLE
#ifndef TARGET_BYTE_ORDER_DEFAULT
#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN /* arbitrary */
#endif
+/* ``target_byte_order'' is only used when non- multi-arch.
+ Multi-arch targets obtain the current byte order using
+ TARGET_BYTE_ORDER which is controlled by gdbarch.*. */
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[] =
+static const char endian_big[] = "big";
+static const char endian_little[] = "little";
+static const char endian_auto[] = "auto";
+static const char *endian_enum[] =
{
endian_big,
endian_little,
endian_auto,
NULL,
};
-static char *set_endian_string;
+static const char *set_endian_string;
/* Called by ``show endian''. */
}
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);
+ if (! gdbarch_update_p (info))
+ {
+ printf_unfiltered ("Little endian target not supported by GDB\n");
+ }
+ }
+ else
+ {
+ target_byte_order = LITTLE_ENDIAN;
}
}
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);
+ if (! gdbarch_update_p (info))
+ {
+ printf_unfiltered ("Big endian target not supported by GDB\n");
+ }
+ }
+ else
+ {
+ target_byte_order = BIG_ENDIAN;
}
}
else
static void
set_endian_from_file (bfd *abfd)
{
+ if (GDB_MULTI_ARCH)
+ internal_error ("set_endian_from_file: not for multi-arch");
if (TARGET_BYTE_ORDER_SELECTABLE_P)
{
int want;
int target_architecture_auto = 1;
-char *set_architecture_string;
+const char *set_architecture_string;
/* Old way of changing the current architecture. */
break;
}
if (gdbarch_debug)
- gdbarch_dump ();
+ gdbarch_dump (current_gdbarch, gdb_stdlog);
}
/* Set the architecture from arch/machine (deprecated) */
if (wanted != NULL)
set_arch (wanted, set_arch_manual);
else
- internal_error ("gdbarch: hardwired architecture/machine not reconized");
+ internal_error ("gdbarch: hardwired architecture/machine not recognized");
}
/* Set the architecture from a BFD (deprecated) */
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))
+ if (gdbarch_update_p (info))
target_architecture_auto = 0;
else
- printf_unfiltered ("Architecture `%s' not reconized.\n",
+ printf_unfiltered ("Architecture `%s' not recognized.\n",
set_architecture_string);
}
else
{
printf_filtered (" %s", *arch);
}
- free (arches);
+ xfree (arches);
}
else
{
printf_filtered ("\n");
}
-/* Set the dynamic target-system-dependant parameters (architecture,
+/* Set the dynamic target-system-dependent parameters (architecture,
byte-order) using information found in the BFD */
void
-set_gdbarch_from_file (abfd)
- bfd *abfd;
+set_gdbarch_from_file (bfd *abfd)
{
if (GDB_MULTI_ARCH)
{
struct gdbarch_info info;
memset (&info, 0, sizeof info);
info.abfd = abfd;
- gdbarch_update (info);
+ if (! gdbarch_update_p (info))
+ error ("Architecture of file not recognized.\n");
}
else
{
architecture'' command so that it specifies a list of valid
architectures. */
+#ifdef DEFAULT_BFD_ARCH
+extern const bfd_arch_info_type DEFAULT_BFD_ARCH;
+static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH;
+#else
+static const bfd_arch_info_type *default_bfd_arch;
+#endif
+
+#ifdef DEFAULT_BFD_VEC
+extern const bfd_target DEFAULT_BFD_VEC;
+static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC;
+#else
+static const bfd_target *default_bfd_vec;
+#endif
+
void
initialize_current_architecture (void)
{
const char **arches = gdbarch_printable_names ();
- const char *chosen = arches[0];
- if (GDB_MULTI_ARCH)
+ /* determine a default architecture and byte order. */
+ struct gdbarch_info info;
+ memset (&info, 0, sizeof (info));
+
+ /* Find a default architecture. */
+ if (info.bfd_arch_info == NULL
+ && default_bfd_arch != NULL)
+ info.bfd_arch_info = default_bfd_arch;
+ if (info.bfd_arch_info == NULL)
{
+ /* Choose the architecture by taking the first one
+ alphabetically. */
+ const char *chosen = arches[0];
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''. */
+ /* take several guesses at a byte order. */
+ /* NB: can't use TARGET_BYTE_ORDER_DEFAULT as its definition is
+ forced above. */
+ if (info.byte_order == 0
+ && default_bfd_vec != NULL)
+ {
+ /* Extract BFD's default vector's byte order. */
+ switch (default_bfd_vec->byteorder)
+ {
+ case BFD_ENDIAN_BIG:
+ info.byte_order = BIG_ENDIAN;
+ break;
+ case BFD_ENDIAN_LITTLE:
+ info.byte_order = LITTLE_ENDIAN;
+ break;
+ default:
+ break;
+ }
+ }
+ if (info.byte_order == 0)
+ {
+ /* look for ``*el-*'' in the target name. */
+ const char *chp;
+ chp = strchr (target_name, '-');
+ if (chp != NULL
+ && chp - 2 >= target_name
+ && strncmp (chp - 2, "el", 2) == 0)
+ info.byte_order = LITTLE_ENDIAN;
+ }
+ if (info.byte_order == 0)
+ {
+ /* Wire it to big-endian!!! */
+ info.byte_order = BIG_ENDIAN;
+ }
+
+ if (GDB_MULTI_ARCH)
+ {
+ if (! gdbarch_update_p (info))
+ {
+ internal_error ("initialize_current_architecture: Selection of initial architecture failed");
+ }
+ }
+
+ /* Create the ``set architecture'' command appending ``auto'' to the
+ list of architectures. */
{
struct cmd_list_element *c;
/* Append ``auto''. */
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,
+ arches, &set_architecture_string,
"Set architecture of target.",
&setlist);
c->function.sfunc = set_architecture;