From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5116 invoked by alias); 24 Oct 2003 16:16:50 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5104 invoked from network); 24 Oct 2003 16:16:47 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 24 Oct 2003 16:16:47 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id h9OGGj8q000383 for ; Fri, 24 Oct 2003 18:16:45 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id h9OGGj5s001843 for ; Fri, 24 Oct 2003 18:16:45 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id h9OGGjwW001840; Fri, 24 Oct 2003 18:16:45 +0200 (CEST) Date: Fri, 24 Oct 2003 16:16:00 -0000 Message-Id: <200310241616.h9OGGjwW001840@elgar.kettenis.dyndns.org> From: Mark Kettenis To: gdb-patches@sources.redhat.com Subject: [PATCH/RFA] Add core file support using register sets X-SW-Source: 2003-10/txt/msg00739.txt.bz2 This adds core file support using register sets. The patch depends on http://sources.redhat.com/ml/gdb-patches/2003-10/msg00732.html OK to check this in? Mark Index: ChangeLog from 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. Index: corelow.c =================================================================== RCS file: /cvs/src/src/gdb/corelow.c,v retrieving revision 1.31 diff -u -p -r1.31 corelow.c --- corelow.c 23 Oct 2003 03:01:54 -0000 1.31 +++ corelow.c 24 Oct 2003 16:14:29 -0000 @@ -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 = 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");