gdbserver/linux-low: turn 'fetch_register' into a method
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 2 Apr 2020 13:11:24 +0000 (15:11 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 2 Apr 2020 13:11:24 +0000 (15:11 +0200)
gdbserver/ChangeLog:
2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

Turn the 'fetch_register' linux target op into a method of
linux_process_target.

* linux-low.h (struct linux_target_ops) <fetch_register>: Remove.
(class linux_process_target) <low_fetch_register>: Declare.
* linux-x86-low.cc (the_low_target)
* linux-aarch64-low.cc (the_low_target)
* linux-arm-low.cc (the_low_target)
* linux-bfin-low.cc (the_low_target)
* linux-cris-low.cc (the_low_target)
* linux-crisv32-low.cc (the_low_target)
* linux-m32r-low.cc (the_low_target)
* linux-m68k-low.cc (the_low_target)
* linux-nios2-low.cc (the_low_target)
* linux-ppc-low.cc (the_low_target)
* linux-s390-low.cc (the_low_target)
* linux-sh-low.cc (the_low_target)
* linux-sparc-low.cc (the_low_target)
* linux-tic6x-low.cc (the_low_target)
* linux-tile-low.cc (the_low_target)
* linux-xtensa-low.cc (the_low_target): Remove the op field.
* linux-ia64-low.cc (class ia64_target) <low_fetch_register>:
Declare.
(ia64_fetch_register): Turn into...
(ia64_target::low_fetch_register): ...this.
(the_low_target): Remove the op field.
* linux-mips-low.cc (class mips_target) <low_fetch_register>:
Declare.
(mips_fetch_register): Turn into...
(mips_target::low_fetch_register): ...this.
(the_low_target): Remove the op field.
* linux-riscv-low.cc (class riscv_target) <low_fetch_register>:
Declare.
(riscv_fetch_register): Turn into...
(riscv_target::low_fetch_register): ...this.
(the_low_target): Remove the op field.

Update the callers below.

* linux-low.cc (linux_process_target::fetch_registers)
(linux_process_target::low_fetch_register)

22 files changed:
gdbserver/ChangeLog
gdbserver/linux-aarch64-low.cc
gdbserver/linux-arm-low.cc
gdbserver/linux-bfin-low.cc
gdbserver/linux-cris-low.cc
gdbserver/linux-crisv32-low.cc
gdbserver/linux-ia64-low.cc
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/linux-m32r-low.cc
gdbserver/linux-m68k-low.cc
gdbserver/linux-mips-low.cc
gdbserver/linux-nios2-low.cc
gdbserver/linux-ppc-low.cc
gdbserver/linux-riscv-low.cc
gdbserver/linux-s390-low.cc
gdbserver/linux-sh-low.cc
gdbserver/linux-sparc-low.cc
gdbserver/linux-tic6x-low.cc
gdbserver/linux-tile-low.cc
gdbserver/linux-x86-low.cc
gdbserver/linux-xtensa-low.cc

index 8aaca90c061c24230f1ab55e7144368cb1d4bb55..5f543bb5fa5b8543afbc7090bfc0cecc8bc272f6 100644 (file)
@@ -1,3 +1,47 @@
+2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       Turn the 'fetch_register' linux target op into a method of
+       linux_process_target.
+
+       * linux-low.h (struct linux_target_ops) <fetch_register>: Remove.
+       (class linux_process_target) <low_fetch_register>: Declare.
+       * linux-x86-low.cc (the_low_target)
+       * linux-aarch64-low.cc (the_low_target)
+       * linux-arm-low.cc (the_low_target)
+       * linux-bfin-low.cc (the_low_target)
+       * linux-cris-low.cc (the_low_target)
+       * linux-crisv32-low.cc (the_low_target)
+       * linux-m32r-low.cc (the_low_target)
+       * linux-m68k-low.cc (the_low_target)
+       * linux-nios2-low.cc (the_low_target)
+       * linux-ppc-low.cc (the_low_target)
+       * linux-s390-low.cc (the_low_target)
+       * linux-sh-low.cc (the_low_target)
+       * linux-sparc-low.cc (the_low_target)
+       * linux-tic6x-low.cc (the_low_target)
+       * linux-tile-low.cc (the_low_target)
+       * linux-xtensa-low.cc (the_low_target): Remove the op field.
+       * linux-ia64-low.cc (class ia64_target) <low_fetch_register>:
+       Declare.
+       (ia64_fetch_register): Turn into...
+       (ia64_target::low_fetch_register): ...this.
+       (the_low_target): Remove the op field.
+       * linux-mips-low.cc (class mips_target) <low_fetch_register>:
+       Declare.
+       (mips_fetch_register): Turn into...
+       (mips_target::low_fetch_register): ...this.
+       (the_low_target): Remove the op field.
+       * linux-riscv-low.cc (class riscv_target) <low_fetch_register>:
+       Declare.
+       (riscv_fetch_register): Turn into...
+       (riscv_target::low_fetch_register): ...this.
+       (the_low_target): Remove the op field.
+
+       Update the callers below.
+
+       * linux-low.cc (linux_process_target::fetch_registers)
+       (linux_process_target::low_fetch_register)
+
 2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        Turn the 'cannot_fetch_register' and 'cannot_store_register'
index 19484219d73d5fcb2dca675cadc946de658ea7a3..0bcac19384a3614ef904e992efbd851a03a3ea51 100644 (file)
@@ -3085,7 +3085,6 @@ aarch64_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL, /* fetch_register */
   aarch64_get_pc,
   aarch64_set_pc,
   aarch64_breakpoint_kind_from_pc,
index 896c5fd1e64c0095431dbe9936cc28de7d210395..1bbf0e6977f251d1b6a7d259a0a017165876547d 100644 (file)
@@ -1027,7 +1027,6 @@ arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   arm_breakpoint_kind_from_pc,
index e7cd1e2963775ccdf783f314a491c11ca0617972..a8bb8f03ce02155dd3bc5ee27c4f176c42167be1 100644 (file)
@@ -135,7 +135,6 @@ bfin_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
index 03ca52e39e46df98c9a417567af0011aecd1f544..7956922f7e5821f6d9d7cb60f3f80763483e6438 100644 (file)
@@ -132,7 +132,6 @@ cris_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
index 03f0aa138e2f261104d60d9eb9f08b2fd1e5bff6..828ac111d1067c9874731c8ecded348211d9795a 100644 (file)
@@ -429,7 +429,6 @@ crisv32_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
index 471530a621bffff4c215811148c4d4eccae53bff..377df4f75c307d1473dc32cb307da0258c2e203e 100644 (file)
@@ -38,6 +38,8 @@ protected:
   bool low_cannot_fetch_register (int regno) override;
 
   bool low_cannot_store_register (int regno) override;
+
+  bool low_fetch_register (regcache *regcache, int regno) override;
 };
 
 /* The singleton target ops object.  */
