+2002-12-14 Mark Kettenis <kettenis@gnu.org>
+
+ * osabi.c: Include "gdb_assert.h" and "gdb_string.h".
+ (struct gdb_osabi_handler): Remove member `arch'. Add member
+ `arch_info'.
+ (gdbarch_register_osabi): Add new argument `machine'. Use ot to
+ construct a `struct bfd_arch_info' and store it in the `struct
+ gdb_osabi_handler' that is created.
+ (gdbarch_init_osabi): Check for compatibility based on machine
+ type and architecture.
+ * osabi.h (gdbarch_register_osabi): Adjust prototype and update
+ comment.
+ * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add 0 as
+ second argument in call to gdbarch_register_osabi.
+ * alpha-osf1-tdep.c (_initialize_alpha_osf1_tdep): Likewise.
+ * alphafbsd-tdep.c (_initialize_alphafbsd_tdep): Likewise.
+ * alphanbsd-tdep.c (_initialize_alphanbsd_tdep): Likewise.
+ * arm-linux-tdep.c (_initialize_arm_linux_tdep): Likewise.
+ * arm-tdep.c (_initialize_arm_tdep): Likewise.
+ * armnbsd-tdep.c (_initialize_armnbsd_tdep): Likewise.
+ * hppa-hpux-tdep.c (_initialize_hppa_hpux_tdep): Likewise.
+ * i386-interix-tdep.c (_initialize_i386_interix_tdep): Likewise.
+ * i386-linux-tdep.c (_initialize_i386_linux_tdep): Likewise.
+ * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Likewise.
+ * i386-tdep.c (_initialize_i386_tdep): Likewise.
+ * i386bsd-tdep.c (_initialize_i386bsd_tdep): Likewise.
+ * i386gnu-tdep.c (_initialize_i386gnu_tdep): Likewise.
+ * i386ly-tdep.c (_initialize_i386lynx_tdep): Renamed from
+ _initialize_i386bsd_tdep and updated likewise.
+ * i386nbsd-tdep.c (_initialize_i386nbsd_tdep): Likewise.
+ * i386obsd-tdep.c (_initialize_i386obsd_tdep): Likewise.
+ * mips-irix-tdep.c (_initialize_mips_irix_tdep): Likewise.
+ * mips-linux-tdep.c (_initialize_mips_linux_tdep): Likewise.
+ * mipsnbsd-tdep.c (_initialize_mipsnbsd__tdep): Likewise.
+ * ns32knbsd-tdep.c (_initialize_ns32kmnsd_tdep): Likewise.
+ * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Likewise.
+ * ppcnbsd-tdep.c (_initialize_ppcnbsd_tdep): Likewise.
+ * shnbsd-tdep.c (_initialize_shnbsd_tdep): Likewise.
+ * sparcnbsd-tdep.c (_initialize_sparcnbsd_tdep): Likewise.
+
2002-12-20 Kevin Buettner <kevinb@redhat.com>
* solib-svr4.c (elf_locate_base): Fix sizeof() related bug. Add
void
_initialize_alpha_linux_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_alpha, GDB_OSABI_LINUX,
+ gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_LINUX,
alpha_linux_init_abi);
}
void
_initialize_alpha_osf1_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_alpha, GDB_OSABI_OSF1, alpha_osf1_init_abi);
+ gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_OSF1,
+ alpha_osf1_init_abi);
}
void
_initialize_alphafbsd_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_alpha, GDB_OSABI_FREEBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_FREEBSD_ELF,
alphafbsd_init_abi);
}
void
_initialize_alphanbsd_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_alpha, GDB_OSABI_NETBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_NETBSD_ELF,
alphanbsd_init_abi);
add_core_fns (&alphanbsd_core_fns);
void
_initialize_arm_linux_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_arm, GDB_OSABI_LINUX, arm_linux_init_abi);
+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_LINUX,
+ arm_linux_init_abi);
}
arm_elf_osabi_sniffer);
/* Register some ABI variants for embedded systems. */
- gdbarch_register_osabi (bfd_arch_arm, GDB_OSABI_ARM_EABI_V1,
+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_ARM_EABI_V1,
arm_init_abi_eabi_v1);
- gdbarch_register_osabi (bfd_arch_arm, GDB_OSABI_ARM_EABI_V2,
+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_ARM_EABI_V2,
arm_init_abi_eabi_v2);
- gdbarch_register_osabi (bfd_arch_arm, GDB_OSABI_ARM_APCS,
+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_ARM_APCS,
arm_init_abi_apcs);
tm_print_insn = gdb_print_insn_arm;
gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_aout_flavour,
arm_netbsd_aout_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_arm, GDB_OSABI_NETBSD_AOUT,
+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD_AOUT,
arm_netbsd_aout_init_abi);
- gdbarch_register_osabi (bfd_arch_arm, GDB_OSABI_NETBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_NETBSD_ELF,
arm_netbsd_elf_init_abi);
}
void
_initialize_hppa_hpux_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_hppa, GDB_OSABI_HPUX_SOM,
+ gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_SOM,
hppa_hpux_som_init_abi);
- gdbarch_register_osabi (bfd_arch_hppa, GDB_OSABI_HPUX_ELF,
+ gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_HPUX_ELF,
hppa_hpux_elf_init_abi);
}
-
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour,
i386_interix_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_INTERIX,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_INTERIX,
i386_interix_init_abi);
}
void
_initialize_i386_linux_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_LINUX,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
i386_linux_init_abi);
}
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
i386_sol2_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_SOLARIS,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SOLARIS,
i386_sol2_init_abi);
}
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_nlm_flavour,
i386_nlm_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_SVR4,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SVR4,
i386_svr4_init_abi);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_GO32,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_GO32,
i386_go32_init_abi);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETWARE,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_NETWARE,
i386_nw_init_abi);
/* Initialize the i386 specific register groups. */
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
i386bsd_aout_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_FREEBSD_AOUT,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_AOUT,
i386fbsdaout_init_abi);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_FREEBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_ELF,
i386fbsd4_init_abi);
}
void
_initialize_i386gnu_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_HURD, i386gnu_init_abi);
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_HURD, i386gnu_init_abi);
}
void _initialize_i386lynx_tdep (void);
void
-_initialize_i386bsd_tdep (void)
+_initialize_i386lynx_tdep (void)
{
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour,
i386lynx_coff_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_LYNXOS,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LYNXOS,
i386lynx_init_abi);
}
add_core_fns (&i386nbsd_core_fns);
add_core_fns (&i386nbsd_elfcore_fns);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_AOUT,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_NETBSD_AOUT,
i386nbsd_init_abi);
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_NETBSD_ELF,
i386nbsdelf_init_abi);
}
expected. */
#define GDB_OSABI_OPENBSD_AOUT GDB_OSABI_NETBSD_AOUT
- gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_OPENBSD_AOUT,
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_OPENBSD_AOUT,
i386obsd_init_abi);
}
bfd_target_elf_flavour,
mips_irix_elf_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_mips, GDB_OSABI_IRIX,
+ gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_IRIX,
mips_irix_init_abi);
}
void
_initialize_mips_linux_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_mips, GDB_OSABI_LINUX,
+ gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_LINUX,
mips_linux_init_abi);
add_core_fns (®set_core_fns);
}
void
_initialize_mipsnbsd_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_mips, GDB_OSABI_NETBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_NETBSD_ELF,
mipsnbsd_init_abi);
add_core_fns (&mipsnbsd_core_fns);
gdbarch_register_osabi_sniffer (bfd_arch_ns32k, bfd_target_aout_flavour,
ns32knbsd_aout_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_ns32k, GDB_OSABI_NETBSD_AOUT,
+ gdbarch_register_osabi (bfd_arch_ns32k, 0, GDB_OSABI_NETBSD_AOUT,
ns32knbsd_init_abi_aout);
}
Boston, MA 02111-1307, USA. */
#include "defs.h"
+
+#include "gdb_assert.h"
#include "gdb_string.h"
+
#include "osabi.h"
#include "elf-bfd.h"
struct gdb_osabi_handler
{
struct gdb_osabi_handler *next;
- enum bfd_architecture arch;
+ const struct bfd_arch_info *arch_info;
enum gdb_osabi osabi;
void (*init_osabi)(struct gdbarch_info, struct gdbarch *);
};
static struct gdb_osabi_handler *gdb_osabi_handler_list;
void
-gdbarch_register_osabi (enum bfd_architecture arch, enum gdb_osabi osabi,
+gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine,
+ enum gdb_osabi osabi,
void (*init_osabi)(struct gdbarch_info,
struct gdbarch *))
{
struct gdb_osabi_handler **handler_p;
+ const struct bfd_arch_info *arch_info = bfd_lookup_arch (arch, machine);
/* Registering an OS ABI handler for "unknown" is not allowed. */
if (osabi == GDB_OSABI_UNKNOWN)
"OS ABI \"%s\" for architecture %s was made. The handler will "
"not be registered",
gdbarch_osabi_name (osabi),
- bfd_printable_arch_mach (arch, 0));
+ bfd_printable_arch_mach (arch, machine));
return;
}
+ gdb_assert (arch_info);
+
for (handler_p = &gdb_osabi_handler_list; *handler_p != NULL;
handler_p = &(*handler_p)->next)
{
- if ((*handler_p)->arch == arch
+ if ((*handler_p)->arch_info == arch_info
&& (*handler_p)->osabi == osabi)
{
internal_error
"gdbarch_register_osabi: A handler for OS ABI \"%s\" "
"has already been registered for architecture %s",
gdbarch_osabi_name (osabi),
- bfd_printable_arch_mach (arch, 0));
+ arch_info->printable_name);
/* If user wants to continue, override previous definition. */
(*handler_p)->init_osabi = init_osabi;
return;
(*handler_p)
= (struct gdb_osabi_handler *) xmalloc (sizeof (struct gdb_osabi_handler));
(*handler_p)->next = NULL;
- (*handler_p)->arch = arch;
+ (*handler_p)->arch_info = arch_info;
(*handler_p)->osabi = osabi;
(*handler_p)->init_osabi = init_osabi;
}
gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch,
enum gdb_osabi osabi)
{
- struct gdb_osabi_handler *handler;
- bfd *abfd = info.abfd;
const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
+ const struct bfd_arch_info *compatible;
+ struct gdb_osabi_handler *handler;
if (osabi == GDB_OSABI_UNKNOWN)
{
for (handler = gdb_osabi_handler_list; handler != NULL;
handler = handler->next)
{
- if (handler->arch == bfd_get_arch (abfd)
- && handler->osabi == osabi)
+ if (handler->osabi != osabi)
+ continue;
+
+ /* Check whether the machine type and architecture of the
+ handler are compatible with the desired machine type and
+ architecture.
+
+ NOTE: kettenis/20021027: There may be more than one machine
+ type that is compatible with the desired machine type. Right
+ now we simply return the first match, which is fine for now.
+ However, we might want to do something smarter in the future. */
+ compatible = arch_info->compatible (arch_info, handler->arch_info);
+ if (compatible == handler->arch_info)
{
(*handler->init_osabi) (info, gdbarch);
return;
enum bfd_flavour,
enum gdb_osabi (*)(bfd *));
-/* Register a handler for an OS ABI variant for a given architecture. There
- should be only one handler for a given OS ABI each architecture family. */
-void gdbarch_register_osabi (enum bfd_architecture, enum gdb_osabi,
+/* Register a handler for an OS ABI variant for a given architecture
+ and machine type. There should be only one handler for a given OS
+ ABI for each architecture and machine type combination. */
+void gdbarch_register_osabi (enum bfd_architecture, unsigned long,
+ enum gdb_osabi,
void (*)(struct gdbarch_info,
struct gdbarch *));
void
_initialize_ppc_linux_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_powerpc, GDB_OSABI_LINUX,
+ gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_LINUX,
ppc_linux_init_abi);
add_core_fns (&ppc_linux_regset_core_fns);
}
void
_initialize_ppcnbsd_tdep (void)
{
- gdbarch_register_osabi (bfd_arch_powerpc, GDB_OSABI_NETBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_NETBSD_ELF,
ppcnbsd_init_abi);
add_core_fns (&ppcnbsd_core_fns);
add_core_fns (&shnbsd_core_fns);
add_core_fns (&shnbsd_elfcore_fns);
- gdbarch_register_osabi (bfd_arch_sh, GDB_OSABI_NETBSD_ELF, shnbsd_init_abi);
+ gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD_ELF,
+ shnbsd_init_abi);
}
gdbarch_register_osabi_sniffer (bfd_arch_sparc, bfd_target_aout_flavour,
sparcnbsd_aout_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_sparc, GDB_OSABI_NETBSD_AOUT,
+ gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_NETBSD_AOUT,
sparcnbsd_init_abi_aout);
- gdbarch_register_osabi (bfd_arch_sparc, GDB_OSABI_NETBSD_ELF,
+ gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_NETBSD_ELF,
sparcnbsd_init_abi_elf);
add_core_fns (&sparcnbsd_core_fns);