[11/31] gdbserver/linux-low: turn 'sw_breakpoint_from_kind' into a method

Message ID 9d3e8912ac039651e2e3eec2a3db2bf2bee92a4c.1583529167.git.tankut.baris.aktemur@intel.com
State New
Headers show
Series
  • Turn gdbserver's linux low targets into classes
Related show

Commit Message

Tankut Baris Aktemur March 6, 2020, 9:31 p.m.
gdbserver/ChangeLog:
2020-03-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Remove the 'sw_breakpoint_from_kind' linux target op, and let
	the concrete linux target define it by overriding the op
	in process_stratum_target.

	* linux-low.cc (linux_process_target::sw_breakpoint_from_kind):
	Remove.
	* linux-low.h (struct linux_target_ops): Remove the op.
	(class linux_process_target) <sw_breakpoint_from_kind>: Remove.
	* linux-x86-low.cc (class x86_target) <sw_breakpoint_from_kind>:
	Declare.
	(x86_sw_breakpoint_from_kind): Turn into...
	(x86_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-aarch64-low.cc (class aarch64_target)
	<sw_breakpoint_from_kind>: Declare.
	(aarch64_sw_breakpoint_from_kind): Turn into...
	(aarch64_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-arm-low.cc (class arm_target) <sw_breakpoint_from_kind>:
	Declare.
	(arm_target::sw_breakpoint_from_kind): Define.
	(the_low_target): Remove the op field.
	* linux-bfin-low.cc (class bfin_target) <sw_breakpoint_from_kind>:
	Declare.
	(bfin_sw_breakpoint_from_kind): Turn into...
	(bfin_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-cris-low.cc (class cris_target) <sw_breakpoint_from_kind>:
	Declare.
	(cris_sw_breakpoint_from_kind): Turn into...
	(cris_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-crisv32-low.cc (class crisv32_target)
	<sw_breakpoint_from_kind>: Declare.
	(cris_sw_breakpoint_from_kind): Turn into...
	(crisv32_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-ia64-low.cc (class ia64_target) <sw_breakpoint_from_kind>:
	Declare.
	(ia64_target::sw_breakpoint_from_kind): Define.
	* linux-m32r-low.cc (class m32r_target) <sw_breakpoint_from_kind>:
	Declare.
	(m32r_sw_breakpoint_from_kind): Turn into...
	(m32r_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-m68k-low.cc (class m68k_target) <sw_breakpoint_from_kind>:
	Declare.
	(m68k_sw_breakpoint_from_kind): Turn into...
	(m68k_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-mips-low.cc (class mips_target) <sw_breakpoint_from_kind>:
	Declare.
	(mips_sw_breakpoint_from_kind): Turn into...
	(mips_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-nios2-low.cc (class nios2_target) <sw_breakpoint_from_kind>:
	Declare.
	(nios2_sw_breakpoint_from_kind): Turn into...
	(nios2_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-ppc-low.cc (class ppc_target) <sw_breakpoint_from_kind>:
	Declare.
	(ppc_sw_breakpoint_from_kind): Turn into...
	(ppc_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-riscv-low.cc (class riscv_target) <sw_breakpoint_from_kind>:
	Declare.
	(riscv_sw_breakpoint_from_kind): Turn into...
	(riscv_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-s390-low.cc (class s390_target) <sw_breakpoint_from_kind>:
	Declare.
	(s390_sw_breakpoint_from_kind): Turn into...
	(s390_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-sh-low.cc (class sh_target) <sw_breakpoint_from_kind>:
	Declare.
	(sh_sw_breakpoint_from_kind): Turn into...
	(sh_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-sparc-low.cc (class sparc_target) <sw_breakpoint_from_kind>:
	Declare.
	(sparc_sw_breakpoint_from_kind): Turn into...
	(sparc_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-tic6x-low.cc (class tic6x_target) <sw_breakpoint_from_kind>:
	Declare.
	(tic6x_sw_breakpoint_from_kind): Turn into...
	(tic6x_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-tile-low.cc (class tile_target) <sw_breakpoint_from_kind>:
	Declare.
	(tile_sw_breakpoint_from_kind): Turn into...
	(tile_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
	* linux-xtensa-low.cc (class xtensa_target)
	<sw_breakpoint_from_kind>: Declare.
	(xtensa_sw_breakpoint_from_kind): Turn into...
	(xtensa_target::sw_breakpoint_from_kind): ...this.
	(the_low_target): Remove the op field.
---
 gdbserver/linux-aarch64-low.cc |  9 +++++----
 gdbserver/linux-arm-low.cc     |  9 ++++++++-
 gdbserver/linux-bfin-low.cc    |  9 +++++----
 gdbserver/linux-cris-low.cc    |  9 +++++----
 gdbserver/linux-crisv32-low.cc |  9 +++++----
 gdbserver/linux-ia64-low.cc    |  9 +++++++++
 gdbserver/linux-low.cc         | 10 ----------
 gdbserver/linux-low.h          |  5 -----
 gdbserver/linux-m32r-low.cc    |  9 +++++----
 gdbserver/linux-m68k-low.cc    |  9 +++++----
 gdbserver/linux-mips-low.cc    |  9 +++++----
 gdbserver/linux-nios2-low.cc   |  9 +++++----
 gdbserver/linux-ppc-low.cc     |  9 +++++----
 gdbserver/linux-riscv-low.cc   |  9 +++++----
 gdbserver/linux-s390-low.cc    |  9 +++++----
 gdbserver/linux-sh-low.cc      |  9 +++++----
 gdbserver/linux-sparc-low.cc   |  9 +++++----
 gdbserver/linux-tic6x-low.cc   |  9 +++++----
 gdbserver/linux-tile-low.cc    |  9 +++++----
 gdbserver/linux-x86-low.cc     |  9 +++++----
 gdbserver/linux-xtensa-low.cc  |  9 +++++----
 21 files changed, 102 insertions(+), 84 deletions(-)

-- 
2.17.1

Comments

Andreas Schwab May 16, 2020, 8:08 a.m. | #1
../../gdbserver/linux-ia64-low.cc: In member function ‘virtual const gdb_byte* ia64_target::sw_breakpoint_from_kind(int, int*)’:
../../gdbserver/linux-ia64-low.cc:57:33: error: ‘gdb_assert_no_reached’ was not declared in this scope
     "implemented by this target");
                                 ^
../../gdbserver/linux-ia64-low.cc:58:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Patch

diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index c9c9b30b36f..23c9c3e2518 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -61,6 +61,8 @@  public:
 
   int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -3054,10 +3056,10 @@  aarch64_supports_range_stepping (void)
   return 1;
 }
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-aarch64_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+aarch64_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   if (is_64bit_tdesc ())
     {
@@ -3101,7 +3103,6 @@  aarch64_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  aarch64_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,    /* decr_pc_after_break */
   aarch64_breakpoint_at,
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index d02ead70fa9..aab2c427f5a 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -66,6 +66,8 @@  public:
 
   int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -115,6 +117,12 @@  arm_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
   return arm_breakpoint_kind_from_current_state (pcptr);
 }
 
+const gdb_byte *
+arm_target::sw_breakpoint_from_kind (int kind, int *size)
+{
+  return arm_sw_breakpoint_from_kind (kind, size);
+}
+
 /* Information describing the hardware breakpoint capabilities.  */
 static struct
 {
@@ -1067,7 +1075,6 @@  arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  arm_sw_breakpoint_from_kind,
   arm_gdbserver_get_next_pcs,
   0,
   arm_breakpoint_at,
diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc
index 1a0938ef584..c798c9317f2 100644
--- a/gdbserver/linux-bfin-low.cc
+++ b/gdbserver/linux-bfin-low.cc
@@ -31,6 +31,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -102,10 +104,10 @@  bfin_target::low_cannot_fetch_register (int regno)
 #define bfin_breakpoint_len 2
 static const gdb_byte bfin_breakpoint[bfin_breakpoint_len] = {0xa1, 0x00};
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-bfin_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+bfin_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = bfin_breakpoint_len;
   return bfin_breakpoint;
@@ -159,7 +161,6 @@  bfin_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  bfin_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   2,
   bfin_breakpoint_at,
diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc
index 882e4c61eb0..a22ec3342dc 100644
--- a/gdbserver/linux-cris-low.cc
+++ b/gdbserver/linux-cris-low.cc
@@ -28,6 +28,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -107,10 +109,10 @@  cris_target::low_cannot_fetch_register (int regno)
 static const unsigned short cris_breakpoint = 0xe938;
 #define cris_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-cris_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+cris_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = cris_breakpoint_len;
   return (const gdb_byte *) &cris_breakpoint;
@@ -156,7 +158,6 @@  cris_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  cris_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,
   cris_breakpoint_at,
diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc
index 270c206e806..965f186981d 100644
--- a/gdbserver/linux-crisv32-low.cc
+++ b/gdbserver/linux-crisv32-low.cc
@@ -28,6 +28,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -117,10 +119,10 @@  static int cris_regmap[] = {
 static const unsigned short cris_breakpoint = 0xe938;
 #define cris_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-cris_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+crisv32_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = cris_breakpoint_len;
   return (const gdb_byte *) &cris_breakpoint;
@@ -453,7 +455,6 @@  crisv32_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  cris_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,
   cris_breakpoint_at,
diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc
index 377df4f75c3..493c7e4f93d 100644
--- a/gdbserver/linux-ia64-low.cc
+++ b/gdbserver/linux-ia64-low.cc
@@ -31,6 +31,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -46,6 +48,13 @@  protected:
 
 static ia64_target the_ia64_target;
 
+const gdb_byte *
+ia64_target::sw_breakpoint_from_kind (int kind, int *size)
+{
+  gdb_assert_no_reached ("target op sw_breakpoint_from_kind is not "
+			 "implemented by this target");
+}
+
 /* Defined in auto-generated file reg-ia64.c.  */
 void init_registers_ia64 (void);
 extern const struct target_desc *tdesc_ia64;
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 730f23bb6f0..14a4dbf0866 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7230,16 +7230,6 @@  current_lwp_ptid (void)
   return ptid_of (current_thread);
 }
 
-/* Implementation of the target_ops method "sw_breakpoint_from_kind".  */
-
-const gdb_byte *
-linux_process_target::sw_breakpoint_from_kind (int kind, int *size)
-{
-  gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL);
-
-  return (*the_low_target.sw_breakpoint_from_kind) (kind, size);
-}
-
 const char *
 linux_process_target::thread_name (ptid_t thread)
 {
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 60ec910057f..b2f779893e3 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -131,9 +131,6 @@  struct lwp_info;
 
 struct linux_target_ops
 {
-  /* See target.h for details.  */
-  const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size);
-
   /* Find the next possible PCs after the current instruction executes.  */
   std::vector<CORE_ADDR> (*get_next_pcs) (struct regcache *regcache);
 
@@ -436,8 +433,6 @@  class linux_process_target : public process_stratum_target
   ssize_t multifs_readlink (int pid, const char *filename, char *buf,
 			    size_t bufsiz) override;
 
-  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
-
   const char *thread_name (ptid_t thread) override;
 
 #if USE_THREAD_DB
diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc
index c7bb811e64c..1a6771f5845 100644
--- a/gdbserver/linux-m32r-low.cc
+++ b/gdbserver/linux-m32r-low.cc
@@ -31,6 +31,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -101,10 +103,10 @@  m32r_target::low_cannot_fetch_register (int regno)
 static const unsigned short m32r_breakpoint = 0x10f1;
 #define m32r_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-m32r_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+m32r_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = m32r_breakpoint_len;
   return (const gdb_byte *) &m32r_breakpoint;
@@ -158,7 +160,6 @@  m32r_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  m32r_sw_breakpoint_from_kind,
   NULL,
   0,
   m32r_breakpoint_at,
diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc
index 6483c27698e..5e19ab02094 100644
--- a/gdbserver/linux-m68k-low.cc
+++ b/gdbserver/linux-m68k-low.cc
@@ -27,6 +27,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -170,10 +172,10 @@  static struct regset_info m68k_regsets[] = {
 static const gdb_byte m68k_breakpoint[] = { 0x4E, 0x4F };
 #define m68k_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-m68k_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+m68k_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = m68k_breakpoint_len;
   return m68k_breakpoint;
@@ -253,7 +255,6 @@  m68k_supports_hardware_single_step (void)
 }
 
 struct linux_target_ops the_low_target = {
-  m68k_sw_breakpoint_from_kind,
   NULL,
   2,
   m68k_breakpoint_at,
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index d36836669db..972f431bfbd 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -33,6 +33,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -315,10 +317,10 @@  mips_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
 static const unsigned int mips_breakpoint = 0x0005000d;
 #define mips_breakpoint_len 4
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-mips_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+mips_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = mips_breakpoint_len;
   return (const gdb_byte *) &mips_breakpoint;
@@ -964,7 +966,6 @@  mips_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  mips_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,
   mips_breakpoint_at,
diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc
index 4f10df53d20..693af71f29e 100644
--- a/gdbserver/linux-nios2-low.cc
+++ b/gdbserver/linux-nios2-low.cc
@@ -39,6 +39,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -152,10 +154,10 @@  nios2_target::low_cannot_store_register (int regno)
 static const unsigned int nios2_breakpoint = NIOS2_BREAKPOINT;
 #define nios2_breakpoint_len 4
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-nios2_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+nios2_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = nios2_breakpoint_len;
   return (const gdb_byte *) &nios2_breakpoint;
@@ -275,7 +277,6 @@  nios2_target::get_regs_info ()
 
 struct linux_target_ops the_low_target =
 {
-  nios2_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,
   nios2_breakpoint_at,
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 167c3b60f76..9690d79f3d8 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -52,6 +52,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -296,10 +298,10 @@  static int ppc_regmap_adjusted;
 static const unsigned int ppc_breakpoint = 0x7d821008;
 #define ppc_breakpoint_len 4
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-ppc_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+ppc_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = ppc_breakpoint_len;
   return (const gdb_byte *) &ppc_breakpoint;
@@ -3404,7 +3406,6 @@  ppc_get_ipa_tdesc_idx (void)
 }
 
 struct linux_target_ops the_low_target = {
-  ppc_sw_breakpoint_from_kind,
   NULL,
   0,
   ppc_breakpoint_at,
diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc
index 87abb7cb52d..c25519301c4 100644
--- a/gdbserver/linux-riscv-low.cc
+++ b/gdbserver/linux-riscv-low.cc
@@ -40,6 +40,8 @@  public:
 
   int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -266,10 +268,10 @@  riscv_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
     return sizeof (riscv_cbreakpoint);
 }
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-riscv_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+riscv_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = kind;
   switch (kind)
@@ -307,7 +309,6 @@  riscv_breakpoint_at (CORE_ADDR pc)
 /* RISC-V/Linux target operations.  */
 struct linux_target_ops the_low_target =
 {
-  riscv_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,    /* decr_pc_after_break */
   riscv_breakpoint_at,
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index 44f3be6c98e..164142dff6e 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -59,6 +59,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -451,10 +453,10 @@  static struct regset_info s390_regsets[] = {
 static const gdb_byte s390_breakpoint[] = { 0, 1 };
 #define s390_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-s390_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+s390_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = s390_breakpoint_len;
   return s390_breakpoint;
@@ -2824,7 +2826,6 @@  s390_emit_ops (void)
 }
 
 struct linux_target_ops the_low_target = {
-  s390_sw_breakpoint_from_kind,
   NULL,
   s390_breakpoint_len,
   s390_breakpoint_at,
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 36c19334758..10ee49a5f87 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -27,6 +27,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -107,10 +109,10 @@  sh_target::low_cannot_fetch_register (int regno)
 static const unsigned short sh_breakpoint = 0xc3c3;
 #define sh_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-sh_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+sh_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = sh_breakpoint_len;
   return (const gdb_byte *) &sh_breakpoint;
@@ -188,7 +190,6 @@  sh_target::low_arch_setup ()
 }
 
 struct linux_target_ops the_low_target = {
-  sh_sw_breakpoint_from_kind,
   NULL,
   0,
   sh_breakpoint_at,
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index 18a529adb70..c94c3e3caf3 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -50,6 +50,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -267,10 +269,10 @@  static const gdb_byte sparc_breakpoint[INSN_SIZE] = {
 };
 #define sparc_breakpoint_len INSN_SIZE
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const unsigned char *
-sparc_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+sparc_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = sparc_breakpoint_len;
   return sparc_breakpoint;
@@ -337,7 +339,6 @@  sparc_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  sparc_sw_breakpoint_from_kind,
   NULL, /* get_next_pcs */
   0,
   sparc_breakpoint_at,
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index 1486829594d..69bb4f3d7b1 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -46,6 +46,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -202,10 +204,10 @@  static int *tic6x_regmap;
 static unsigned int tic6x_breakpoint;
 #define tic6x_breakpoint_len 4
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-tic6x_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+tic6x_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = tic6x_breakpoint_len;
   return (const gdb_byte *) &tic6x_breakpoint;
@@ -419,7 +421,6 @@  tic6x_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  tic6x_sw_breakpoint_from_kind,
   NULL,
   0,
   tic6x_breakpoint_at,
diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc
index d577b589b4a..e4565b4cfbe 100644
--- a/gdbserver/linux-tile-low.cc
+++ b/gdbserver/linux-tile-low.cc
@@ -31,6 +31,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -116,10 +118,10 @@  tile_target::low_cannot_store_register (int regno)
 static uint64_t tile_breakpoint = 0x400b3cae70166000ULL;
 #define tile_breakpoint_len 8
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-tile_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+tile_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = tile_breakpoint_len;
   return (const gdb_byte *) &tile_breakpoint;
@@ -220,7 +222,6 @@  tile_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  tile_sw_breakpoint_from_kind,
   NULL,
   0,
   tile_breakpoint_at,
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 1da48db3027..a9d7ec06705 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -106,6 +106,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -2852,10 +2854,10 @@  x86_emit_ops (void)
     return &i386_emit_ops;
 }
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-x86_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+x86_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = x86_breakpoint_len;
   return x86_breakpoint;
@@ -2897,7 +2899,6 @@  x86_get_ipa_tdesc_idx (void)
 
 struct linux_target_ops the_low_target =
 {
-  x86_sw_breakpoint_from_kind,
   NULL,
   1,
   x86_breakpoint_at,
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 32643307cb7..ab08227a862 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -28,6 +28,8 @@  public:
 
   const regs_info *get_regs_info () override;
 
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
 protected:
 
   void low_arch_setup () override;
@@ -252,10 +254,10 @@  static struct regset_info xtensa_regsets[] = {
 static const gdb_byte xtensa_breakpoint[] = XTENSA_BREAKPOINT;
 #define xtensa_breakpoint_len 2
 
-/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+/* Implementation of target ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-xtensa_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+xtensa_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = xtensa_breakpoint_len;
   return xtensa_breakpoint;
@@ -326,7 +328,6 @@  xtensa_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  xtensa_sw_breakpoint_from_kind,
   NULL,
   0,
   xtensa_breakpoint_at,