* [PATCH/RFC/RFA] Add regcache_raw_{supply,collect}
@ 2003-08-28 22:02 Mark Kettenis
2003-08-29 0:49 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2003-08-28 22:02 UTC (permalink / raw)
To: gdb-patches
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''.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFC/RFA] Add regcache_raw_{supply,collect}
2003-08-28 22:02 [PATCH/RFC/RFA] Add regcache_raw_{supply,collect} Mark Kettenis
@ 2003-08-29 0:49 ` Andrew Cagney
2003-08-29 10:23 ` Mark Kettenis
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-08-29 0:49 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
BTW, in the ARI, I've the comment:
supply register
Replace supply_register() with something involving the regcache, or a TPID
so yep.
Can you at the same time re-implement supply_register and
regcache_collect to use these new methods. I'll then add
supply_register and regcache_collect to the deprecate list.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFC/RFA] Add regcache_raw_{supply,collect}
2003-08-29 0:49 ` Andrew Cagney
@ 2003-08-29 10:23 ` Mark Kettenis
2003-08-29 14:27 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2003-08-29 10:23 UTC (permalink / raw)
To: ac131313; +Cc: gdb-patches
Date: Thu, 28 Aug 2003 20:49:06 -0400
From: Andrew Cagney <ac131313@redhat.com>
BTW, in the ARI, I've the comment:
supply register
Replace supply_register() with something involving the regcache, or a TPID
so yep.
Missed that. Anyway, I think supplying the regcache is better than
supplying a TPID.
Can you at the same time re-implement supply_register and
regcache_collect to use these new methods. I'll then add
supply_register and regcache_collect to the deprecate list.
This is not entirely without a risk. I want to keep the new
interfaces "legacy-free", so they're not doing exactly the same thing
as the old interfaces. Therefore I chose to re-implement the old
interfaces in a seperate commit. The new functions are checked in now.
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFC/RFA] Add regcache_raw_{supply,collect}
2003-08-29 10:23 ` Mark Kettenis
@ 2003-08-29 14:27 ` Andrew Cagney
2003-08-29 15:36 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2003-08-29 14:27 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Thu, 28 Aug 2003 20:49:06 -0400
> From: Andrew Cagney <ac131313@redhat.com>
>
> BTW, in the ARI, I've the comment:
>
> supply register
> Replace supply_register() with something involving the regcache, or a TPID
>
> so yep.
>
> Missed that. Anyway, I think supplying the regcache is better than
> supplying a TPID.
>
> Can you at the same time re-implement supply_register and
> regcache_collect to use these new methods. I'll then add
> supply_register and regcache_collect to the deprecate list.
>
> This is not entirely without a risk. I want to keep the new
> interfaces "legacy-free", so they're not doing exactly the same thing
> as the old interfaces. Therefore I chose to re-implement the old
> interfaces in a seperate commit. The new functions are checked in now.
So it's a follow on change? Otherwize a some comments will be needed.
ok,
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH/RFC/RFA] Add regcache_raw_{supply,collect}
2003-08-29 14:27 ` Andrew Cagney
@ 2003-08-29 15:36 ` Andrew Cagney
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-08-29 15:36 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
>
> This is not entirely without a risk. I want to keep the new
> interfaces "legacy-free", so they're not doing exactly the same thing
> as the old interfaces. Therefore I chose to re-implement the old
> interfaces in a seperate commit. The new functions are checked in now.
>
> So it's a follow on change? Otherwize a some comments will be needed.
Sorry, just saw your post. Never mind.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-08-29 15:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-28 22:02 [PATCH/RFC/RFA] Add regcache_raw_{supply,collect} Mark Kettenis
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox