From: Mark Kettenis <kettenis@chello.nl>
To: gdb-patches@sources.redhat.com
Subject: [PATCH/RFC/RFA] Add regcache_raw_{supply,collect}
Date: Thu, 28 Aug 2003 22:02:00 -0000 [thread overview]
Message-ID: <200308282202.h7SM2Q2k032444@elgar.kettenis.dyndns.org> (raw)
With this path I propose the addition of two new regcache interfaces
to replace supply_register() and regcache_collect(). My work on
debugging 32-bit code on AMD64 and unifying ELF core file support will
be touching several places where we transfer registers to and from the
register cache. The current functions aren't named very consistently.
Moreover, somewhere in the future we want to get rid of the single
register cache, so we should be able to specify a register cache.
That's why I think we need the following functions:
/* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
void regcache_raw_supply (struct regcache *regcache,
int regnum, const void *buf);
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
void regcache_raw_collect (const struct regcache *regcache,
int regnum, void *buf);
For now, these will only be called with CURRENT_REGCACHE as their
first argument, but if we start to use these functions now it will be
easier to start using multiple register caches in the future.
Opinions?
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* regcache.c (register_buffer): Consitify first argument.
(regcache_raw_supply, regcache_raw_collect): New
functions.
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.94
diff -u -p -r1.94 regcache.c
--- regcache.c 4 Aug 2003 22:24:44 -0000 1.94
+++ regcache.c 28 Aug 2003 22:01:55 -0000
@@ -345,7 +345,7 @@ make_cleanup_regcache_xfree (struct regc
/* Return a pointer to register REGNUM's buffer cache. */
static char *
-register_buffer (struct regcache *regcache, int regnum)
+register_buffer (const struct regcache *regcache, int regnum)
{
return regcache->registers + regcache->descr->register_offset[regnum];
}
@@ -1201,6 +1201,10 @@ write_register_pid (int regnum, CORE_ADD
inferior_ptid = save_ptid;
}
+/* FIXME: kettenis/20030828: We should get rid of supply_register and
+ regcache_collect in favour of regcache_raw_supply and
+ regcache_raw_collect. */
+
/* SUPPLY_REGISTER()
Record that register REGNUM contains VAL. This is used when the
@@ -1250,6 +1254,55 @@ regcache_collect (int regnum, void *buf)
{
memcpy (buf, register_buffer (current_regcache, regnum),
REGISTER_RAW_SIZE (regnum));
+}
+
+/* Supply register REGNUM, whose contents are store in BUF, to REGCACHE. */
+
+void
+regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
+{
+ void *regbuf;
+ size_t size;
+
+ gdb_assert (regcache != NULL && buf != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+ gdb_assert (!regcache->readonly_p);
+
+ /* FIXME: kettenis/20030828: It shouldn't be necessary to handle
+ CURRENT_REGCACHE specially here. */
+ if (regcache == current_regcache
+ && !ptid_equal (registers_ptid, inferior_ptid))
+ {
+ registers_changed ();
+ registers_ptid = inferior_ptid;
+ }
+
+ regbuf = register_buffer (regcache, regnum);
+ size = regcache->descr->sizeof_register[regnum];
+
+ if (buf)
+ memcpy (regbuf, buf, size);
+ else
+ memset (regbuf, 0, size);
+
+ /* Mark the register as cached. */
+ regcache->register_valid_p[regnum] = 1;
+}
+
+/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
+
+void
+regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
+{
+ const void *regbuf;
+ size_t size;
+
+ gdb_assert (regcache != NULL && buf != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+
+ regbuf = register_buffer (regcache, regnum);
+ size = regcache->descr->sizeof_register[regnum];
+ memcpy (buf, regbuf, size);
}
Index: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.35
diff -u -p -r1.35 regcache.h
--- regcache.h 15 May 2003 18:01:50 -0000 1.35
+++ regcache.h 28 Aug 2003 22:01:56 -0000
@@ -94,6 +94,10 @@ void regcache_cooked_write_part (struct
extern void supply_register (int regnum, const void *val);
extern void regcache_collect (int regnum, void *buf);
+extern void regcache_raw_supply (struct regcache *regcache,
+ int regnum, const void *buf);
+extern void regcache_raw_collect (const struct regcache *regcache,
+ int regnum, void *buf);
/* The register's ``offset''.
next reply other threads:[~2003-08-28 22:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-28 22:02 Mark Kettenis [this message]
2003-08-29 0:49 ` Andrew Cagney
2003-08-29 10:23 ` Mark Kettenis
2003-08-29 14:27 ` Andrew Cagney
2003-08-29 15:36 ` Andrew Cagney
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=200308282202.h7SM2Q2k032444@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