From 68365089fc7e8091f6b10a724a499f0e405721d4 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Fri, 2 Aug 2002 18:08:31 +0000 Subject: [PATCH] Add the cooked register interface. --- gdb/ChangeLog | 10 ++++++++++ gdb/regcache.c | 32 ++++++++++++++++++++++---------- gdb/regcache.h | 5 +++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 97b6d5b7ceb..69282443349 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2002-08-02 Andrew Cagney + + * regcache.c (regcache_cooked_read): New function. + (regcache_cooked_write): New function. + (read_register_gen): Rewrite using regcache_cooked_read. + (write_register_gen): Rewrite using regcache_cooked_write. + + * regcache.h (regcache_cooked_read, regcache_cooked_write): + Declare. + 2002-08-02 Andrew Cagney * gdbarch.sh (pseudo_register_read, pseudo_register_write): diff --git a/gdb/regcache.c b/gdb/regcache.c index 7d4a8d6de2e..70af8f093bd 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -719,16 +719,21 @@ read_register_gen (int regnum, char *buf) legacy_read_register_gen (regnum, buf); return; } + regcache_cooked_read (current_regcache, regnum, buf); +} + +void +regcache_cooked_read (struct regcache *regcache, int rawnum, void *buf) +{ gdb_assert (regnum >= 0); - gdb_assert (regnum < current_regcache->descr->nr_cooked_registers); - if (regnum < current_regcache->descr->nr_raw_registers) - regcache_raw_read (current_regcache, regnum, buf); + gdb_assert (regnum < regcache->descr->nr_cooked_registers); + if (regnum < regcache->descr->nr_raw_registers) + regcache_raw_read (regcache, regnum, buf); else - gdbarch_pseudo_register_read (current_gdbarch, current_regcache, - regnum, buf); + gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache, + regnum, buf); } - /* Write register REGNUM at MYADDR to the target. MYADDR points at REGISTER_RAW_BYTES(REGNUM), which must be in target byte-order. */ @@ -834,12 +839,19 @@ write_register_gen (int regnum, char *buf) legacy_write_register_gen (regnum, buf); return; } + regcache_cooked_write (current_regcache, regnum, buf); +} + +void +regcache_cooked_write (struct regcache *regcache, int rawnum, + const void *buf) +{ gdb_assert (regnum >= 0); - gdb_assert (regnum < current_regcache->descr->nr_cooked_registers); - if (regnum < current_regcache->descr->nr_raw_registers) - regcache_raw_write (current_regcache, regnum, buf); + gdb_assert (regnum < regcache->descr->nr_cooked_registers); + if (regnum < regcache->descr->nr_raw_registers) + regcache_raw_write (regcache, regnum, buf); else - gdbarch_pseudo_register_write (current_gdbarch, current_regcache, + gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache, regnum, buf); } diff --git a/gdb/regcache.h b/gdb/regcache.h index cd5bb83ee30..5ca7babad67 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -41,6 +41,11 @@ void regcache_raw_write (struct regcache *regcache, int rawnum, int regcache_valid_p (struct regcache *regcache, int regnum); CORE_ADDR regcache_raw_read_as_address (struct regcache *regcache, int rawnum); +/* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */ +void regcache_cooked_read (struct regcache *regcache, int rawnum, void *buf); +void regcache_cooked_write (struct regcache *regcache, int rawnum, + const void *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(). */ -- 2.30.2