diff options
author | Yao Qi <yao.qi@linaro.org> | 2018-02-21 11:20:03 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2018-02-21 11:20:03 +0000 |
commit | c8ec2f334c3751c28d5f952d07dea9c0558ca0a0 (patch) | |
tree | 5a6e3a58f37632ab54059d2275d77c515154c76e /gdb/regcache.c | |
parent | daf6667d1f94c7e74df4076daf021cd28a2797b6 (diff) | |
download | gdb-c8ec2f334c3751c28d5f952d07dea9c0558ca0a0.zip gdb-c8ec2f334c3751c28d5f952d07dea9c0558ca0a0.tar.gz gdb-c8ec2f334c3751c28d5f952d07dea9c0558ca0a0.tar.bz2 |
Class detached_regcache
jit.c uses the regcache in a slightly different way, the regcache dosen't
write through to target, but it has read and write methods. If I apply
regcache in record-full.c, it has the similar use pattern. This patch
adds a new class detached_regcache, a register buffer, but can be
read and written.
Since jit.c doesn't want to write registers through to target, it uses
regcache as a readonly regcache (because only readonly regcache
disconnects from the target), but it adds a hole in regcache
(raw_set_cached_value) in order to modify a readonly regcache. This patch
fixes this hole completely.
regcache inherits detached_regcache, and detached_regcache inherits
readable_regcache. The ideal design is that both detached_regcache and
readable_regcache inherit reg_buffer, and regcache inherit
detached_regcache and regcache_read (virtual inheritance). I concern
about the performance overhead of virtual inheritance, so I don't do it in
the patch.
gdb:
2018-02-21 Yao Qi <yao.qi@linaro.org>
* jit.c (struct jit_unwind_private) <regcache>: Change its type to
reg_buffer_rw *.
(jit_unwind_reg_set_impl): Call raw_supply.
(jit_frame_sniffer): Use reg_buffer_rw.
* record-full.c (record_full_core_regbuf): Change its type.
(record_full_core_open_1): Use reg_buffer_rw.
(record_full_close): Likewise.
(record_full_core_fetch_registers): Use regcache->raw_supply.
(record_full_core_store_registers): Likewise.
* regcache.c (regcache::get_register_status): Move it to
reg_buffer.
(regcache_raw_set_cached_value): Remove.
(regcache::raw_set_cached_value): Remove.
(regcache::raw_write): Call raw_supply.
(regcache::raw_supply): Move it to reg_buffer_rw.
* regcache.h (regcache_raw_set_cached_value): Remove.
(reg_buffer_rw): New class.
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r-- | gdb/regcache.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c index ebe3c7b..c757231 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -205,7 +205,7 @@ regcache::regcache (gdbarch *gdbarch, const address_space *aspace_, /* The register buffers. A read-only register cache can hold the full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write register cache can only hold [0 .. gdbarch_num_regs). */ - : readable_regcache (gdbarch, readonly_p_), + : detached_regcache (gdbarch, readonly_p_), m_aspace (aspace_), m_readonly_p (readonly_p_) { m_ptid = minus_one_ptid; @@ -353,13 +353,9 @@ regcache_register_status (const struct regcache *regcache, int regnum) } enum register_status -regcache::get_register_status (int regnum) const +reg_buffer::get_register_status (int regnum) const { - gdb_assert (regnum >= 0); - if (m_readonly_p) - gdb_assert (regnum < m_descr->nr_cooked_registers); - else - gdb_assert (regnum < num_raw_registers ()); + assert_regnum (regnum); return (enum register_status) m_register_status[regnum]; } @@ -802,23 +798,6 @@ regcache_cooked_write_unsigned (struct regcache *regcache, int regnum, regcache->cooked_write (regnum, val); } -/* See regcache.h. */ - -void -regcache_raw_set_cached_value (struct regcache *regcache, int regnum, - const gdb_byte *buf) -{ - regcache->raw_set_cached_value (regnum, buf); -} - -void -regcache::raw_set_cached_value (int regnum, const gdb_byte *buf) -{ - memcpy (register_buffer (regnum), buf, - m_descr->sizeof_register[regnum]); - m_register_status[regnum] = REG_VALID; -} - void regcache_raw_write (struct regcache *regcache, int regnum, const gdb_byte *buf) @@ -848,7 +827,7 @@ regcache::raw_write (int regnum, const gdb_byte *buf) return; target_prepare_to_store (this); - raw_set_cached_value (regnum, buf); + raw_supply (regnum, buf); /* Invalidate the register after it is written, in case of a failure. */ @@ -1024,13 +1003,12 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf) } void -regcache::raw_supply (int regnum, const void *buf) +detached_regcache::raw_supply (int regnum, const void *buf) { void *regbuf; size_t size; assert_regnum (regnum); - gdb_assert (!m_readonly_p); regbuf = register_buffer (regnum); size = m_descr->sizeof_register[regnum]; |