@@ -304,8 +306,8 @@ ia64_target::low_cannot_fetch_register (int regno)
 #define IA64_FR0_REGNUM                128
 #define IA64_FR1_REGNUM                129
 
-static int
-ia64_fetch_register (struct regcache *regcache, int regnum)
+bool
+ia64_target::low_fetch_register (regcache *regcache, int regnum)
 {
   /* r0 cannot be fetched but is always zero.  */
   if (regnum == IA64_GR0_REGNUM)
@@ -314,7 +316,7 @@ ia64_fetch_register (struct regcache *regcache, int regnum)
 
       gdb_assert (sizeof (zero) == register_size (regcache->tdesc, regnum));
       supply_register (regcache, regnum, zero);
-      return 1;
+      return true;
     }
 
   /* fr0 cannot be fetched but is always zero.  */
@@ -324,7 +326,7 @@ ia64_fetch_register (struct regcache *regcache, int regnum)
 
       gdb_assert (sizeof (f_zero) == register_size (regcache->tdesc, regnum));
       supply_register (regcache, regnum, f_zero);
-      return 1;
+      return true;
     }
 
   /* fr1 cannot be fetched but is always one (1.0).  */
@@ -335,10 +337,10 @@ ia64_fetch_register (struct regcache *regcache, int regnum)
 
       gdb_assert (sizeof (f_one) == register_size (regcache->tdesc, regnum));
       supply_register (regcache, regnum, f_one);
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 static struct usrregs_info ia64_usrregs_info =
@@ -367,7 +369,6 @@ ia64_target::low_arch_setup ()
 
 
 struct linux_target_ops the_low_target = {
-  ia64_fetch_register,
 };
 
 /* The linux target ops object.  */
