From: Mark Kettenis <kettenis@chello.nl>
To: gdb-patches@sources.redhat.com
Subject: [PATCH/RFA] Add core file support using register sets
Date: Fri, 24 Oct 2003 16:16:00 -0000 [thread overview]
Message-ID: <200310241616.h9OGGjwW001840@elgar.kettenis.dyndns.org> (raw)
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");
next reply other threads:[~2003-10-24 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-24 16:16 Mark Kettenis [this message]
2003-10-29 21:01 ` Mark Kettenis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200310241616.h9OGGjwW001840@elgar.kettenis.dyndns.org \
--to=kettenis@chello.nl \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox