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

Turn the 'get_syscall_trapinfo' linux target op into a method
of process_stratum_target.

* linux-low.h (struct linux_target_ops): Remove the op.
(class linux_process_target) <get_syscall_trapinfo>
<gdb_catch_this_syscall>
<low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
* linux-low.cc (get_syscall_trapinfo): Turn into...
(linux_process_target::get_syscall_trapinfo): ...this.
(linux_process_target::low_get_syscall_trapinfo): Define.
(gdb_catch_this_syscall_p): Turn into...
(linux_process_target::gdb_catch_this_syscall): ...this.
(linux_process_target::low_supports_catch_syscall): Define.

Update the callers below.

(linux_process_target::wait_1)
(linux_process_target::supports_catch_syscall)

* linux-x86-low.cc (class x86_target) <low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
(x86_target::low_supports_catch_syscall): Define.
(x86_get_syscall_trapinfo): Turn into...
(x86_target::low_get_syscall_trapinfo): ...this.
(the_low_target): Remove the op field.
* linux-aarch64-low.cc (class aarch64_target)
<low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
(aarch64_target::low_supports_catch_syscall): Define.
(aarch64_get_syscall_trapinfo): Turn into...
(aarch64_target::low_get_syscall_trapinfo): ...this.
(the_low_target): Remove the op field.
* linux-arm-low.cc (class arm_target) <low_supports_catch_syscall>
<low_get_syscall_trapinfo>: Declare.
(arm_target::low_supports_catch_syscall): Define.
(arm_get_syscall_trapinfo): Turn into...
(arm_target::low_get_syscall_trapinfo): ...this.
(the_low_target): Remove the op field.
* linux-ppc-low.cc (the_low_target): Remove the op field.
* linux-s390-low.cc (the_low_target): Remove the op field.

gdbserver/ChangeLog
gdbserver/linux-aarch64-low.cc
gdbserver/linux-arm-low.cc
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/linux-ppc-low.cc
gdbserver/linux-s390-low.cc
gdbserver/linux-x86-low.cc

index 9f14c57933e0686cd6431389c8bd3b92986e0bdc..4649ec2fb10da5afd480a9771f5ec7c8177f3351 100644 (file)
@@ -1,3 +1,47 @@
+2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       Turn the 'get_syscall_trapinfo' linux target op into a method
+       of process_stratum_target.
+
+       * linux-low.h (struct linux_target_ops): Remove the op.
+       (class linux_process_target) <get_syscall_trapinfo>
+       <gdb_catch_this_syscall>
+       <low_supports_catch_syscall>
+       <low_get_syscall_trapinfo>: Declare.
+       * linux-low.cc (get_syscall_trapinfo): Turn into...
+       (linux_process_target::get_syscall_trapinfo): ...this.
+       (linux_process_target::low_get_syscall_trapinfo): Define.
+       (gdb_catch_this_syscall_p): Turn into...
+       (linux_process_target::gdb_catch_this_syscall): ...this.
+       (linux_process_target::low_supports_catch_syscall): Define.
+
+       Update the callers below.
+
+       (linux_process_target::wait_1)
+       (linux_process_target::supports_catch_syscall)
+
+       * linux-x86-low.cc (class x86_target) <low_supports_catch_syscall>
+       <low_get_syscall_trapinfo>: Declare.
+       (x86_target::low_supports_catch_syscall): Define.
+       (x86_get_syscall_trapinfo): Turn into...
+       (x86_target::low_get_syscall_trapinfo): ...this.
+       (the_low_target): Remove the op field.
+       * linux-aarch64-low.cc (class aarch64_target)
+       <low_supports_catch_syscall>
+       <low_get_syscall_trapinfo>: Declare.
+       (aarch64_target::low_supports_catch_syscall): Define.
+       (aarch64_get_syscall_trapinfo): Turn into...
+       (aarch64_target::low_get_syscall_trapinfo): ...this.
+       (the_low_target): Remove the op field.
+       * linux-arm-low.cc (class arm_target) <low_supports_catch_syscall>
+       <low_get_syscall_trapinfo>: Declare.
+       (arm_target::low_supports_catch_syscall): Define.
+       (arm_get_syscall_trapinfo): Turn into...
+       (arm_target::low_get_syscall_trapinfo): ...this.
+       (the_low_target): Remove the op field.
+       * linux-ppc-low.cc (the_low_target): Remove the op field.
+       * linux-s390-low.cc (the_low_target): Remove the op field.
+
 2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        Remove the 'supports_hardware_single_step' linux target op and
index 4f7c2578eb8938bb434e9dd0149f354b3f7a9b91..f1eae958d0188271858f03c7d1b2078c10f7f912 100644 (file)
@@ -125,6 +125,10 @@ protected:
   int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
 
   bool low_supports_range_stepping () override;
+
+  bool low_supports_catch_syscall () override;
+
+  void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
 };
 
 /* The singleton target ops object.  */
