From patchwork Fri Mar 6 21:31:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 38500 Received: (qmail 53012 invoked by alias); 6 Mar 2020 21:32:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 52305 invoked by uid 89); 6 Mar 2020 21:32:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2020 21:32:23 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 13:32:21 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 06 Mar 2020 13:32:20 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 026LWJEK022477; Fri, 6 Mar 2020 21:32:19 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 026LWJMv020467; Fri, 6 Mar 2020 22:32:19 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 026LWIJG020463; Fri, 6 Mar 2020 22:32:19 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 18/31] gdbserver/linux-low: turn '{collect, supply}_ptrace_register' into methods Date: Fri, 6 Mar 2020 22:31:26 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-03-06 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. --- gdbserver/linux-aarch64-low.cc | 2 -- gdbserver/linux-arm-low.cc | 2 -- gdbserver/linux-bfin-low.cc | 2 -- gdbserver/linux-crisv32-low.cc | 2 -- gdbserver/linux-low.cc | 24 ++++++++++++++++-------- gdbserver/linux-low.h | 15 ++++++++------- gdbserver/linux-m32r-low.cc | 2 -- gdbserver/linux-m68k-low.cc | 2 -- gdbserver/linux-mips-low.cc | 20 ++++++++++++-------- gdbserver/linux-ppc-low.cc | 30 ++++++++++++++++++++---------- gdbserver/linux-s390-low.cc | 27 ++++++++++++++++----------- gdbserver/linux-sh-low.cc | 2 -- gdbserver/linux-sparc-low.cc | 1 - gdbserver/linux-tic6x-low.cc | 2 -- gdbserver/linux-tile-low.cc | 2 -- gdbserver/linux-x86-low.cc | 9 ++++----- gdbserver/linux-xtensa-low.cc | 2 -- 17 files changed, 76 insertions(+), 70 deletions(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 7eef276fb0c..3cd0b48caae 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -3114,8 +3114,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 2e4b6cf3d0c..a6539f3bd0b 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -1107,8 +1107,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 c17799b7d14..ccbd708d83c 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -165,8 +165,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 3498e01b9cc..f3376e89abb 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -470,8 +470,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 d643e8d5d56..62622e097e4 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 252b549989a..1f93fde8c04 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. @@ -684,6 +677,14 @@ class linux_process_target : public process_stratum_target 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. */ int m_decr_pc_after_break; }; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 9f3b8743476..1b963978f75 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -163,8 +163,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 64937149ed6..81ccbe65b11 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -259,8 +259,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 c39b81d0cb7..402cb2f1245 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -66,6 +66,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. */ @@ -893,9 +899,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; @@ -912,9 +918,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; @@ -982,8 +988,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 f0f10570842..2cbaf5303e1 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -58,6 +58,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; @@ -210,8 +216,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)); @@ -236,9 +243,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) { @@ -403,14 +410,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. */ @@ -3418,8 +3430,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 79a597c1e4a..ac86f26ee17 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -68,6 +68,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; @@ -190,11 +196,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]; @@ -236,12 +243,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]; @@ -308,8 +315,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]); } } @@ -2832,8 +2839,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 6af90b150a1..215838eae27 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -194,8 +194,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 b0b21b51269..245b8925d80 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -343,7 +343,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 3abbb27a548..b094a9ba60e 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -425,8 +425,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 bcb7a495f70..0d5bfae1f2d 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -226,8 +226,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 207d906a6fd..299f848a4a1 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. */ @@ -2915,11 +2919,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 42a1912881d..9ef7c9d4460 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -331,8 +331,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 */