From bf922ad9fa36a3072ec439b024f3285feddbee7d Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sun, 9 Nov 2003 23:52:28 +0000 Subject: [PATCH] 2003-11-09 Andrew Cagney * Makefile.in (arch-utils.o): Update dependencies. * arch-utils.c: Include "osabi.h". (gdbarch_info_fill): New function. * arch-utils.h (gdbarch_info_fill): Declare. * gdbarch.sh (gdbarch_update_p): Call "gdbarch_info_fill". * gdbarch.c: Re-generate. --- gdb/ChangeLog | 9 +++++++++ gdb/arch-utils.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ gdb/arch-utils.h | 6 ++++++ gdb/gdbarch.c | 33 +------------------------------- gdb/gdbarch.sh | 33 +------------------------------- 5 files changed, 67 insertions(+), 64 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5b75c88d3e2..58f35220363 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2003-11-09 Andrew Cagney + + * Makefile.in (arch-utils.o): Update dependencies. + * arch-utils.c: Include "osabi.h". + (gdbarch_info_fill): New function. + * arch-utils.h (gdbarch_info_fill): Declare. + * gdbarch.sh (gdbarch_update_p): Call "gdbarch_info_fill". + * gdbarch.c: Re-generate. + 2003-11-09 Mark Kettenis David S. Miller diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 2c564e741f7..9483b938377 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -31,6 +31,8 @@ #include "gdb_assert.h" #include "sim-regno.h" +#include "osabi.h" + #include "version.h" #include "floatformat.h" @@ -680,6 +682,54 @@ gdbarch_info_init (struct gdbarch_info *info) info->osabi = GDB_OSABI_UNINITIALIZED; } +/* Similar it init, but this time fill in the blanks. Information is + obtained from the specified architecture, global "set ..." options, + and explicitly initialized INFO fields. */ + +void +gdbarch_info_fill (struct gdbarch *gdbarch, struct gdbarch_info *info) +{ + /* "(gdb) set architecture ...". */ + if (info->bfd_arch_info == NULL + && !target_architecture_auto + && gdbarch != NULL) + info->bfd_arch_info = gdbarch_bfd_arch_info (gdbarch); + if (info->bfd_arch_info == NULL + && info->abfd != NULL + && bfd_get_arch (info->abfd) != bfd_arch_unknown + && bfd_get_arch (info->abfd) != bfd_arch_obscure) + info->bfd_arch_info = bfd_get_arch_info (info->abfd); + if (info->bfd_arch_info == NULL + && gdbarch != NULL) + info->bfd_arch_info = gdbarch_bfd_arch_info (gdbarch); + + /* "(gdb) set byte-order ...". */ + if (info->byte_order == BFD_ENDIAN_UNKNOWN + && !target_byte_order_auto + && gdbarch != NULL) + info->byte_order = gdbarch_byte_order (gdbarch); + /* From the INFO struct. */ + if (info->byte_order == BFD_ENDIAN_UNKNOWN + && info->abfd != NULL) + info->byte_order = (bfd_big_endian (info->abfd) ? BFD_ENDIAN_BIG + : bfd_little_endian (info->abfd) ? BFD_ENDIAN_LITTLE + : BFD_ENDIAN_UNKNOWN); + /* From the current target. */ + if (info->byte_order == BFD_ENDIAN_UNKNOWN + && gdbarch != NULL) + info->byte_order = gdbarch_byte_order (gdbarch); + + /* "(gdb) set osabi ...". Handled by gdbarch_lookup_osabi. */ + if (info->osabi == GDB_OSABI_UNINITIALIZED) + info->osabi = gdbarch_lookup_osabi (info->abfd); + if (info->osabi == GDB_OSABI_UNINITIALIZED + && gdbarch != NULL) + info->osabi = gdbarch_osabi (gdbarch); + + /* Must have at least filled in the architecture. */ + gdb_assert (info->bfd_arch_info != NULL); +} + /* */ extern initialize_file_ftype _initialize_gdbarch_utils; /* -Wmissing-prototypes */ diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index a180fda885c..db9d24ed635 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -153,6 +153,12 @@ extern int legacy_register_sim_regno (int regnum); default values are not zero. */ extern void gdbarch_info_init (struct gdbarch_info *info); +/* Similar it init, but this time fill in the blanks. Information is + obtained from the specified architecture, global "set ..." options, + and explicitly initialized INFO fields. */ +extern void gdbarch_info_fill (struct gdbarch *gdbarch, + struct gdbarch_info *info); + /* Return the architecture for ABFD. If no suitable architecture could be find, return NULL. */ diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 75652a88eb1..40fbdd92ddb 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -5922,38 +5922,7 @@ gdbarch_update_p (struct gdbarch_info info) /* Fill in missing parts of the INFO struct using a number of sources: ``set ...''; INFOabfd supplied; existing target. */ - - /* ``(gdb) set architecture ...'' */ - if (info.bfd_arch_info == NULL - && !TARGET_ARCHITECTURE_AUTO) - info.bfd_arch_info = TARGET_ARCHITECTURE; - if (info.bfd_arch_info == NULL - && info.abfd != NULL - && bfd_get_arch (info.abfd) != bfd_arch_unknown - && bfd_get_arch (info.abfd) != bfd_arch_obscure) - info.bfd_arch_info = bfd_get_arch_info (info.abfd); - if (info.bfd_arch_info == NULL) - info.bfd_arch_info = TARGET_ARCHITECTURE; - - /* ``(gdb) set byte-order ...'' */ - if (info.byte_order == BFD_ENDIAN_UNKNOWN - && !TARGET_BYTE_ORDER_AUTO) - info.byte_order = TARGET_BYTE_ORDER; - /* From the INFO struct. */ - if (info.byte_order == BFD_ENDIAN_UNKNOWN - && info.abfd != NULL) - info.byte_order = (bfd_big_endian (info.abfd) ? BFD_ENDIAN_BIG - : bfd_little_endian (info.abfd) ? BFD_ENDIAN_LITTLE - : BFD_ENDIAN_UNKNOWN); - /* From the current target. */ - if (info.byte_order == BFD_ENDIAN_UNKNOWN) - info.byte_order = TARGET_BYTE_ORDER; - - /* ``(gdb) set osabi ...'' is handled by gdbarch_lookup_osabi. */ - if (info.osabi == GDB_OSABI_UNINITIALIZED) - info.osabi = gdbarch_lookup_osabi (info.abfd); - if (info.osabi == GDB_OSABI_UNINITIALIZED) - info.osabi = current_gdbarch->osabi; + gdbarch_info_fill (current_gdbarch, &info); /* Must have found some sort of architecture. */ gdb_assert (info.bfd_arch_info != NULL); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index c1c39f687dd..afc5e02cdec 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -2138,38 +2138,7 @@ gdbarch_update_p (struct gdbarch_info info) /* Fill in missing parts of the INFO struct using a number of sources: \`\`set ...''; INFOabfd supplied; existing target. */ - - /* \`\`(gdb) set architecture ...'' */ - if (info.bfd_arch_info == NULL - && !TARGET_ARCHITECTURE_AUTO) - info.bfd_arch_info = TARGET_ARCHITECTURE; - if (info.bfd_arch_info == NULL - && info.abfd != NULL - && bfd_get_arch (info.abfd) != bfd_arch_unknown - && bfd_get_arch (info.abfd) != bfd_arch_obscure) - info.bfd_arch_info = bfd_get_arch_info (info.abfd); - if (info.bfd_arch_info == NULL) - info.bfd_arch_info = TARGET_ARCHITECTURE; - - /* \`\`(gdb) set byte-order ...'' */ - if (info.byte_order == BFD_ENDIAN_UNKNOWN - && !TARGET_BYTE_ORDER_AUTO) - info.byte_order = TARGET_BYTE_ORDER; - /* From the INFO struct. */ - if (info.byte_order == BFD_ENDIAN_UNKNOWN - && info.abfd != NULL) - info.byte_order = (bfd_big_endian (info.abfd) ? BFD_ENDIAN_BIG - : bfd_little_endian (info.abfd) ? BFD_ENDIAN_LITTLE - : BFD_ENDIAN_UNKNOWN); - /* From the current target. */ - if (info.byte_order == BFD_ENDIAN_UNKNOWN) - info.byte_order = TARGET_BYTE_ORDER; - - /* \`\`(gdb) set osabi ...'' is handled by gdbarch_lookup_osabi. */ - if (info.osabi == GDB_OSABI_UNINITIALIZED) - info.osabi = gdbarch_lookup_osabi (info.abfd); - if (info.osabi == GDB_OSABI_UNINITIALIZED) - info.osabi = current_gdbarch->osabi; + gdbarch_info_fill (current_gdbarch, &info); /* Must have found some sort of architecture. */ gdb_assert (info.bfd_arch_info != NULL); -- 2.30.2