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.h | |
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.h')
-rw-r--r-- | gdb/regcache.h | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/gdb/regcache.h b/gdb/regcache.h index 4ad0060..beebf99 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -68,14 +68,6 @@ extern void regcache_raw_write_unsigned (struct regcache *regcache, extern LONGEST regcache_raw_get_signed (struct regcache *regcache, int regnum); -/* Set a raw register's value in the regcache's buffer. Unlike - regcache_raw_write, this is not write-through. The intention is - allowing to change the buffer contents of a read-only regcache - allocated with new. */ - -extern void regcache_raw_set_cached_value - (struct regcache *regcache, int regnum, const gdb_byte *buf); - /* Partial transfer of raw registers. These perform read, modify, write style operations. The read variant returns the status of the register. */ @@ -229,12 +221,13 @@ public: /* Return regcache's architecture. */ gdbarch *arch () const; + enum register_status get_register_status (int regnum) const; + virtual ~reg_buffer () { xfree (m_registers); xfree (m_register_status); } - protected: /* Assert on the range of REGNUM. */ void assert_regnum (int regnum) const; @@ -257,6 +250,7 @@ protected: signed char *m_register_status; friend class regcache; + friend class detached_regcache; }; /* An abstract class which only has methods doing read. */ @@ -291,11 +285,33 @@ protected: bool is_raw); }; +/* Buffer of registers, can be read and written. */ + +class detached_regcache : public readable_regcache +{ +public: + detached_regcache (gdbarch *gdbarch, bool has_pseudo) + : readable_regcache (gdbarch, has_pseudo) + {} + + void raw_supply (int regnum, const void *buf); + + void raw_supply (int regnum, const reg_buffer &src) + { + raw_supply (regnum, src.register_buffer (regnum)); + } + + void raw_update (int regnum) override + {} + + DISABLE_COPY_AND_ASSIGN (detached_regcache); +}; + class readonly_detached_regcache; /* The register cache for storing raw register values. */ -class regcache : public readable_regcache +class regcache : public detached_regcache { public: regcache (gdbarch *gdbarch) @@ -339,17 +355,11 @@ public: void raw_collect_integer (int regnum, gdb_byte *addr, int addr_len, bool is_signed) const; - void raw_supply (int regnum, const void *buf); - void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len, bool is_signed); void raw_supply_zeroed (int regnum); - enum register_status get_register_status (int regnum) const; - - void raw_set_cached_value (int regnum, const gdb_byte *buf); - void invalidate (int regnum); void raw_write_part (int regnum, int offset, int len, const gdb_byte *buf); |