[19/31] gdbserver/linux-low: turn 'siginfo_fixup' into a method

Message ID 510dfd0a51dc6460f524befc1f8e5a503f4ca097.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>

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

	* linux-low.h (struct linux_target_ops): Remove the op.
	(class linux_process_target) <siginfo_fixup>
	<low_siginfo_fixup>: Declare.
	* linux-low.cc (siginfo_fixup): Turn into...
	(linux_process_target::siginfo_fixup): ...this.
	(linux_process_target::low_siginfo_fixup): Define.
	* linux-x86-low.cc (class x86_target) <low_siginfo_fixup>: Declare.
	(x86_siginfo_fixup): Turn into...
	(x86_target::low_siginfo_fixup): ...this.
	(the_low_target): Remove the op field.
	* linux-aarch64-low.cc (class aarch64_target):
	<low_siginfo_fixup>: Declare.
	(aarch64_linux_siginfo_fixup): Turn into...
	(aarch64_target::low_siginfo_fixup): ...this.
	(the_low_target): Remove the op field.
	* linux-arm-low.cc (the_low_target): Remove the op field.
	* 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-mips-low.cc (the_low_target): Ditto.
	* linux-ppc-low.cc (the_low_target): Ditto.
	* linux-s390-low.cc (the_low_target): Ditto.
	* linux-sh-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.
---
 gdbserver/linux-aarch64-low.cc | 15 +++++++++------
 gdbserver/linux-arm-low.cc     |  1 -
 gdbserver/linux-bfin-low.cc    |  1 -
 gdbserver/linux-crisv32-low.cc |  1 -
 gdbserver/linux-low.cc         | 20 +++++++++++---------
 gdbserver/linux-low.h          | 18 ++++++++++++------
 gdbserver/linux-m32r-low.cc    |  1 -
 gdbserver/linux-m68k-low.cc    |  1 -
 gdbserver/linux-mips-low.cc    |  1 -
 gdbserver/linux-ppc-low.cc     |  1 -
 gdbserver/linux-s390-low.cc    |  1 -
 gdbserver/linux-sh-low.cc      |  1 -
 gdbserver/linux-tic6x-low.cc   |  1 -
 gdbserver/linux-tile-low.cc    |  1 -
 gdbserver/linux-x86-low.cc     | 12 +++++++-----
 gdbserver/linux-xtensa-low.cc  |  1 -
 16 files changed, 39 insertions(+), 38 deletions(-)

-- 
2.17.1

Patch

diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 3cd0b48caae..458c5a77209 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -91,6 +91,9 @@  protected:
   bool low_stopped_by_watchpoint () override;
 
   CORE_ADDR low_stopped_data_address () override;
+
+  bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
+			  int direction) override;
 };
 
 /* The singleton target ops object.  */
@@ -494,10 +497,11 @@  ps_get_thread_area (struct ps_prochandle *ph,
 				     is_64bit_tdesc ());
 }
 
-/* Implementation of linux_target_ops method "siginfo_fixup".  */
+/* Implementation of linux target ops method "low_siginfo_fixup".  */
 
-static int
-aarch64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
+bool
+aarch64_target::low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
+				   int direction)
 {
   /* Is the inferior 32-bit?  If so, then fixup the siginfo object.  */
   if (!is_64bit_tdesc ())
@@ -509,10 +513,10 @@  aarch64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
 	aarch64_siginfo_from_compat_siginfo (native,
 					     (struct compat_siginfo *) inf);
 
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 /* Implementation of linux_target_ops method "new_process".  */
@@ -3114,7 +3118,6 @@  aarch64_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  aarch64_linux_siginfo_fixup,
   aarch64_linux_new_process,
   aarch64_linux_delete_process,
   aarch64_linux_new_thread,
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index a6539f3bd0b..55859780ae7 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -1107,7 +1107,6 @@  arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   arm_new_process,
   arm_delete_process,
   arm_new_thread,
diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc
index ccbd708d83c..5843ac29f36 100644
--- a/gdbserver/linux-bfin-low.cc
+++ b/gdbserver/linux-bfin-low.cc
@@ -165,7 +165,6 @@  bfin_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc
index f3376e89abb..0e228a859e2 100644
--- a/gdbserver/linux-crisv32-low.cc
+++ b/gdbserver/linux-crisv32-low.cc
@@ -470,7 +470,6 @@  crisv32_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 62622e097e4..47a36ee3052 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6016,16 +6016,11 @@  linux_process_target::qxfer_osdata (const char *annex,
   return linux_common_xfer_osdata (annex, readbuf, offset, len);
 }
 
-/* Convert a native/host siginfo object, into/from the siginfo in the
-   layout of the inferiors' architecture.  */
-
-static void
-siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction)
+void
+linux_process_target::siginfo_fixup (siginfo_t *siginfo,
+				     gdb_byte *inf_siginfo, int direction)
 {
-  int done = 0;
-
-  if (the_low_target.siginfo_fixup != NULL)
-    done = the_low_target.siginfo_fixup (siginfo, inf_siginfo, direction);
+  bool done = low_siginfo_fixup (siginfo, inf_siginfo, direction);
 
   /* If there was no callback, or the callback didn't do anything,
      then just do a straight memcpy.  */
@@ -6038,6 +6033,13 @@  siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction)
     }
 }
 
+bool
+linux_process_target::low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
+					 int direction)
+{
+  return false;
+}
+
 bool
 linux_process_target::supports_qxfer_siginfo ()
 {
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 1f93fde8c04..ced71f34cf0 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -131,12 +131,6 @@  struct lwp_info;
 
 struct linux_target_ops
 {
-  /* 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.
-     If DIRECTION is 0, copy from NATIVE to INF.  */
-  int (*siginfo_fixup) (siginfo_t *native, gdb_byte *inf, int direction);
-
   /* Hook to call when a new process is created or attached to.
      If extra per-process architecture-specific data is needed,
      allocate it here.  */
@@ -630,6 +624,11 @@  class linux_process_target : public process_stratum_target
      registers meanwhile, we have the cached data we can rely on.  */
   bool check_stopped_by_watchpoint (lwp_info *child);
 
+  /* Convert a native/host siginfo object, into/from the siginfo in the
+     layout of the inferiors' architecture.  */
+  void siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo,
+		      int direction);
+
 protected:
   /* The architecture-specific "low" methods are listed below.  */
 
@@ -685,6 +684,13 @@  class linux_process_target : public process_stratum_target
   virtual void low_supply_ptrace_register (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.
+     If DIRECTION is 0, copy from NATIVE to INF.  */
+  virtual bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
+				  int direction);
+
   /* 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 1b963978f75..e664c6d2a82 100644
--- a/gdbserver/linux-m32r-low.cc
+++ b/gdbserver/linux-m32r-low.cc
@@ -163,7 +163,6 @@  m32r_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc
index 81ccbe65b11..39e45171428 100644
--- a/gdbserver/linux-m68k-low.cc
+++ b/gdbserver/linux-m68k-low.cc
@@ -259,7 +259,6 @@  m68k_supports_hardware_single_step (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index 402cb2f1245..52be7f0f748 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -988,7 +988,6 @@  mips_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   mips_linux_new_process,
   mips_linux_delete_process,
   mips_linux_new_thread,
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 2cbaf5303e1..625bc012623 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -3430,7 +3430,6 @@  ppc_get_ipa_tdesc_idx (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index ac86f26ee17..937628fe25f 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -2839,7 +2839,6 @@  s390_emit_ops (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 215838eae27..1bbfb472409 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -194,7 +194,6 @@  sh_target::low_arch_setup ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index b094a9ba60e..77ffc28f186 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -425,7 +425,6 @@  tic6x_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc
index 0d5bfae1f2d..66302ef6fe5 100644
--- a/gdbserver/linux-tile-low.cc
+++ b/gdbserver/linux-tile-low.cc
@@ -226,7 +226,6 @@  tile_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 299f848a4a1..5d16e89aca4 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -141,6 +141,10 @@  protected:
   /* 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).  */
+
+  /* Need to fix up i386 siginfo if host is amd64.  */
+  bool low_siginfo_fixup (siginfo_t *native, gdb_byte *inf,
+			  int direction) override;
 };
 
 /* The singleton target ops object.  */
@@ -750,8 +754,8 @@  x86_debug_reg_state (pid_t pid)
    from INF to PTRACE.  If DIRECTION is 0, copy from PTRACE to
    INF.  */
 
-static int
-x86_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
+bool
+x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
 {
 #ifdef __x86_64__
   unsigned int machine;
@@ -768,7 +772,7 @@  x86_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
 					     FIXUP_X32);
 #endif
 
-  return 0;
+  return false;
 }
 
 static int use_xml;
@@ -2919,8 +2923,6 @@  x86_get_ipa_tdesc_idx (void)
 
 struct linux_target_ops the_low_target =
 {
-  /* need to fix up i386 siginfo if host is amd64 */
-  x86_siginfo_fixup,
   x86_linux_new_process,
   x86_linux_delete_process,
   x86_linux_new_thread,
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 9ef7c9d4460..957858980d6 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -331,7 +331,6 @@  xtensa_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* siginfo_fixup */
   NULL, /* new_process */
   NULL, /* delete_process */
   NULL, /* new_thread */