mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-01 20:12:01 +08:00
Class readonly_detached_regcache
This patch adds a new class (type) for readonly regcache, which is created via regcache::save. readonly_detached_regcache inherits readable_regcache. gdb: 2018-02-21 Yao Qi <yao.qi@linaro.org> * dummy-frame.c (dummy_frame_cache) <prev_regcache>: Use readonly_detached_regcache. (dummy_frame_prev_register): Use regcache->cooked_read. * frame.c (frame_save_as_regcache): Change return type. (frame_pop): Update. * frame.h (frame_save_as_regcache): Update declaration. * inferior.h (get_infcall_suspend_state_regcache): Update declaration. * infrun.c (infcall_suspend_state) <registers>: use readonly_detached_regcache. (save_infcall_suspend_state): Don't use regcache_dup. (get_infcall_suspend_state_regcache): Change return type. * linux-fork.c (struct fork_info) <savedregs>: Change to readonly_detached_regcache. <pc>: New field. (fork_save_infrun_state): Don't use regcache_dup. (info_checkpoints_command): Adjust. * mi/mi-main.c (register_changed_p): Update declaration. (mi_cmd_data_list_changed_registers): Use readonly_detached_regcache. (register_changed_p): Change parameter type to readonly_detached_regcache. * ppc-linux-tdep.c (ppu2spu_cache) <regcache>: Use readonly_detached_regcache. (ppu2spu_sniffer): Construct a new readonly_detached_regcache. * regcache.c (readonly_detached_regcache::readonly_detached_regcache): New. (regcache::save): Move it to reg_buffer. (regcache::restore): Change parameter type. (regcache_dup): Remove. * regcache.h (reg_buffer) <save>: New method. (readonly_detached_regcache): New class. * spu-tdep.c (spu2ppu_cache) <regcache>: Use readonly_detached_regcache. (spu2ppu_sniffer): Construct a new readonly_detached_regcache.
This commit is contained in:
@ -243,6 +243,11 @@ protected:
|
||||
|
||||
gdb_byte *register_buffer (int regnum) const;
|
||||
|
||||
/* Save a register cache. The set of registers saved into the
|
||||
regcache determined by the save_reggroup. COOKED_READ returns
|
||||
zero iff the register's value can't be returned. */
|
||||
void save (regcache_cooked_read_ftype *cooked_read, void *src);
|
||||
|
||||
struct regcache_descr *m_descr;
|
||||
|
||||
bool m_has_pseudo;
|
||||
@ -250,6 +255,8 @@ protected:
|
||||
gdb_byte *m_registers;
|
||||
/* Register cache status. */
|
||||
signed char *m_register_status;
|
||||
|
||||
friend class regcache;
|
||||
};
|
||||
|
||||
/* An abstract class which only has methods doing read. */
|
||||
@ -284,6 +291,8 @@ protected:
|
||||
bool is_raw);
|
||||
};
|
||||
|
||||
class readonly_detached_regcache;
|
||||
|
||||
/* The register cache for storing raw register values. */
|
||||
|
||||
class regcache : public readable_regcache
|
||||
@ -307,15 +316,11 @@ public:
|
||||
return m_aspace;
|
||||
}
|
||||
|
||||
/* Save/restore 'this' regcache. The set of registers saved /
|
||||
restored into the regcache determined by the save_reggroup /
|
||||
restore_reggroup respectively. COOKED_READ returns zero iff the
|
||||
register's value can't be returned. */
|
||||
void save (regcache_cooked_read_ftype *cooked_read, void *src);
|
||||
|
||||
/* Writes to regcache will go through to the target. SRC is a
|
||||
/* Restore 'this' regcache. The set of registers restored into
|
||||
the regcache determined by the restore_reggroup.
|
||||
Writes to regcache will go through to the target. SRC is a
|
||||
read-only register cache. */
|
||||
void restore (struct regcache *src);
|
||||
void restore (readonly_detached_regcache *src);
|
||||
|
||||
void cooked_write (int regnum, const gdb_byte *buf);
|
||||
|
||||
@ -413,9 +418,26 @@ private:
|
||||
registers_changed_ptid (ptid_t ptid);
|
||||
};
|
||||
|
||||
/* Duplicate the contents of a register cache to a read-only register
|
||||
cache. The operation is pass-through. */
|
||||
extern struct regcache *regcache_dup (struct regcache *regcache);
|
||||
class readonly_detached_regcache : public readable_regcache
|
||||
{
|
||||
public:
|
||||
readonly_detached_regcache (const regcache &src);
|
||||
|
||||
/* Create a readonly regcache by getting contents from COOKED_READ. */
|
||||
|
||||
readonly_detached_regcache (gdbarch *gdbarch,
|
||||
regcache_cooked_read_ftype *cooked_read,
|
||||
void *src)
|
||||
: readable_regcache (gdbarch, true)
|
||||
{
|
||||
save (cooked_read, src);
|
||||
}
|
||||
|
||||
DISABLE_COPY_AND_ASSIGN (readonly_detached_regcache);
|
||||
|
||||
void raw_update (int regnum) override
|
||||
{}
|
||||
};
|
||||
|
||||
extern void registers_changed (void);
|
||||
extern void registers_changed_ptid (ptid_t);
|
||||
|
Reference in New Issue
Block a user