From patchwork Fri Mar 6 21:31:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aktemur, Tankut Baris" X-Patchwork-Id: 38493 Received: (qmail 51866 invoked by alias); 6 Mar 2020 21:32:32 -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 51567 invoked by uid 89); 6 Mar 2020 21:32:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 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=1966 X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2020 21:32:20 +0000 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 13:32:18 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga007.fm.intel.com with ESMTP; 06 Mar 2020 13:32:16 -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 026LWGUI022440; Fri, 6 Mar 2020 21:32:16 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 026LWGsO020383; Fri, 6 Mar 2020 22:32:16 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 026LWGrd020379; Fri, 6 Mar 2020 22:32:16 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 06/31] gdbserver/linux-low: turn 'cannot_{fetch/store}_register' into methods Date: Fri, 6 Mar 2020 22:31:14 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes gdbserver/ChangeLog: 2020-03-06 Tankut Baris Aktemur Turn the 'cannot_fetch_register' and 'cannot_store_register' linux target ops into methods of linux_process_target. * linux-low.h (struct linux_target_ops): Remove the low target ops. (class linux_process_target) Declare. * linux-low.cc (fetch_register): Turn into... (linux_process_target::fetch_register): ...this. (store_register): Turn into ... (linux_process_target::store_register): ...this. (usr_fetch_inferior_registers): Turn into... (linux_process_target::usr_fetch_inferior_registers): ...this. (usr_store_inferior_registers): Turn into... (linux_process_target::usr_store_inferior_registers): ...this. * linux-x86-low.cc (class x86_target) : Declare. (x86_cannot_store_register): Turn into... (x86_target::low_cannot_store_register): ...this. (x86_cannot_fetch_register): Turn into... (x86_target::low_cannot_fetch_register): ...this. (the_low_target): Remove the target op fields. * linux-aarch64-low.cc (class aarch64_target) : Declare. (aarch64_target::low_cannot_fetch_register) (aarch64_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-arm-low.cc (class arm_target) : Declare. (arm_cannot_fetch_register): Turn into... (arm_target::low_cannot_fetch_register): ...this. (arm_cannot_store_register): Turn into... (arm_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-bfin-low.cc (class bfin_target) : Declare. (bfin_cannot_fetch_register): Turn into... (bfin_target::low_cannot_fetch_register): ...this. (bfin_cannot_store_register): Turn into... (bfin_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-cris-low.cc (class cris_target) : Declare. (cris_cannot_fetch_register): Turn into... (cris_target::low_cannot_fetch_register): ...this. (cris_cannot_store_register): Turn into... (cris_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-crisv32-low.cc (class crisv32_target) : Declare. (crisv32_target::low_cannot_fetch_register) (crisv32_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-ia64-low.cc (class ia64_target) : Declare. (ia64_cannot_fetch_register): Turn into... (ia64_target::low_cannot_fetch_register): ...this. (ia64_cannot_store_register): Turn into... (ia64_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m32r-low.cc (class m32r_target) : Declare. (m32r_cannot_fetch_register): Turn into... (m32r_target::low_cannot_fetch_register): ...this. (m32r_cannot_store_register): Turn into... (m32r_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-m68k-low.cc (class m68k_target) : Declare. (m68k_cannot_fetch_register): Turn into... (m68k_target::low_cannot_fetch_register): ...this. (m68k_cannot_store_register): Turn into... (m68k_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-mips-low.cc (class mips_target) : Declare. (mips_cannot_fetch_register): Turn into... (mips_target::low_cannot_fetch_register): ...this. (mips_cannot_store_register): Turn into... (mips_target::low_cannot_store_register): ...this. (get_usrregs_info): Inline at the call sites in low_cannot_fetch_register and low_cannot_store_register, and remove. (the_low_target): Remove the op fields. * linux-nios2-low.cc (class nios2_target) : Declare. (nios2_cannot_fetch_register): Turn into... (nios2_target::low_cannot_fetch_register): ...this. (nios2_cannot_store_register): Turn into... (nios2_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-ppc-low.cc (class ppc_target) : Declare. (ppc_cannot_fetch_register): Turn into... (ppc_target::low_cannot_fetch_register): ...this. (ppc_cannot_store_register): Turn into... (ppc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-riscv-low.cc (class riscv_target) : Declare. (riscv_target::low_cannot_fetch_register) (riscv_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. * linux-s390-low.cc (class s390_target) : Declare. (s390_cannot_fetch_register): Turn into... (s390_target::low_cannot_fetch_register): ...this. (s390_cannot_store_register): Turn into... (s390_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sh-low.cc (class sh_target) : Declare. (sh_cannot_fetch_register): Turn into... (sh_target::low_cannot_fetch_register): ...this. (sh_cannot_store_register): Turn into... (sh_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-sparc-low.cc (class sparc_target) : Declare. (sparc_cannot_fetch_register): Turn into... (sparc_target::low_cannot_fetch_register): ...this. (sparc_cannot_store_register): Turn into... (sparc_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tic6x-low.cc (class tic6x_target) : Declare. (tic6x_cannot_fetch_register): Turn into... (tic6x_target::low_cannot_fetch_register): ...this. (tic6x_cannot_store_register): Turn into... (tic6x_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-tile-low.cc (class tile_target) : Declare. (tile_cannot_fetch_register): Turn into... (tile_target::low_cannot_fetch_register): ...this. (tile_cannot_store_register): Turn into... (tile_target::low_cannot_store_register): ...this. (the_low_target): Remove the op fields. * linux-xtensa-low.cc (class xtensa_target) : Declare. (xtensa_target::low_cannot_fetch_register) (xtensa_target::low_cannot_store_register): Define. (the_low_target): Remove the op fields. --- gdbserver/linux-aarch64-low.cc | 20 ++++++++++-- gdbserver/linux-arm-low.cc | 14 ++++---- gdbserver/linux-bfin-low.cc | 14 ++++---- gdbserver/linux-cris-low.cc | 18 ++++++----- gdbserver/linux-crisv32-low.cc | 20 ++++++++++-- gdbserver/linux-ia64-low.cc | 18 ++++++----- gdbserver/linux-low.cc | 59 ++++++++++++++-------------------- gdbserver/linux-low.h | 37 ++++++++++++++++++--- gdbserver/linux-m32r-low.cc | 14 ++++---- gdbserver/linux-m68k-low.cc | 14 ++++---- gdbserver/linux-mips-low.cc | 48 ++++++++++++--------------- gdbserver/linux-nios2-low.cc | 28 +++++++--------- gdbserver/linux-ppc-low.cc | 22 +++++++------ gdbserver/linux-riscv-low.cc | 20 ++++++++++-- gdbserver/linux-s390-low.cc | 18 ++++++----- gdbserver/linux-sh-low.cc | 18 ++++++----- gdbserver/linux-sparc-low.cc | 14 ++++---- gdbserver/linux-tic6x-low.cc | 14 ++++---- gdbserver/linux-tile-low.cc | 26 ++++++++------- gdbserver/linux-x86-low.cc | 18 ++++++----- gdbserver/linux-xtensa-low.cc | 20 ++++++++++-- 21 files changed, 285 insertions(+), 189 deletions(-) diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index ebbfbe6cba3..19484219d73 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -60,12 +60,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static aarch64_target the_aarch64_target; +bool +aarch64_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +aarch64_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Per-process arch-specific data we want to keep. */ struct arch_process_info @@ -3067,8 +3085,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - NULL, /* cannot_fetch_register */ - NULL, /* cannot_store_register */ NULL, /* fetch_register */ aarch64_get_pc, aarch64_set_pc, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index c59e8bddc08..896c5fd1e64 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -65,6 +65,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -166,14 +170,14 @@ static struct arm_get_next_pcs_ops get_next_pcs_ops = { arm_linux_get_next_pcs_fixup, }; -static int -arm_cannot_store_register (int regno) +bool +arm_target::low_cannot_store_register (int regno) { return (regno >= arm_num_regs); } -static int -arm_cannot_fetch_register (int regno) +bool +arm_target::low_cannot_fetch_register (int regno) { return (regno >= arm_num_regs); } @@ -1023,8 +1027,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - arm_cannot_fetch_register, - arm_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index fee79b74da1..e7cd1e29637 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -59,14 +63,14 @@ static int bfin_regmap[] = #define bfin_num_regs ARRAY_SIZE (bfin_regmap) -static int -bfin_cannot_store_register (int regno) +bool +bfin_target::low_cannot_store_register (int regno) { return (regno >= bfin_num_regs); } -static int -bfin_cannot_fetch_register (int regno) +bool +bfin_target::low_cannot_fetch_register (int regno) { return (regno >= bfin_num_regs); } @@ -131,8 +135,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - bfin_cannot_fetch_register, - bfin_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc index dcb7d3fd5f4..03ca52e39e4 100644 --- a/gdbserver/linux-cris-low.cc +++ b/gdbserver/linux-cris-low.cc @@ -31,6 +31,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -58,20 +62,20 @@ static int cris_regmap[] = { }; -static int -cris_cannot_store_register (int regno) +bool +cris_target::low_cannot_store_register (int regno) { if (cris_regmap[regno] == -1) - return 1; + return true; return (regno >= cris_num_regs); } -static int -cris_cannot_fetch_register (int regno) +bool +cris_target::low_cannot_fetch_register (int regno) { if (cris_regmap[regno] == -1) - return 1; + return true; return (regno >= cris_num_regs); } @@ -128,8 +132,6 @@ cris_target::get_regs_info () } struct linux_target_ops the_low_target = { - cris_cannot_fetch_register, - cris_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index b7763ab1356..03f0aa138e2 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -31,12 +31,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static crisv32_target the_crisv32_target; +bool +crisv32_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +crisv32_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Defined in auto-generated file reg-crisv32.c. */ void init_registers_crisv32 (void); extern const struct target_desc *tdesc_crisv32; @@ -411,8 +429,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - NULL, - NULL, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc index d6508d2fb1d..471530a621b 100644 --- a/gdbserver/linux-ia64-low.cc +++ b/gdbserver/linux-ia64-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -283,16 +287,16 @@ static int ia64_regmap[] = -1, }; -static int -ia64_cannot_store_register (int regno) +bool +ia64_target::low_cannot_store_register (int regno) { - return 0; + return false; } -static int -ia64_cannot_fetch_register (int regno) +bool +ia64_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } /* GDB register numbers. */ @@ -363,8 +367,6 @@ ia64_target::low_arch_setup () struct linux_target_ops the_low_target = { - ia64_cannot_fetch_register, - ia64_cannot_store_register, ia64_fetch_register, }; diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 546ca731d8f..caa2d8dbd58 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -5418,10 +5418,10 @@ register_addr (const struct usrregs_info *usrregs, int regnum) return addr; } -/* Fetch one register. */ -static void -fetch_register (const struct usrregs_info *usrregs, - struct regcache *regcache, int regno) + +void +linux_process_target::fetch_register (const usrregs_info *usrregs, + regcache *regcache, int regno) { CORE_ADDR regaddr; int i, size; @@ -5430,7 +5430,7 @@ fetch_register (const struct usrregs_info *usrregs, if (regno >= usrregs->num_regs) return; - if ((*the_low_target.cannot_fetch_register) (regno)) + if (low_cannot_fetch_register (regno)) return; regaddr = register_addr (usrregs, regno); @@ -5466,10 +5466,9 @@ fetch_register (const struct usrregs_info *usrregs, supply_register (regcache, regno, buf); } -/* Store one register. */ -static void -store_register (const struct usrregs_info *usrregs, - struct regcache *regcache, int regno) +void +linux_process_target::store_register (const usrregs_info *usrregs, + regcache *regcache, int regno) { CORE_ADDR regaddr; int i, size; @@ -5478,7 +5477,7 @@ store_register (const struct usrregs_info *usrregs, if (regno >= usrregs->num_regs) return; - if ((*the_low_target.cannot_store_register) (regno)) + if (low_cannot_store_register (regno)) return; regaddr = register_addr (usrregs, regno); @@ -5514,22 +5513,21 @@ store_register (const struct usrregs_info *usrregs, if (errno == ESRCH) return; - if ((*the_low_target.cannot_store_register) (regno) == 0) + + if (!low_cannot_store_register (regno)) error ("writing register %d: %s", regno, safe_strerror (errno)); } regaddr += sizeof (PTRACE_XFER_TYPE); } } +#endif /* HAVE_LINUX_USRREGS */ -/* Fetch all registers, or just one, from the child process. - If REGNO is -1, do this for all registers, skipping any that are - assumed to have been retrieved by regsets_fetch_inferior_registers, - unless ALL is non-zero. - Otherwise, REGNO specifies which register (so we can save time). */ -static void -usr_fetch_inferior_registers (const struct regs_info *regs_info, - struct regcache *regcache, int regno, int all) +void +linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info, + regcache *regcache, + int regno, int all) { +#ifdef HAVE_LINUX_USRREGS struct usrregs_info *usr = regs_info->usrregs; if (regno == -1) @@ -5540,17 +5538,15 @@ usr_fetch_inferior_registers (const struct regs_info *regs_info, } else fetch_register (usr, regcache, regno); +#endif } -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers, skipping any that are - assumed to have been saved by regsets_store_inferior_registers, - unless ALL is non-zero. - Otherwise, REGNO specifies which register (so we can save time). */ -static void -usr_store_inferior_registers (const struct regs_info *regs_info, - struct regcache *regcache, int regno, int all) +void +linux_process_target::usr_store_inferior_registers (const regs_info *regs_info, + regcache *regcache, + int regno, int all) { +#ifdef HAVE_LINUX_USRREGS struct usrregs_info *usr = regs_info->usrregs; if (regno == -1) @@ -5561,15 +5557,8 @@ usr_store_inferior_registers (const struct regs_info *regs_info, } else store_register (usr, regcache, regno); -} - -#else /* !HAVE_LINUX_USRREGS */ - -#define usr_fetch_inferior_registers(regs_info, regcache, regno, all) do {} while (0) -#define usr_store_inferior_registers(regs_info, regcache, regno, all) do {} while (0) - #endif - +} void linux_process_target::fetch_registers (regcache *regcache, int regno) diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 697b4af53a4..65c570e0669 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,11 +131,6 @@ struct lwp_info; struct linux_target_ops { - /* Return 0 if we can fetch/store the register, 1 if we cannot - fetch/store the register. */ - int (*cannot_fetch_register) (int); - int (*cannot_store_register) (int); - /* Hook to fetch a register in some non-standard way. Used for example by backends that have read-only registers with hardcoded values (e.g., IA64's gr0/fr0/fr1). Returns true if register @@ -566,11 +561,43 @@ class linux_process_target : public process_stratum_target /* Call low_arch_setup on THREAD. */ void arch_setup_thread (thread_info *thread); +#ifdef HAVE_LINUX_USRREGS + /* Fetch one register. */ + void fetch_register (const usrregs_info *usrregs, regcache *regcache, + int regno); + + /* Store one register. */ + void store_register (const usrregs_info *usrregs, regcache *regcache, + int regno); +#endif + + /* Fetch all registers, or just one, from the child process. + If REGNO is -1, do this for all registers, skipping any that are + assumed to have been retrieved by regsets_fetch_inferior_registers, + unless ALL is non-zero. + Otherwise, REGNO specifies which register (so we can save time). */ + void usr_fetch_inferior_registers (const regs_info *regs_info, + regcache *regcache, int regno, int all); + + /* Store our register values back into the inferior. + If REGNO is -1, do this for all registers, skipping any that are + assumed to have been saved by regsets_store_inferior_registers, + unless ALL is non-zero. + Otherwise, REGNO specifies which register (so we can save time). */ + void usr_store_inferior_registers (const regs_info *regs_info, + regcache *regcache, int regno, int all); + protected: /* The architecture-specific "low" methods are listed below. */ /* Architecture-specific setup for the current thread. */ virtual void low_arch_setup () = 0; + + /* Return false if we can fetch/store the register, true if we cannot + fetch/store the register. */ + virtual bool low_cannot_fetch_register (int regno) = 0; + + virtual bool low_cannot_store_register (int regno) = 0; }; extern linux_process_target *the_linux_target; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 2a5c6ea9bbe..912708db817 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -58,14 +62,14 @@ static int m32r_regmap[] = { #endif }; -static int -m32r_cannot_store_register (int regno) +bool +m32r_target::low_cannot_store_register (int regno) { return (regno >= m32r_num_regs); } -static int -m32r_cannot_fetch_register (int regno) +bool +m32r_target::low_cannot_fetch_register (int regno) { return (regno >= m32r_num_regs); } @@ -130,8 +134,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - m32r_cannot_fetch_register, - m32r_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index cbecc7a7f52..08545aa946f 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -30,6 +30,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -71,14 +75,14 @@ static int m68k_regmap[] = #endif }; -static int -m68k_cannot_store_register (int regno) +bool +m68k_target::low_cannot_store_register (int regno) { return (regno >= m68k_num_regs); } -static int -m68k_cannot_fetch_register (int regno) +bool +m68k_target::low_cannot_fetch_register (int regno) { return (regno >= m68k_num_regs); } @@ -225,8 +229,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - m68k_cannot_fetch_register, - m68k_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index 8231217dac9..0900dc88e0b 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -36,6 +36,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -170,14 +174,6 @@ mips_target::low_arch_setup () current_process ()->tdesc = mips_read_description (); } -static struct usrregs_info * -get_usrregs_info (void) -{ - const struct regs_info *regs_info = the_linux_target->get_regs_info (); - - return regs_info->usrregs; -} - /* Per-process arch-specific data we want to keep. */ struct arch_process_info @@ -218,53 +214,53 @@ struct arch_lwp_info ZERO_REGNUM, it's always 0. We also can not set BADVADDR, CAUSE, or FCRIR via ptrace(). */ -static int -mips_cannot_fetch_register (int regno) +bool +mips_target::low_cannot_fetch_register (int regno) { const struct target_desc *tdesc; - if (get_usrregs_info ()->regmap[regno] == -1) - return 1; + if (get_regs_info ()->usrregs->regmap[regno] == -1) + return true; tdesc = current_process ()->tdesc; /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR. */ if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE)) - return 1; + return true; if (find_regno (tdesc, "r0") == regno) - return 1; + return true; - return 0; + return false; } -static int -mips_cannot_store_register (int regno) +bool +mips_target::low_cannot_store_register (int regno) { const struct target_desc *tdesc; - if (get_usrregs_info ()->regmap[regno] == -1) - return 1; + if (get_regs_info ()->usrregs->regmap[regno] == -1) + return true; tdesc = current_process ()->tdesc; /* On n32 we can't access 64-bit registers via PTRACE_POKEUSR. */ if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE)) - return 1; + return true; if (find_regno (tdesc, "r0") == regno) - return 1; + return true; if (find_regno (tdesc, "cause") == regno) - return 1; + return true; if (find_regno (tdesc, "badvaddr") == regno) - return 1; + return true; if (find_regno (tdesc, "fir") == regno) - return 1; + return true; - return 0; + return false; } static int @@ -954,8 +950,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - mips_cannot_fetch_register, - mips_cannot_store_register, mips_fetch_register, mips_get_pc, mips_set_pc, diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc index 2e19b8dc7de..adbb0f2622e 100644 --- a/gdbserver/linux-nios2-low.cc +++ b/gdbserver/linux-nios2-low.cc @@ -42,6 +42,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -90,26 +94,20 @@ nios2_target::low_arch_setup () current_process ()->tdesc = tdesc_nios2_linux; } -/* Implement the cannot_fetch_register linux_target_ops method. */ +/* Implement the low_cannot_fetch_register linux target ops method. */ -static int -nios2_cannot_fetch_register (int regno) +bool +nios2_target::low_cannot_fetch_register (int regno) { - if (nios2_regmap[regno] == -1) - return 1; - - return 0; + return (nios2_regmap[regno] == -1); } -/* Implement the cannot_store_register linux_target_ops method. */ +/* Implement the low_cannot_store_register linux target ops method. */ -static int -nios2_cannot_store_register (int regno) +bool +nios2_target::low_cannot_store_register (int regno) { - if (nios2_regmap[regno] == -1) - return 1; - - return 0; + return (nios2_regmap[regno] == -1); } /* Breakpoint support. Also see comments on nios2_breakpoint_from_pc @@ -253,8 +251,6 @@ nios2_target::get_regs_info () struct linux_target_ops the_low_target = { - nios2_cannot_fetch_register, - nios2_cannot_store_register, NULL, linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index fe63e7bf07b..968538df370 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -55,6 +55,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -160,8 +164,8 @@ ppc_check_regset (int tid, int regset_id, int regsetsize) return 0; } -static int -ppc_cannot_store_register (int regno) +bool +ppc_target::low_cannot_store_register (int regno) { const struct target_desc *tdesc = current_process ()->tdesc; @@ -169,21 +173,21 @@ ppc_cannot_store_register (int regno) /* Some kernels do not allow us to store fpscr. */ if (!(ppc_hwcap & PPC_FEATURE_HAS_SPE) && regno == find_regno (tdesc, "fpscr")) - return 1; + return true; #endif /* Some kernels do not allow us to store orig_r3 or trap. */ if (regno == find_regno (tdesc, "orig_r3") || regno == find_regno (tdesc, "trap")) - return 1; + return true; - return 0; + return false; } -static int -ppc_cannot_fetch_register (int regno) +bool +ppc_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } static void @@ -3388,8 +3392,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - ppc_cannot_fetch_register, - ppc_cannot_store_register, NULL, /* fetch_register */ ppc_get_pc, ppc_set_pc, diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc index 092f497b85a..4f2e28beafc 100644 --- a/gdbserver/linux-riscv-low.cc +++ b/gdbserver/linux-riscv-low.cc @@ -41,12 +41,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static riscv_target the_riscv_target; +bool +riscv_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +riscv_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Implementation of linux target ops method "low_arch_setup". */ void @@ -273,8 +291,6 @@ riscv_breakpoint_at (CORE_ADDR pc) /* RISC-V/Linux target operations. */ struct linux_target_ops the_low_target = { - NULL, /* cannot_fetch_register */ - NULL, /* cannot_store_register */ riscv_fetch_register, riscv_get_pc, riscv_set_pc, diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 464f60d8d42..2ba0dec0551 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -62,6 +62,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -157,16 +161,16 @@ static int s390_regmap_3264[] = { #endif -static int -s390_cannot_fetch_register (int regno) +bool +s390_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } -static int -s390_cannot_store_register (int regno) +bool +s390_target::low_cannot_store_register (int regno) { - return 0; + return false; } static void @@ -2808,8 +2812,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - s390_cannot_fetch_register, - s390_cannot_store_register, NULL, /* fetch_register */ s390_get_pc, s390_set_pc, diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index d47cd402def..b4fd534547e 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -30,6 +30,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -63,16 +67,16 @@ static int sh_regmap[] = { REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60, }; -static int -sh_cannot_store_register (int regno) +bool +sh_target::low_cannot_store_register (int regno) { - return 0; + return false; } -static int -sh_cannot_fetch_register (int regno) +bool +sh_target::low_cannot_fetch_register (int regno) { - return 0; + return false; } /* Correct in either endianness, obviously. */ @@ -160,8 +164,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - sh_cannot_fetch_register, - sh_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit, diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index 7be5c15c256..4e0d930f800 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -53,6 +53,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -119,14 +123,14 @@ static const struct regs_range_t fpregs_ranges[] = { void init_registers_sparc64 (void); extern const struct target_desc *tdesc_sparc64; -static int -sparc_cannot_store_register (int regno) +bool +sparc_target::low_cannot_store_register (int regno) { return (regno >= sparc_num_regs || sparc_regmap[regno] == -1); } -static int -sparc_cannot_fetch_register (int regno) +bool +sparc_target::low_cannot_fetch_register (int regno) { return (regno >= sparc_num_regs || sparc_regmap[regno] == -1); } @@ -315,8 +319,6 @@ sparc_target::get_regs_info () } struct linux_target_ops the_low_target = { - sparc_cannot_fetch_register, - sparc_cannot_store_register, NULL, /* fetch_register */ linux_get_pc_64bit, /* No sparc_set_pc is needed. */ diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 1f8d2f6451e..be6eb98b45c 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -49,6 +49,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -223,14 +227,14 @@ tic6x_read_description (enum c6x_feature feature) return *tdesc; } -static int -tic6x_cannot_fetch_register (int regno) +bool +tic6x_target::low_cannot_fetch_register (int regno) { return (tic6x_regmap[regno] == -1); } -static int -tic6x_cannot_store_register (int regno) +bool +tic6x_target::low_cannot_store_register (int regno) { return (tic6x_regmap[regno] == -1); } @@ -403,8 +407,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - tic6x_cannot_fetch_register, - tic6x_cannot_store_register, NULL, /* fetch_register */ tic6x_get_pc, tic6x_set_pc, diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 6f173ccdf83..b9af7af7fb5 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -34,6 +34,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -63,26 +67,26 @@ static int tile_regmap[] = 56 }; -static int -tile_cannot_fetch_register (int regno) +bool +tile_target::low_cannot_fetch_register (int regno) { if (regno >= 0 && regno < 56) - return 0; + return false; else if (regno == 64) - return 0; + return false; else - return 1; + return true; } -static int -tile_cannot_store_register (int regno) +bool +tile_target::low_cannot_store_register (int regno) { if (regno >= 0 && regno < 56) - return 0; + return false; else if (regno == 64) - return 0; + return false; else - return 1; + return true; } static uint64_t tile_breakpoint = 0x400b3cae70166000ULL; @@ -192,8 +196,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - tile_cannot_fetch_register, - tile_cannot_store_register, NULL, linux_get_pc_64bit, linux_set_pc_64bit, diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 4fdeeef2eee..8c9ab733ea8 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -109,6 +109,10 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ @@ -301,23 +305,23 @@ x86_get_thread_area (int lwpid, CORE_ADDR *addr) -static int -x86_cannot_store_register (int regno) +bool +x86_target::low_cannot_store_register (int regno) { #ifdef __x86_64__ if (is_64bit_tdesc ()) - return 0; + return false; #endif return regno >= I386_NUM_REGS; } -static int -x86_cannot_fetch_register (int regno) +bool +x86_target::low_cannot_fetch_register (int regno) { #ifdef __x86_64__ if (is_64bit_tdesc ()) - return 0; + return false; #endif return regno >= I386_NUM_REGS; @@ -2881,8 +2885,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - x86_cannot_fetch_register, - x86_cannot_store_register, NULL, /* fetch_register */ x86_get_pc, x86_set_pc, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index ee2cd3bd9a4..876c2ad63e0 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -31,12 +31,30 @@ public: protected: void low_arch_setup () override; + + bool low_cannot_fetch_register (int regno) override; + + bool low_cannot_store_register (int regno) override; }; /* The singleton target ops object. */ static xtensa_target the_xtensa_target; +bool +xtensa_target::low_cannot_fetch_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_fetch_register " + "is not implemented by the target"); +} + +bool +xtensa_target::low_cannot_store_register (int regno) +{ + gdb_assert_not_reached ("linux target op low_cannot_store_register " + "is not implemented by the target"); +} + /* Defined in auto-generated file reg-xtensa.c. */ void init_registers_xtensa (void); extern const struct target_desc *tdesc_xtensa; @@ -284,8 +302,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, - 0, NULL, /* fetch_register */ linux_get_pc_32bit, linux_set_pc_32bit,