@@ -768,10 +772,16 @@ aarch64_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
   return 0;
 }
 
-/* Implementation of linux_target_ops method "get_syscall_trapinfo".  */
+bool
+aarch64_target::low_supports_catch_syscall ()
+{
+  return true;
+}
 
-static void
-aarch64_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
+/* Implementation of linux target ops method "low_get_syscall_trapinfo".  */
+
+void
+aarch64_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
 {
   int use_64bit = register_size (regcache->tdesc, 0) == 8;
 
@@ -3159,7 +3169,6 @@ aarch64_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
 
 struct linux_target_ops the_low_target =
 {
-  aarch64_get_syscall_trapinfo,
 };
 
 /* The linux target ops object.  */
index 2e3d00a489afd94a40398f60e7fbbf7b1ce5a4a0..4577c83bfb03b9f397eb555a50466b231015a29c 100644 (file)
@@ -113,6 +113,10 @@ protected:
   void low_new_fork (process_info *parent, process_info *child) override;
 
   void low_prepare_to_resume (lwp_info *lwp) override;
+
+  bool low_supports_catch_syscall () override;
+
+  void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
 };
 
 /* The singleton target ops object.  */
@@ -1038,10 +1042,16 @@ arm_target::supports_hardware_single_step ()
   return false;
 }
 
-/* Implementation of linux_target_ops method "get_syscall_trapinfo".  */
+bool
+arm_target::low_supports_catch_syscall ()
+{
+  return true;
+}
 
-static void
-arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
+/* Implementation of linux target ops method "low_get_syscall_trapinfo".  */
+
+void
+arm_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
 {
   if (arm_is_thumb_mode ())
     collect_register_by_name (regcache, "r7", sysno);
@@ -1052,7 +1062,7 @@ arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
 
       collect_register_by_name (regcache, "pc", &pc);
 
-      if (the_target->read_memory (pc - 4, (unsigned char *) &insn, 4))
+      if (read_memory (pc - 4, (unsigned char *) &insn, 4))
        *sysno = UNKNOWN_SYSCALL;
       else
        {
@@ -1119,7 +1129,6 @@ arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  arm_get_syscall_trapinfo,
 };
 
 /* The linux target ops object.  */
index 56615430b59e1d8291fe191db5dcd7b478455aae..cd04160978de1f9e59b96897b85253c0c12705e5 100644 (file)
@@ -754,28 +754,17 @@ linux_process_target::get_pc (lwp_info *lwp)
   return pc;
 }
 
-/* This function should only be called if LWP got a SYSCALL_SIGTRAP.
-   Fill *SYSNO with the syscall nr trapped.  */
-
-static void
-get_syscall_trapinfo (struct lwp_info *lwp, int *sysno)
+void
+linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno)
 {
   struct thread_info *saved_thread;
   struct regcache *regcache;
 
-  if (the_low_target.get_syscall_trapinfo == NULL)
-    {
-      /* If we cannot get the syscall trapinfo, report an unknown
-        system call number.  */
-      *sysno = UNKNOWN_SYSCALL;
-      return;
-    }
-
   saved_thread = current_thread;
   current_thread = get_lwp_thread (lwp);
 
   regcache = get_thread_regcache (current_thread, 1);
-  (*the_low_target.get_syscall_trapinfo) (regcache, sysno);
+  low_get_syscall_trapinfo (regcache, sysno);
 
   if (debug_threads)
     debug_printf ("get_syscall_trapinfo sysno %d\n", *sysno);
@@ -783,6 +772,13 @@ get_syscall_trapinfo (struct lwp_info *lwp, int *sysno)
   current_thread = saved_thread;
 }
 
+void
+linux_process_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
+{
+  /* By default, report an unknown system call number.  */
+  *sysno = UNKNOWN_SYSCALL;
+}
+
 bool
 linux_process_target::save_stop_reason (lwp_info *lwp)
 {
@@ -2961,29 +2957,26 @@ gdb_catching_syscalls_p (struct lwp_info *event_child)
   return !proc->syscalls_to_catch.empty ();
 }
 
-/* Returns 1 if GDB is interested in the event_child syscall.
-   Only to be called when stopped reason is SYSCALL_SIGTRAP.  */
-
-static int
-gdb_catch_this_syscall_p (struct lwp_info *event_child)
+bool
+linux_process_target::gdb_catch_this_syscall (lwp_info *event_child)
 {
   int sysno;
   struct thread_info *thread = get_lwp_thread (event_child);
   struct process_info *proc = get_thread_process (thread);
 
   if (proc->syscalls_to_catch.empty ())
-    return 0;
+    return false;
 
   if (proc->syscalls_to_catch[0] == ANY_SYSCALL)
-    return 1;
+    return true;
 
   get_syscall_trapinfo (event_child, &sysno);
 
   for (int iter : proc->syscalls_to_catch)
     if (iter == sysno)
-      return 1;
+      return true;
 
-  return 0;
+  return false;
 }
 
 ptid_t
