aboutsummaryrefslogtreecommitdiff
path: root/gdb/osabi.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2002-12-21 19:58:07 +0000
committerMark Kettenis <kettenis@gnu.org>2002-12-21 19:58:07 +0000
commit05816f706ec4cb2e789828fa8edb8ea30593933b (patch)
treee6e08df1755b4df8667a796d3c271bb99031d55b /gdb/osabi.c
parent743b930b5935b474bec050a1598344b8580eaab9 (diff)
downloadgdb-05816f706ec4cb2e789828fa8edb8ea30593933b.zip
gdb-05816f706ec4cb2e789828fa8edb8ea30593933b.tar.gz
gdb-05816f706ec4cb2e789828fa8edb8ea30593933b.tar.bz2
* 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.
Diffstat (limited to 'gdb/osabi.c')
-rw-r--r--gdb/osabi.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 06d9c90..47d08a2 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -19,7 +19,10 @@
Boston, MA 02111-1307, USA. */
#include "defs.h"
+
+#include "gdb_assert.h"
#include "gdb_string.h"
+
#include "osabi.h"
#include "elf-bfd.h"
@@ -70,7 +73,7 @@ gdbarch_osabi_name (enum gdb_osabi osabi)
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 *);
};
@@ -78,11 +81,13 @@ struct gdb_osabi_handler
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)
@@ -93,14 +98,16 @@ gdbarch_register_osabi (enum bfd_architecture arch, enum gdb_osabi osabi,
"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
@@ -108,7 +115,7 @@ gdbarch_register_osabi (enum bfd_architecture arch, enum gdb_osabi osabi,
"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;
@@ -118,7 +125,7 @@ gdbarch_register_osabi (enum bfd_architecture arch, enum gdb_osabi osabi,
(*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;
}
@@ -230,9 +237,9 @@ void
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)
{
@@ -244,8 +251,19 @@ gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch,
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;