aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2001-11-15 06:43:10 +0000
committerAndrew Cagney <cagney@redhat.com>2001-11-15 06:43:10 +0000
commit193cb69f7b359809cc83c0d57149a478d1e803c7 (patch)
treec0393e743008d5bacc55b5135a9a394f513c24c6
parent7c2b59d0e8cd59974289c1a167e93810e9137021 (diff)
downloadgdb-193cb69f7b359809cc83c0d57149a478d1e803c7.zip
gdb-193cb69f7b359809cc83c0d57149a478d1e803c7.tar.gz
gdb-193cb69f7b359809cc83c0d57149a478d1e803c7.tar.bz2
* TODO (register_buffer): Delete.
* regcache.c (register_buffer): Make static. (regcache_collect): New function. * regcache.h (register_buffer): Delete declaration. (regcache_collect): Declare. * remote.c (store_register_using_P): Rewrite using regcache_collect. (remote_store_registers): Ditto. * go32-nat.c (store_register): Ditto.
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/TODO1
-rw-r--r--gdb/go32-nat.c3
-rw-r--r--gdb/regcache.c9
-rw-r--r--gdb/regcache.h15
-rw-r--r--gdb/remote.c26
6 files changed, 48 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bce62a2..ccb4363 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2001-11-15 Andrew Cagney <ac131313@redhat.com>
+
+ * TODO (register_buffer): Delete.
+ * regcache.c (register_buffer): Make static.
+ (regcache_collect): New function.
+ * regcache.h (register_buffer): Delete declaration.
+ (regcache_collect): Declare.
+ * remote.c (store_register_using_P): Rewrite using
+ regcache_collect.
+ (remote_store_registers): Ditto.
+ * go32-nat.c (store_register): Ditto.
+
2001-11-14 Andrew Cagney <ac131313@redhat.com>
* remote.c (struct remote_state): Declare.
diff --git a/gdb/TODO b/gdb/TODO
index 7cf0eab..191f106 100644
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -136,7 +136,6 @@ Deprecate, if not delete, the following:
register[]
register_valid[]
- register_buffer()
REGISTER_BYTE()
Replaced by, on the target side
supply_register()
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 3f56088..612ff3e 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -493,7 +493,8 @@ static void
store_register (int regno)
{
void *rp;
- void *v = (void *) register_buffer (regno);
+ void *v = alloca (MAX_REGISTER_RAW_SIZE);
+ regcache_collect (regno, v);
if (regno < FP0_REGNUM)
memcpy ((char *) &a_tss + regno_mapping[regno].tss_ofs,
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 3bf0b47..ae89345 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -90,7 +90,7 @@ register_changed (int regnum)
/* If REGNUM >= 0, return a pointer to register REGNUM's cache buffer area,
else return a pointer to the start of the cache buffer. */
-char *
+static char *
register_buffer (int regnum)
{
if (regnum < 0)
@@ -568,6 +568,13 @@ supply_register (int regnum, char *val)
#endif
}
+void
+regcache_collect (int regnum, void *buf)
+{
+ memcpy (buf, register_buffer (regnum), REGISTER_RAW_SIZE (regnum));
+}
+
+
/* read_pc, write_pc, read_sp, write_sp, read_fp, write_fp, etc.
Special handling for registers PC, SP, and FP. */
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 93fbbc7..4e854d3 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -28,6 +28,14 @@
void regcache_read (int rawnum, char *buf);
void regcache_write (int rawnum, char *buf);
+/* Transfer a raw register [0..NUM_REGS) between the regcache and the
+ target. These functions are called by the target in response to a
+ target_fetch_registers() or target_store_registers(). */
+
+extern void supply_register (int regnum, char *val);
+extern void regcache_collect (int regnum, void *buf);
+
+
/* DEPRECATED: Character array containing an image of the inferior
programs' registers for the most recently referenced thread. */
@@ -45,11 +53,6 @@ extern void set_register_cached (int regnum, int state);
extern void register_changed (int regnum);
-/* DEPRECATED: Functional interface returning pointer into registers[]
- array. */
-
-extern char *register_buffer (int regnum);
-
extern void registers_changed (void);
extern void registers_fetched (void);
@@ -76,6 +79,4 @@ extern void write_register (int regnum, LONGEST val);
extern void write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid);
-extern void supply_register (int regnum, char *val);
-
#endif /* REGCACHE_H */
diff --git a/gdb/remote.c b/gdb/remote.c
index 2061985..52bde8a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3444,13 +3444,13 @@ store_register_using_P (int regno)
struct remote_state *rs = get_remote_state ();
/* Try storing a single register. */
char *buf = alloca (rs->remote_packet_size);
- char *regp;
+ char *regp = alloca (MAX_REGISTER_RAW_SIZE);
char *p;
int i;
sprintf (buf, "P%x=", regno);
p = buf + strlen (buf);
- regp = register_buffer (regno);
+ regcache_collect (regno, regp);
bin2hex (regp, p, REGISTER_RAW_SIZE (regno));
remote_send (buf, (rs->remote_packet_size));
@@ -3465,10 +3465,10 @@ static void
remote_store_registers (int regno)
{
struct remote_state *rs = get_remote_state ();
- char *buf = alloca (rs->remote_packet_size);
+ char *buf;
+ char *regs;
int i;
char *p;
- char *regs;
set_thread (PIDGET (inferior_ptid), 1);
@@ -3501,13 +3501,23 @@ remote_store_registers (int regno)
}
}
- buf[0] = 'G';
+ /* Extract all the registers in the regcache copying them into a
+ local buffer. */
+ {
+ int i;
+ regs = alloca (REGISTER_BYTES);
+ memset (regs, REGISTER_BYTES, 0);
+ for (i = 0; i < NUM_REGS; i++)
+ {
+ regcache_collect (i, regs + REGISTER_BYTE (i));
+ }
+ }
/* Command describes registers byte by byte,
each byte encoded as two hex characters. */
-
- regs = register_buffer (-1);
- p = buf + 1;
+ buf = alloca (rs->remote_packet_size);
+ p = buf;
+ *p++ = 'G';
/* remote_prepare_to_store insures that register_bytes_found gets set. */
bin2hex (regs, p, register_bytes_found);
remote_send (buf, (rs->remote_packet_size));