From 0e24ac5d5fb8b0bc998f57748e6bc222edddb949 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 29 Oct 2003 20:59:07 +0000 Subject: [PATCH] * corelow.c: Include "arch-utils.h", "regset.h" and "gdb_assert.h". (core_gdbarch): New variable. (sniff_core_bfd): Don't sniff if we have support for register sets in CORE_GDBARCH. (core_close): Reset CORE_GDBARCH. (core_open): Initialize CORE_GDBARCH. (get_core_register_section): Use register sets if they are supported by CORE_GDBARCH. (get_core_registers): Don't print error message if we have support for register sets in CORE_GDBARCH. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/corelow.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 048bb9d2c02..3c956067e5d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2003-10-29 Mark Kettenis + + * corelow.c: Include "arch-utils.h", "regset.h" and + "gdb_assert.h". + (core_gdbarch): New variable. + (sniff_core_bfd): Don't sniff if we have support for register sets + in CORE_GDBARCH. + (core_close): Reset CORE_GDBARCH. + (core_open): Initialize CORE_GDBARCH. + (get_core_register_section): Use register sets if they are + supported by CORE_GDBARCH. + (get_core_registers): Don't print error message if we have support + for register sets in CORE_GDBARCH. + 2003-10-29 Andrew Cagney * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Instead of the diff --git a/gdb/corelow.c b/gdb/corelow.c index d6a3cfdedee..b933467579f 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA. */ #include "defs.h" +#include "arch-utils.h" #include "gdb_string.h" #include #include @@ -37,10 +38,13 @@ #include "gdbcore.h" #include "gdbthread.h" #include "regcache.h" +#include "regset.h" #include "symfile.h" #include "exec.h" #include +#include "gdb_assert.h" + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -56,6 +60,11 @@ static struct core_fns *core_file_fns = NULL; static struct core_fns *core_vec = NULL; +/* FIXME: kettenis/20031023: Eventually this variable should + disappear. */ + +struct gdbarch *core_gdbarch = NULL; + static void core_files_info (struct target_ops *); #ifdef SOLIB_ADD @@ -125,6 +134,10 @@ sniff_core_bfd (bfd *abfd) struct core_fns *yummy = NULL; int matches = 0;; + /* Don't sniff if we have support for register sets in CORE_GDBARCH. */ + if (core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) + return NULL; + for (cf = core_file_fns; cf != NULL; cf = cf->next) { if (cf->core_sniffer (cf, abfd)) @@ -209,6 +222,7 @@ core_close (int quitting) } } core_vec = NULL; + core_gdbarch = NULL; } static void @@ -311,6 +325,14 @@ core_open (char *filename, int from_tty) core_bfd = temp_bfd; old_chain = make_cleanup (core_close_cleanup, 0 /*ignore*/); + /* FIXME: kettenis/20031023: This is very dangerous. The + CORE_GDBARCH that results from this call may very well be + different from CURRENT_GDBARCH. However, its methods may only + work if it is selected as the current architecture, because they + rely on swapped data (see gdbarch.c). We should get rid of that + swapped data. */ + core_gdbarch = gdbarch_from_bfd (core_bfd); + /* Find a suitable core file handler to munch on core_bfd */ core_vec = sniff_core_bfd (core_bfd); @@ -437,6 +459,24 @@ get_core_register_section (char *name, return; } + if (core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) + { + const struct regset *regset; + + regset = gdbarch_regset_from_core_section (core_gdbarch, name, size); + if (regset == NULL) + { + if (required) + warning ("Couldn't recognize %s registers in core file.\n", + human_name); + return; + } + + regset->supply_regset (regset, current_regcache, -1, contents, size); + return; + } + + gdb_assert (core_vec); core_vec->core_read_registers (contents, size, which, ((CORE_ADDR) bfd_section_vma (core_bfd, section))); @@ -454,8 +494,8 @@ get_core_registers (int regno) { int status; - if (core_vec == NULL - || core_vec->core_read_registers == NULL) + if (!(core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch)) + && (core_vec == NULL || core_vec->core_read_registers == NULL)) { fprintf_filtered (gdb_stderr, "Can't fetch registers from this type of core file\n"); -- 2.30.2