index caa2d8dbd589ae76855c3da1e3062691e106f2b0..c77e92d17b1488fc163e3b8268b5ad752721dade 100644 (file)
@@ -5569,10 +5569,9 @@ linux_process_target::fetch_registers (regcache *regcache, int regno)
 
   if (regno == -1)
     {
-      if (the_low_target.fetch_register != NULL
-         && regs_info->usrregs != NULL)
+      if (regs_info->usrregs != NULL)
        for (regno = 0; regno < regs_info->usrregs->num_regs; regno++)
-         (*the_low_target.fetch_register) (regcache, regno);
+         low_fetch_register (regcache, regno);
 
       all = regsets_fetch_inferior_registers (regs_info->regsets_info, regcache);
       if (regs_info->usrregs != NULL)
@@ -5580,8 +5579,7 @@ linux_process_target::fetch_registers (regcache *regcache, int regno)
     }
   else
     {
-      if (the_low_target.fetch_register != NULL
-         && (*the_low_target.fetch_register) (regcache, regno))
+      if (low_fetch_register (regcache, regno))
        return;
 
       use_regsets = linux_register_in_regsets (regs_info, regno);
@@ -5618,6 +5616,11 @@ linux_process_target::store_registers (regcache *regcache, int regno)
     }
 }
 
+bool
+linux_process_target::low_fetch_register (regcache *regcache, int regno)
+{
+  return false;
+}
 
 /* A wrapper for the read_memory target op.  */
 
index 65c570e06692bdae7dc1b4b7f72c74d6340fdeb2..7ac9086fb9991d51dacab3133a1e19d8dee39e45 100644 (file)
@@ -131,13 +131,6 @@ struct lwp_info;
 
 struct linux_target_ops
 {
-  /* 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
-     REGNO was supplied, false if not, and we should fallback to the
-     standard ptrace methods.  */
-  int (*fetch_register) (struct regcache *regcache, int regno);
-
   CORE_ADDR (*get_pc) (struct regcache *regcache);
   void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc);
 
@@ -598,6 +591,13 @@ protected:
   virtual bool low_cannot_fetch_register (int regno) = 0;
 
   virtual bool low_cannot_store_register (int regno) = 0;
+
+  /* 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
+     REGNO was supplied, false if not, and we should fallback to the
+     standard ptrace methods.  */
+  virtual bool low_fetch_register (regcache *regcache, int regno);
 };
 
 extern linux_process_target *the_linux_target;
index 912708db817e0fe9ed7c10e68d48e769b97271fc..82a503401b8dfc27a923f59367360e007535b245 100644 (file)
@@ -134,7 +134,6 @@ m32r_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_from_pc */
index 08545aa946fb7f7835337e8112e3db9df03f8cb7..6a3a2aab3839f366389de9194e20ab9e31ad249e 100644 (file)
@@ -229,7 +229,6 @@ m68k_supports_hardware_single_step (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
index 0900dc88e0b70c612ca85fb971db6020004019de..ae925ffb6cc0e78b66319a42b557980fc2c0117e 100644 (file)
@@ -40,6 +40,8 @@ protected:
   bool low_cannot_fetch_register (int regno) override;
 
   bool low_cannot_store_register (int regno) override;
+
+  bool low_fetch_register (regcache *regcache, int regno) override;
 };
 
 /* The singleton target ops object.  */
@@ -263,18 +265,18 @@ mips_target::low_cannot_store_register (int regno)
   return false;
 }
 
