This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH/RFA] Add core file support using register sets
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 24 Oct 2003 18:16:45 +0200 (CEST)
- Subject: [PATCH/RFA] Add core file support using register sets
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 <kettenis@gnu.org>
* 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 <errno.h>
#include <signal.h>
@@ -37,10 +38,13 @@
#include "gdbcore.h"
#include "gdbthread.h"
#include "regcache.h"
+#include "regset.h"
#include "symfile.h"
#include "exec.h"
#include <readline/readline.h>
+#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");