From: Tankut Baris Aktemur Date: Thu, 2 Apr 2020 13:11:28 +0000 (+0200) Subject: gdbserver/linux-low: turn '{collect, supply}_ptrace_register' into methods X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b35db73327cf54445a20533305fcf705e88a520b;p=binutils-gdb.git gdbserver/linux-low: turn '{collect, supply}_ptrace_register' into methods gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur Turn the 'collect_ptrace_register' and 'supply_ptrace_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the ops. (class linux_process_target) : Declare. * linux-low.cc (linux_process_target::low_collect_ptrace_register) (linux_process_target::low_supply_ptrace_register): Define. Update the callers below. (linux_process_target::fetch_register) (linux_process_target::store_register) * linux-x86-low.cc (the_low_target): Remove the op fields. * linux-aarch64-low.cc (the_low_target): Ditto. * linux-arm-low.cc (the_low_target): Ditto. * linux-bfin-low.cc (the_low_target): Ditto. * linux-crisv32-low.cc (the_low_target): Ditto. * linux-m32r-low.cc (the_low_target): Ditto. * linux-m68k-low.cc (the_low_target): Ditto. * linux-sh-low.cc (the_low_target): Ditto. * linux-sparc-low.cc (the_low_target): Ditto. * linux-tic6x-low.cc (the_low_target): Ditto. * linux-tile-low.cc (the_low_target): Ditto. * linux-xtensa-low.cc (the_low_target): Ditto. * linux-mips-low.cc (class mips_target) : Declare. (mips_collect_ptrace_register): Turn into ... (mips_target::low_collect_ptrace_register): ...this. (mips_supply_ptrace_register): Turn into... (mips_target::low_supply_ptrace_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) : Declare. (ppc_collect_ptrace_register): Turn into ... (ppc_target::low_collect_ptrace_register): ...this. (ppc_supply_ptrace_register): Turn into ... (ppc_target::low_supply_ptrace_register): ...this. (ppc_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) : Declare. (s390_collect_ptrace_register): Turn into ... (s390_target::low_collect_ptrace_register): ...this. (s390_supply_ptrace_register): Turn into ... (s390_target::low_supply_ptrace_register): ...this. (s390_fill_gregset): Update for the calls to low_collect_ptrace_register. (the_low_target): Remove the op fields. --- diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index 0b17ea5be26..f8a2bd802b3 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,3 +1,60 @@ +2020-04-02 Tankut Baris Aktemur + + Turn the 'collect_ptrace_register' and 'supply_ptrace_register' + linux target ops into methods of linux_process_target. + + * linux-low.h (struct linux_target_ops): Remove the ops. + (class linux_process_target) + : Declare. + * linux-low.cc (linux_process_target::low_collect_ptrace_register) + (linux_process_target::low_supply_ptrace_register): Define. + + Update the callers below. + + (linux_process_target::fetch_register) + (linux_process_target::store_register) + + * linux-x86-low.cc (the_low_target): Remove the op fields. + * linux-aarch64-low.cc (the_low_target): Ditto. + * linux-arm-low.cc (the_low_target): Ditto. + * linux-bfin-low.cc (the_low_target): Ditto. + * linux-crisv32-low.cc (the_low_target): Ditto. + * linux-m32r-low.cc (the_low_target): Ditto. + * linux-m68k-low.cc (the_low_target): Ditto. + * linux-sh-low.cc (the_low_target): Ditto. + * linux-sparc-low.cc (the_low_target): Ditto. + * linux-tic6x-low.cc (the_low_target): Ditto. + * linux-tile-low.cc (the_low_target): Ditto. + * linux-xtensa-low.cc (the_low_target): Ditto. + * linux-mips-low.cc (class mips_target) + + : Declare. + (mips_collect_ptrace_register): Turn into ... + (mips_target::low_collect_ptrace_register): ...this. + (mips_supply_ptrace_register): Turn into... + (mips_target::low_supply_ptrace_register): ...this. + (the_low_target): Remove the op fields. + * linux-ppc-low.cc (class ppc_target) + + : Declare. + (ppc_collect_ptrace_register): Turn into ... + (ppc_target::low_collect_ptrace_register): ...this. + (ppc_supply_ptrace_register): Turn into ... + (ppc_target::low_supply_ptrace_register): ...this. + (ppc_fill_gregset): Update for the calls to + low_collect_ptrace_register. + (the_low_target): Remove the op fields. + * linux-s390-low.cc (class s390_target) + + : Declare. + (s390_collect_ptrace_register): Turn into ... + (s390_target::low_collect_ptrace_register): ...this. + (s390_supply_ptrace_register): Turn into ... + (s390_target::low_supply_ptrace_register): ...this. + (s390_fill_gregset): Update for the calls to + low_collect_ptrace_register. + (the_low_target): Remove the op fields. + 2020-04-02 Tankut Baris Aktemur Turn the 'stopped_by_watchpoint' and 'stopped_data_address' linux diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 96f8f46d4ee..dfbfa59cba1 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -3113,8 +3113,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ aarch64_linux_siginfo_fixup, aarch64_linux_new_process, aarch64_linux_delete_process, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index 2593dfa0eee..78e93d304f5 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -1105,8 +1105,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ arm_new_process, arm_delete_process, diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index bc3e312c18f..5f0d72fed74 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -171,8 +171,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index fd458350d5a..fe4b68ef4d8 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -468,8 +468,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 998bd1d0595..658ea32f135 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -5408,10 +5408,7 @@ linux_process_target::fetch_register (const usrregs_info *usrregs, } } - if (the_low_target.supply_ptrace_register) - the_low_target.supply_ptrace_register (regcache, regno, buf); - else - supply_register (regcache, regno, buf); + low_supply_ptrace_register (regcache, regno, buf); } void @@ -5438,10 +5435,7 @@ linux_process_target::store_register (const usrregs_info *usrregs, buf = (char *) alloca (size); memset (buf, 0, size); - if (the_low_target.collect_ptrace_register) - the_low_target.collect_ptrace_register (regcache, regno, buf); - else - collect_register (regcache, regno, buf); + low_collect_ptrace_register (regcache, regno, buf); pid = lwpid_of (current_thread); for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE)) @@ -5470,6 +5464,20 @@ linux_process_target::store_register (const usrregs_info *usrregs, } #endif /* HAVE_LINUX_USRREGS */ +void +linux_process_target::low_collect_ptrace_register (regcache *regcache, + int regno, char *buf) +{ + collect_register (regcache, regno, buf); +} + +void +linux_process_target::low_supply_ptrace_register (regcache *regcache, + int regno, const char *buf) +{ + supply_register (regcache, regno, buf); +} + void linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info, regcache *regcache, diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index ee2fdb8e865..ca6cf3edc1c 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,13 +131,6 @@ struct lwp_info; struct linux_target_ops { - /* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular - for registers smaller than an xfer unit). */ - void (*collect_ptrace_register) (struct regcache *regcache, - int regno, char *buf); - void (*supply_ptrace_register) (struct regcache *regcache, - int regno, const char *buf); - /* Hook to convert from target format to ptrace format and back. Returns true if any conversion was done; false otherwise. If DIRECTION is 1, then copy from INF to NATIVE. @@ -682,6 +675,14 @@ protected: virtual CORE_ADDR low_stopped_data_address (); + /* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular + for registers smaller than an xfer unit). */ + virtual void low_collect_ptrace_register (regcache *regcache, int regno, + char *buf); + + virtual void low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf); + /* How many bytes the PC should be decremented after a break. */ virtual int low_decr_pc_after_break (); }; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 14bb83797d9..2dc25f7c668 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -161,8 +161,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index 7cb80bc2af4..84eccbc14ef 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -265,8 +265,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index 3c2231bda30..78e243c3d40 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -64,6 +64,12 @@ protected: bool low_stopped_by_watchpoint () override; CORE_ADDR low_stopped_data_address () override; + + void low_collect_ptrace_register (regcache *regcache, int regno, + char *buf) override; + + void low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf) override; }; /* The singleton target ops object. */ @@ -891,9 +897,9 @@ mips_store_fpregset (struct regcache *regcache, const void *buf) /* Take care of 32-bit registers with 64-bit ptrace, POKEUSER side. */ -static void -mips_collect_ptrace_register (struct regcache *regcache, - int regno, char *buf) +void +mips_target::low_collect_ptrace_register (regcache *regcache, int regno, + char *buf) { int use_64bit = sizeof (PTRACE_XFER_TYPE) == 8; @@ -910,9 +916,9 @@ mips_collect_ptrace_register (struct regcache *regcache, /* Take care of 32-bit registers with 64-bit ptrace, PEEKUSER side. */ -static void -mips_supply_ptrace_register (struct regcache *regcache, - int regno, const char *buf) +void +mips_target::low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf) { int use_64bit = sizeof (PTRACE_XFER_TYPE) == 8; @@ -980,8 +986,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - mips_collect_ptrace_register, - mips_supply_ptrace_register, NULL, /* siginfo_fixup */ mips_linux_new_process, mips_linux_delete_process, diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index deb2ef64f12..e0310856c20 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -56,6 +56,12 @@ public: bool supports_z_point_type (char z_type) override; + + void low_collect_ptrace_register (regcache *regcache, int regno, + char *buf) override; + + void low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf) override; protected: void low_arch_setup () override; @@ -208,8 +214,9 @@ ppc_target::low_cannot_fetch_register (int regno) return false; } -static void -ppc_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) +void +ppc_target::low_collect_ptrace_register (regcache *regcache, int regno, + char *buf) { memset (buf, 0, sizeof (long)); @@ -234,9 +241,9 @@ ppc_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) perror_with_name ("Unexpected byte order"); } -static void -ppc_supply_ptrace_register (struct regcache *regcache, - int regno, const char *buf) +void +ppc_target::low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf) { if (__BYTE_ORDER == __LITTLE_ENDIAN) { @@ -401,14 +408,19 @@ static void ppc_fill_gregset (struct regcache *regcache, void *buf) { int i; + ppc_target *my_ppc_target = (ppc_target *) the_linux_target; + for (i = 0; i < 32; i++) - ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); + my_ppc_target->low_collect_ptrace_register (regcache, i, + (char *) buf + ppc_regmap[i]); for (i = 64; i < 70; i++) - ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); + my_ppc_target->low_collect_ptrace_register (regcache, i, + (char *) buf + ppc_regmap[i]); for (i = 71; i < 73; i++) - ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); + my_ppc_target->low_collect_ptrace_register (regcache, i, + (char *) buf + ppc_regmap[i]); } /* Program Priority Register regset fill function. */ @@ -3416,8 +3428,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - ppc_collect_ptrace_register, - ppc_supply_ptrace_register, NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 9e7db23e5d0..f7e439ac612 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -63,6 +63,12 @@ public: bool supports_z_point_type (char z_type) override; + void low_collect_ptrace_register (regcache *regcache, int regno, + char *buf) override; + + void low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf) override; + protected: void low_arch_setup () override; @@ -187,11 +193,12 @@ s390_target::low_cannot_store_register (int regno) return false; } -static void -s390_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) +void +s390_target::low_collect_ptrace_register (regcache *regcache, int regno, + char *buf) { int size = register_size (regcache->tdesc, regno); - const struct regs_info *regs_info = the_linux_target->get_regs_info (); + const struct regs_info *regs_info = get_regs_info (); struct usrregs_info *usr = regs_info->usrregs; int regaddr = usr->regmap[regno]; @@ -233,12 +240,12 @@ s390_collect_ptrace_register (struct regcache *regcache, int regno, char *buf) collect_register (regcache, regno, buf); } -static void -s390_supply_ptrace_register (struct regcache *regcache, - int regno, const char *buf) +void +s390_target::low_supply_ptrace_register (regcache *regcache, int regno, + const char *buf) { int size = register_size (regcache->tdesc, regno); - const struct regs_info *regs_info = the_linux_target->get_regs_info (); + const struct regs_info *regs_info = get_regs_info (); struct usrregs_info *usr = regs_info->usrregs; int regaddr = usr->regmap[regno]; @@ -305,8 +312,8 @@ s390_fill_gregset (struct regcache *regcache, void *buf) || usr->regmap[i] > PT_ACR15) continue; - s390_collect_ptrace_register (regcache, i, - (char *) buf + usr->regmap[i]); + ((s390_target *) the_linux_target)->low_collect_ptrace_register + (regcache, i, (char *) buf + usr->regmap[i]); } } @@ -2838,8 +2845,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - s390_collect_ptrace_register, - s390_supply_ptrace_register, NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index a2215ddb4bc..08985338db3 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -192,8 +192,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index 8d1b61b0631..e77ebe52805 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -341,7 +341,6 @@ sparc_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, NULL }; /* The linux target ops object. */ diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 9ff23969c6c..8f5eff7fdb5 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -423,8 +423,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 6efd7b2c8c3..72697649fbc 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -224,8 +224,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 1c6e9b1d100..d33833daa6c 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -137,6 +137,10 @@ protected: bool low_stopped_by_watchpoint () override; CORE_ADDR low_stopped_data_address () override; + + /* collect_ptrace_register/supply_ptrace_register are not needed in the + native i386 case (no registers smaller than an xfer unit), and are not + used in the biarch case (HAVE_LINUX_USRREGS is not defined). */ }; /* The singleton target ops object. */ @@ -2922,11 +2926,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - /* collect_ptrace_register/supply_ptrace_register are not needed in the - native i386 case (no registers smaller than an xfer unit), and are not - used in the biarch case (HAVE_LINUX_USRREGS is not defined). */ - NULL, - NULL, /* need to fix up i386 siginfo if host is amd64 */ x86_siginfo_fixup, x86_linux_new_process, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index 7bc09e99629..08487145337 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -329,8 +329,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, /* collect_ptrace_register */ - NULL, /* supply_ptrace_register */ NULL, /* siginfo_fixup */ NULL, /* new_process */ NULL, /* delete_process */