-static int
-mips_fetch_register (struct regcache *regcache, int regno)
+bool
+mips_target::low_fetch_register (regcache *regcache, int regno)
 {
   const struct target_desc *tdesc = current_process ()->tdesc;
 
   if (find_regno (tdesc, "r0") == regno)
     {
       supply_register_zeroed (regcache, regno);
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 static CORE_ADDR
@@ -950,7 +952,6 @@ mips_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  mips_fetch_register,
   mips_get_pc,
   mips_set_pc,
   NULL, /* breakpoint_kind_from_pc */
index adbb0f2622e002c7dece2a0bc0c391776198f60f..a58d9ca99fb142feed4b890e90460c9ed0a74427 100644 (file)
@@ -251,7 +251,6 @@ nios2_target::get_regs_info ()
 
 struct linux_target_ops the_low_target =
 {
-  NULL,
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
index 968538df3703bdee735128c058a00fa9df17a65b..096308a44d8d12d190fd294c7d9aff2bb934c7a0 100644 (file)
@@ -3392,7 +3392,6 @@ ppc_get_ipa_tdesc_idx (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   ppc_get_pc,
   ppc_set_pc,
   NULL, /* breakpoint_kind_from_pc */
index 4f2e28beafced2135379b4bf068f9fbae61dd727..69af59f720043d53c10fcd1d2d578a4430d00e24 100644 (file)
@@ -45,6 +45,8 @@ protected:
   bool low_cannot_fetch_register (int regno) override;
 
   bool low_cannot_store_register (int regno) override;
+
+  bool low_fetch_register (regcache *regcache, int regno) override;
 };
 
 /* The singleton target ops object.  */
@@ -188,17 +190,17 @@ riscv_target::get_regs_info ()
   return &riscv_regs;
 }
 
-/* Implementation of linux_target_ops method "fetch_register".  */
+/* Implementation of linux target ops method "low_fetch_register".  */
 
-static int
-riscv_fetch_register (struct regcache *regcache, int regno)
+bool
+riscv_target::low_fetch_register (regcache *regcache, int regno)
 {
   const struct target_desc *tdesc = regcache->tdesc;
 
   if (regno != find_regno (tdesc, "zero"))
-    return 0;
+    return false;
   supply_register_zeroed (regcache, regno);
-  return 1;
+  return true;
 }
 
 /* Implementation of linux_target_ops method "get_pc".  */
@@ -291,7 +293,6 @@ riscv_breakpoint_at (CORE_ADDR pc)
 /* RISC-V/Linux target operations.  */
 struct linux_target_ops the_low_target =
 {
-  riscv_fetch_register,
   riscv_get_pc,
   riscv_set_pc,
   riscv_breakpoint_kind_from_pc,
index 2ba0dec0551113511fd7c29d74999813bfbc414f..d25fafa4cdfb3c620d7de10d6858a2cbc431a1ea 100644 (file)
@@ -2812,7 +2812,6 @@ s390_emit_ops (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   s390_get_pc,
   s390_set_pc,
   NULL, /* breakpoint_kind_from_pc */
index b4fd534547e755ad449a9eac3a8da5ab13e64a9b..42bd427d47c6881c88f2ae6dde3a097b9600015b 100644 (file)
@@ -164,7 +164,6 @@ sh_target::low_arch_setup ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
index 4e0d930f800d96f8608fe02eb64e893346cba9a1..b68ed2d36ad8e3c4e9be9ef41d9856dab0fd6412 100644 (file)
@@ -319,7 +319,6 @@ sparc_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_64bit,
   /* No sparc_set_pc is needed.  */
   NULL,
index be6eb98b45c4edba129f9ca10d3edf57ca0c5a0d..5cfdd091c386061b7175398b89226bb30218d202 100644 (file)
@@ -407,7 +407,6 @@ tic6x_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   tic6x_get_pc,
   tic6x_set_pc,
   NULL, /* breakpoint_kind_from_pc */
index b9af7af7fb56fd76547c094e520f568e2bfb9fcd..a6138e78aa784eb67e4b5fc23260d5110645cc90 100644 (file)
@@ -196,7 +196,6 @@ tile_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL,
   linux_get_pc_64bit,
   linux_set_pc_64bit,
   NULL, /* breakpoint_kind_from_pc */
index 8c9ab733ea88c7a684705a5355e892cf3eab3aa8..475d77767f5913567c8a12e009bc8a7c0a5919d2 100644 (file)
@@ -2885,7 +2885,6 @@ x86_get_ipa_tdesc_idx (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL, /* fetch_register */
   x86_get_pc,
   x86_set_pc,
   NULL, /* breakpoint_kind_from_pc */
index 876c2ad63e0d1960b0ac5bd03917baf7ce3e0ba9..d71b2c97fa4df5eeaa65d86c5512af246098d466 100644 (file)
@@ -302,7 +302,6 @@ xtensa_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* fetch_register */
   linux_get_pc_32bit,
   linux_set_pc_32bit,
   NULL, /* breakpoint_kind_from_pc */
This page took 0.041713 seconds and 4 git commands to generate.