From 9fa4f9dd3d0f4e7f35436ba6244f19e49e648aec Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Tue, 3 Oct 2017 15:23:40 +0100 Subject: Simplify xfer_part Since xfer_part is already a class method, and only {raw,cooked}_{read,write} are passed to it. We can remove these two arguments, but add a bool argument is_raw, indicating raw registers or cooked registers are accessed. gdb: 2017-10-03 Yao Qi : * regcache.c (typedef void): (regcache::xfer_part): (regcache::xfer_part): (enum register_status): (regcache::raw_write_part): (enum register_status): (regcache::cooked_write_part): (regcache_raw_supply): - (regcache_raw_supply): + (aarch32_gp_regcache_supply): - (aarch32_gp_regcache_supply): + (aarch32_gp_regcache_supply): (aarch32_gp_regcache_collect): - (aarch32_gp_regcache_collect): + (aarch32_gp_regcache_collect): (aarch32_vfp_regcache_supply): - (aarch32_vfp_regcache_supply): + (aarch32_vfp_regcache_supply): (aarch32_vfp_regcache_collect): - (aarch32_vfp_regcache_collect): + (aarch64_get_debug_reg_state): (fetch_gregs_from_thread): - (fetch_gregs_from_thread): + (fetch_gregs_from_thread): (store_gregs_to_thread): - (store_gregs_to_thread): + (store_gregs_to_thread): (fetch_fpregs_from_thread): - (fetch_fpregs_from_thread): + (fetch_fpregs_from_thread): (store_fpregs_to_thread): - (store_fpregs_to_thread): + (store_fpregs_to_thread): (aarch64_linux_fetch_inferior_registers): (default_addressable_memory_unit_size): (extern const char *default_gnu_triplet_regexp): (static struct tramp_frame arm_kernel_linux_restart_syscall_tramp_frame = {): (arm_linux_supply_gregset): (arm_linux_collect_gregset): (supply_nwfpe_register): - (supply_nwfpe_register): + (supply_nwfpe_register): (collect_nwfpe_register): - (collect_nwfpe_register): + (collect_nwfpe_register): (arm_linux_supply_nwfpe): (arm_linux_collect_nwfpe): (arm_linux_supply_vfp): (void arm_linux_collect_gregset): (core_detach): (get_core_register_section): - (get_core_register_section): + (get_core_registers_cb): (set_gdbarch_fast_tracepoint_valid_at): (gdbarch_guess_tracepoint_registers): - (gdbarch_guess_tracepoint_registers): + (extern void set_gdbarch_fast_tracepoint_valid_at): (m;int;fast_tracepoint_valid_at;CORE_ADDR addr, char **msg;addr, msg;;default_fas): (struct core_fns): (store_waitstatus): (inf_child_fetch_inferior_registers): (inf_child_post_attach): (static CORE_ADDR): (inf_ptrace_fetch_register): - (inf_ptrace_fetch_register): + (inf_ptrace_fetch_register): (inf_ptrace_fetch_registers): (inf_ptrace_store_register): - (inf_ptrace_store_register): + (inf_ptrace_store_register): (record_btrace_remove_breakpoint): (record_btrace_fetch_registers): (record_btrace_store_registers): (static void record_full_save): (record_full_reg_alloc): - (record_full_reg_alloc): + (record_full_get_loc): (record_full_arch_list_add_reg): - (record_full_arch_list_add_reg): + (record_full_supports_stopped_by_hw_breakpoint): (record_full_registers_change): - (record_full_registers_change): + (record_full_registers_change): (record_full_core_kill): (record_full_core_fetch_registers): (record_full_core_prepare_to_store): (regcache_register_size): (regcache::regcache): (regcache::arch): (regcache_get_ptid): - (regcache_get_ptid): + (class regcache_invalidator): (public:): (public:): (get_regcache_arch): - (get_regcache_arch): + (regcache_dup): (regcache_register_status): - (regcache_register_status): + (reg_buffer::set_register_status): (regcache_invalidate): - (regcache_invalidate): + (registers_changed): (regcache_raw_update): - (regcache_raw_update): + (regcache_raw_update): (regcache::raw_update): (regcache_raw_read): - (regcache_raw_read): + (regcache_raw_read_signed): (regcache_raw_write_signed): (regcache_raw_write): (reg_buffer::raw_supply_zeroed): (regcache_raw_collect): - (regcache_raw_collect): + (reg_buffer::transfer_regset): (reg_buffer::supply_regset): (regcache_write_pc): (struct regcache;): (extern struct regcache *get_thread_arch_aspace_regcache): (extern enum register_status): (extern void regcache_write_pc): (enum): (private:): (public:): (public:): (public:): (public:): (private:): (struct regcache;): (static int getpkt_or_notif_sane): (remote_wait): (fetch_register_using_p): - (fetch_register_using_p): + (send_g_packet): (process_g_packet): - (process_g_packet): + (process_g_packet): (fetch_registers_using_g): - (fetch_registers_using_g): + (set_remote_traceframe): (remote_fetch_registers): (remote_prepare_to_store): - (remote_prepare_to_store): + (remote_prepare_to_store): (store_register_using_P): - (store_register_using_P): + (store_register_using_P): (store_registers_using_G): - (store_registers_using_G): + (store_registers_using_G): (s390_write_pc): (debug_wait): (delegate_fetch_registers): - (delegate_fetch_registers): + (tdefault_fetch_registers): - (tdefault_fetch_registers): + (debug_fetch_registers): - (debug_fetch_registers): + (delegate_store_registers): - (delegate_store_registers): + (tdefault_store_registers): - (tdefault_store_registers): + (debug_store_registers): - (debug_store_registers): + (delegate_prepare_to_store): - (delegate_prepare_to_store): + (tdefault_prepare_to_store): - (tdefault_prepare_to_store): + (debug_prepare_to_store): - (debug_prepare_to_store): + (target_options_to_string): (target_fetch_registers): - (target_fetch_registers): + (target_fetch_registers): (target_store_registers): - (target_store_registers): + (struct target_ops): (extern ptid_t default_target_wait): (traceframe_find_block_type): (trace_save_ctf): (tracefile_fetch_registers): - (tracefile_fetch_registers): + (extern struct trace_file_writer *tfile_trace_file_writer_new): --- gdb/regcache.c | 30 +++++++++++++----------------- gdb/regcache.h | 4 +--- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/gdb/regcache.c b/gdb/regcache.c index bf448ef..eb2f967 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -915,12 +915,7 @@ typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum, enum register_status regcache::xfer_part (int regnum, int offset, int len, void *in, - const void *out, - enum register_status (*read) (struct regcache *regcache, - int regnum, - gdb_byte *buf), - void (*write) (struct regcache *regcache, int regnum, - const gdb_byte *buf)) + const void *out, bool is_raw) { struct gdbarch *gdbarch = arch (); gdb_byte *reg = (gdb_byte *) alloca (register_size (gdbarch, regnum)); @@ -938,7 +933,10 @@ regcache::xfer_part (int regnum, int offset, int len, void *in, enum register_status status; gdb_assert (read != NULL); - status = read (this, regnum, reg); + if (is_raw) + status = raw_read (regnum, reg); + else + status = cooked_read (regnum, reg); if (status != REG_VALID) return status; } @@ -950,8 +948,10 @@ regcache::xfer_part (int regnum, int offset, int len, void *in, /* ... write (when needed). */ if (out != NULL) { - gdb_assert (write != NULL); - write (this, regnum, reg); + if (is_raw) + raw_write (regnum, reg); + else + raw_write (regnum, reg); } return REG_VALID; @@ -968,8 +968,7 @@ enum register_status regcache::raw_read_part (int regnum, int offset, int len, gdb_byte *buf) { gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); - return xfer_part (regnum, offset, len, buf, NULL, - regcache_raw_read, regcache_raw_write); + return xfer_part (regnum, offset, len, buf, NULL, true); } void @@ -984,8 +983,7 @@ regcache::raw_write_part (int regnum, int offset, int len, const gdb_byte *buf) { gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); - xfer_part (regnum, offset, len, NULL, buf, regcache_raw_read, - regcache_raw_write); + xfer_part (regnum, offset, len, NULL, buf, true); } enum register_status @@ -1000,8 +998,7 @@ enum register_status regcache::cooked_read_part (int regnum, int offset, int len, gdb_byte *buf) { gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers); - return xfer_part (regnum, offset, len, buf, NULL, - regcache_cooked_read, regcache_cooked_write); + return xfer_part (regnum, offset, len, buf, NULL, false); } void @@ -1016,8 +1013,7 @@ regcache::cooked_write_part (int regnum, int offset, int len, const gdb_byte *buf) { gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers); - xfer_part (regnum, offset, len, NULL, buf, - regcache_cooked_read, regcache_cooked_write); + xfer_part (regnum, offset, len, NULL, buf, false); } /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */ diff --git a/gdb/regcache.h b/gdb/regcache.h index 6f42fb9..460d83f 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -354,9 +354,7 @@ private: void restore (struct regcache *src); enum register_status xfer_part (int regnum, int offset, int len, void *in, - const void *out, - decltype (regcache_raw_read) read, - decltype (regcache_raw_write) write); + const void *out, bool is_raw); void transfer_regset (const struct regset *regset, struct regcache *out_regcache, -- cgit v1.1