diff options
author | Andrew Cagney <cagney@redhat.com> | 2001-05-14 16:43:35 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2001-05-14 16:43:35 +0000 |
commit | b732d07d86411216a0913c95f55bfc1d2c59ee90 (patch) | |
tree | 28050766cce41c0cdb5c814fe0124c8529d9546d /gdb/gdbarch.c | |
parent | 4ed00bba849db255def415a1c8071ddcb8af7b61 (diff) | |
download | gdb-b732d07d86411216a0913c95f55bfc1d2c59ee90.zip gdb-b732d07d86411216a0913c95f55bfc1d2c59ee90.tar.gz gdb-b732d07d86411216a0913c95f55bfc1d2c59ee90.tar.bz2 |
Fix logic selecting a new architecture. Use the sequence:
o provided by INFO
o hard-wired by (gdb) set ...
o reversed engineered from INFO.abfd
o default to previous architecture
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r-- | gdb/gdbarch.c | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index bc2070a..2bd957f 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -4644,57 +4644,41 @@ gdbarch_update_p (struct gdbarch_info info) struct gdbarch_list **list; struct gdbarch_registration *rego; - /* Fill in any missing bits. Most important is the bfd_architecture - which is used to select the target architecture. */ - if (info.bfd_architecture == bfd_arch_unknown) - { - if (info.bfd_arch_info != NULL) - info.bfd_architecture = info.bfd_arch_info->arch; - else if (info.abfd != NULL) - info.bfd_architecture = bfd_get_arch (info.abfd); - /* FIXME - should query BFD for its default architecture. */ - else - info.bfd_architecture = current_gdbarch->bfd_arch_info->arch; - } + /* 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) - { - if (target_architecture_auto && info.abfd != NULL) - info.bfd_arch_info = bfd_get_arch_info (info.abfd); - else - info.bfd_arch_info = current_gdbarch->bfd_arch_info; - } + info.bfd_arch_info = TARGET_ARCHITECTURE; + + /* ``(gdb) set byte-order ...'' */ + if (info.byte_order == 0 + && !TARGET_BYTE_ORDER_AUTO) + info.byte_order = TARGET_BYTE_ORDER; + /* From the INFO struct. */ + if (info.byte_order == 0 + && info.abfd != NULL) + info.byte_order = (bfd_big_endian (info.abfd) ? BIG_ENDIAN + : bfd_little_endian (info.abfd) ? LITTLE_ENDIAN + : 0); + /* From the current target. */ if (info.byte_order == 0) - { - if (target_byte_order_auto && info.abfd != NULL) - info.byte_order = (bfd_big_endian (info.abfd) ? BIG_ENDIAN - : bfd_little_endian (info.abfd) ? LITTLE_ENDIAN - : 0); - else - info.byte_order = current_gdbarch->byte_order; - /* FIXME - should query BFD for its default byte-order. */ - } - /* A default for abfd? */ + info.byte_order = TARGET_BYTE_ORDER; - /* Find the target that knows about this architecture. */ - for (rego = gdbarch_registry; - rego != NULL; - rego = rego->next) - if (rego->bfd_architecture == info.bfd_architecture) - break; - if (rego == NULL) - { - if (gdbarch_debug) - fprintf_unfiltered (gdb_stdlog, "gdbarch_update: No matching architecture\n"); - return 0; - } + /* Must have found some sort of architecture. */ + gdb_assert (info.bfd_arch_info != NULL); if (gdbarch_debug) { fprintf_unfiltered (gdb_stdlog, - "gdbarch_update: info.bfd_architecture %d (%s)\n", - info.bfd_architecture, - bfd_lookup_arch (info.bfd_architecture, 0)->printable_name); - fprintf_unfiltered (gdb_stdlog, "gdbarch_update: info.bfd_arch_info %s\n", (info.bfd_arch_info != NULL ? info.bfd_arch_info->printable_name @@ -4713,6 +4697,19 @@ gdbarch_update_p (struct gdbarch_info info) (long) info.tdep_info); } + /* Find the target that knows about this architecture. */ + for (rego = gdbarch_registry; + rego != NULL; + rego = rego->next) + if (rego->bfd_architecture == info.bfd_arch_info->arch) + break; + if (rego == NULL) + { + if (gdbarch_debug) + fprintf_unfiltered (gdb_stdlog, "gdbarch_update: No matching architecture\n"); + return 0; + } + /* Ask the target for a replacement architecture. */ new_gdbarch = rego->init (info, rego->arches); |