diff options
author | Alan Hayward <alan.hayward@arm.com> | 2017-05-26 17:04:13 +0100 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2017-05-26 17:07:52 +0100 |
commit | b057297ab63a9124aae1773566815cd8c4bde8e9 (patch) | |
tree | 73fedbfc92512c26f04333e433adefa2f2c0a907 /gdb/regcache.c | |
parent | 22e7d2933103f1384c1d54dff6188cd57cbe171a (diff) | |
download | gdb-b057297ab63a9124aae1773566815cd8c4bde8e9.zip gdb-b057297ab63a9124aae1773566815cd8c4bde8e9.tar.gz gdb-b057297ab63a9124aae1773566815cd8c4bde8e9.tar.bz2 |
Add regcache raw_supply_integer and raw_collect_integer.
Use these to replace instances of MAX_REGISTER_SIZE.
* defs.h (copy_integer_to_size): New declaration.
* findvar.c (copy_integer_to_size): New function.
(do_cint_test): New selftest function.
(copy_integer_to_size_test): Likewise.
(_initialize_findvar): Likewise.
* mips-fbsd-tdep.c (mips_fbsd_supply_reg): Use raw_supply_integer.
(mips_fbsd_collect_reg): Use raw_collect_integer.
* mips-linux-tdep.c (supply_32bit_reg): Use raw_supply_integer.
(mips64_fill_gregset): Use raw_collect_integer
(mips64_fill_fpregset): Use raw_supply_integer.
* regcache.c (regcache::raw_supply_integer): New function.
(regcache::raw_collect_integer): Likewise.
* regcache.h: (regcache::raw_supply_integer): New declaration.
(regcache::raw_collect_integer): Likewise.
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r-- | gdb/regcache.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c index 7638eea..3798f0a 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1179,6 +1179,31 @@ regcache::raw_supply (int regnum, const void *buf) } } +/* Supply register REGNUM to REGCACHE. Value to supply is an integer stored at + address ADDR, in target endian, with length ADDR_LEN and sign IS_SIGNED. If + the register size is greater than ADDR_LEN, then the integer will be sign or + zero extended. If the register size is smaller than the integer, then the + most significant bytes of the integer will be truncated. */ + +void +regcache::raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len, + bool is_signed) +{ + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); + gdb_byte *regbuf; + size_t regsize; + + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); + gdb_assert (!m_readonly_p); + + regbuf = register_buffer (regnum); + regsize = m_descr->sizeof_register[regnum]; + + copy_integer_to_size (regbuf, regsize, addr, addr_len, is_signed, + byte_order); + m_register_status[regnum] = REG_VALID; +} + /* Supply register REGNUM with zeroed value to REGCACHE. This is not the same as calling raw_supply with NULL (which will set the state to unavailable). */ @@ -1226,6 +1251,29 @@ regcache::raw_collect (int regnum, void *buf) const set to or from a buffer. This is the main worker function for regcache_supply_regset and regcache_collect_regset. */ +/* Collect register REGNUM from REGCACHE. Store collected value as an integer + at address ADDR, in target endian, with length ADDR_LEN and sign IS_SIGNED. + If ADDR_LEN is greater than the register size, then the integer will be sign + or zero extended. If ADDR_LEN is smaller than the register size, then the + most significant bytes of the integer will be truncated. */ + +void +regcache::raw_collect_integer (int regnum, gdb_byte *addr, int addr_len, + bool is_signed) const +{ + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); + const gdb_byte *regbuf; + size_t regsize; + + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); + + regbuf = register_buffer (regnum); + regsize = m_descr->sizeof_register[regnum]; + + copy_integer_to_size (addr, addr_len, regbuf, regsize, is_signed, + byte_order); +} + void regcache::transfer_regset (const struct regset *regset, struct regcache *out_regcache, |