@@ -3326,7 +3319,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
   /* Check if GDB is interested in this syscall.  */
   if (WIFSTOPPED (w)
       && WSTOPSIG (w) == SYSCALL_SIGTRAP
-      && !gdb_catch_this_syscall_p (event_child))
+      && !gdb_catch_this_syscall (event_child))
     {
       if (debug_threads)
        {
@@ -6404,10 +6397,16 @@ linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
 bool
 linux_process_target::supports_catch_syscall ()
 {
-  return (the_low_target.get_syscall_trapinfo != NULL
+  return (low_supports_catch_syscall ()
          && linux_supports_tracesysgood ());
 }
 
+bool
+linux_process_target::low_supports_catch_syscall ()
+{
+  return false;
+}
+
 int
 linux_process_target::get_ipa_tdesc_idx ()
 {
index 0182be17ce1b337b54268261866db6a6f1e787b1..1f1c3820edbd71f90e2cc129e6916df40e3879de 100644 (file)
@@ -131,10 +131,6 @@ struct lwp_info;
 
 struct linux_target_ops
 {
-  /* Fill *SYSNO with the syscall nr trapped.  Only to be called when
-     inferior is stopped due to SYSCALL_SIGTRAP.  */
-  void (*get_syscall_trapinfo) (struct regcache *regcache, int *sysno);
-
   /* See target.h.  */
   int (*get_ipa_tdesc_idx) (void);
 };
@@ -591,6 +587,14 @@ private: /* Back to private.  */
   fast_tpoint_collect_result linux_fast_tracepoint_collecting
     (lwp_info *lwp, fast_tpoint_collect_status *status);
 
+  /* This function should only be called if LWP got a SYSCALL_SIGTRAP.
+     Fill *SYSNO with the syscall nr trapped.  */
+  void get_syscall_trapinfo (lwp_info *lwp, int *sysno);
+
+  /* Returns true if GDB is interested in the event_child syscall.
+     Only to be called when stopped reason is SYSCALL_SIGTRAP.  */
+  bool gdb_catch_this_syscall (lwp_info *event_child);
+
 protected:
   /* The architecture-specific "low" methods are listed below.  */
 
@@ -684,6 +688,14 @@ protected:
   /* Returns true if the low target supports range stepping.  */
   virtual bool low_supports_range_stepping ();
 
+  /* Return true if the target supports catch syscall.  Such targets
+     override the low_get_syscall_trapinfo method below.  */
+  virtual bool low_supports_catch_syscall ();
+
+  /* Fill *SYSNO with the syscall nr trapped.  Only to be called when
+     inferior is stopped due to SYSCALL_SIGTRAP.  */
+  virtual void low_get_syscall_trapinfo (regcache *regcache, int *sysno);
+
   /* How many bytes the PC should be decremented after a break.  */
   virtual int low_decr_pc_after_break ();
 };
index 5c6930751e19ee12d5406f7ddb4616625c91d128..71ad842243cc698c33db9731925bcb15d3a8991c 100644 (file)
@@ -3446,7 +3446,6 @@ ppc_get_ipa_tdesc_idx (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_syscall_trapinfo */
   ppc_get_ipa_tdesc_idx,
 };
 
index 3ab14d884ee6ca745663c900aa98166db7d367c2..d09860f36db7aaad0ccf28f503d962b87614d1b7 100644 (file)
@@ -2855,7 +2855,6 @@ s390_target::emit_ops ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_syscall_trapinfo */
   s390_get_ipa_tdesc_idx,
 };
 
index c05928d155606be68e5f7f7643b50770433fafb4..2837994653de7de51e6007a0057ecd4a002d4b30 100644 (file)
@@ -176,6 +176,10 @@ protected:
 
   bool low_supports_range_stepping () override;
 
+  bool low_supports_catch_syscall () override;
+
+  void low_get_syscall_trapinfo (regcache *regcache, int *sysno) override;
+
 private:
 
   /* Update all the target description of all processes; a new GDB
@@ -1110,11 +1114,17 @@ x86_target::low_arch_setup ()
   current_process ()->tdesc = x86_linux_read_description ();
 }
 
+bool
+x86_target::low_supports_catch_syscall ()
+{
+  return true;
+}
+
 /* Fill *SYSNO and *SYSRET with the syscall nr trapped and the syscall return
    code.  This should only be called if LWP got a SYSCALL_SIGTRAP.  */
 
-static void
-x86_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
+void
+x86_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno)
 {
   int use_64bit = register_size (regcache->tdesc, 0) == 8;
 
@@ -2985,7 +2995,6 @@ x86_get_ipa_tdesc_idx (void)
 
 struct linux_target_ops the_low_target =
 {
-  x86_get_syscall_trapinfo,
   x86_get_ipa_tdesc_idx,
 };
 
This page took 0.036039 seconds and 4 git commands to generate.