diff options
author | Mark Kettenis <kettenis@gnu.org> | 2003-08-29 09:59:28 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2003-08-29 09:59:28 +0000 |
commit | 9a661b68d1e9919e0bf6e716288801d9268709be (patch) | |
tree | 4a3c87d493fcec6ca01b788e8cad94f9802c2f7d /gdb | |
parent | 71df864f7b5fdcb724360f60ca23a107e9adff52 (diff) | |
download | gdb-9a661b68d1e9919e0bf6e716288801d9268709be.zip gdb-9a661b68d1e9919e0bf6e716288801d9268709be.tar.gz gdb-9a661b68d1e9919e0bf6e716288801d9268709be.tar.bz2 |
* regcache.c (register_buffer): Consitify first argument.
(regcache_raw_supply, regcache_raw_collect): New
functions.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/regcache.c | 55 | ||||
-rw-r--r-- | gdb/regcache.h | 4 |
3 files changed, 64 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c15dcc2..c8d72bd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-08-28 Mark Kettenis <kettenis@gnu.org> + + * regcache.c (register_buffer): Consitify first argument. + (regcache_raw_supply, regcache_raw_collect): New + functions. + 2003-08-28 Daniel Jacobowitz <drow@mvista.com> * config/powerpc/tm-nbsd.h: Undefine IBM6000_TARGET. Suggested diff --git a/gdb/regcache.c b/gdb/regcache.c index 5c7f0ca..1db86e8 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -345,7 +345,7 @@ make_cleanup_regcache_xfree (struct regcache *regcache) /* 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_ADDR val, ptid_t ptid) 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 @@ -1252,6 +1256,55 @@ regcache_collect (int regnum, void *buf) 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); +} + /* read_pc, write_pc, read_sp, deprecated_read_fp, etc. Special handling for registers PC, SP, and FP. */ diff --git a/gdb/regcache.h b/gdb/regcache.h index f848205..b8ac182 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -94,6 +94,10 @@ void regcache_cooked_write_part (struct regcache *regcache, int regnum, 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''. |