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

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

* linux-low.h (struct linux_target_ops): Remove the op.
(class linux_process_target) <stuck_in_jump_pad>
<linux_fast_tracepoint_collecting>
<low_get_thread_area>: Declare.
* linux-low.cc (supports_fast_tracepoints): Remove.
(linux_fast_tracepoint_collecting): Turn into...
(linux_process_target::linux_fast_tracepoint_collecting): ...this.
(linux_process_target::low_get_thread_area): Define.
(stuck_in_jump_pad_callback): Turn into...
(linux_process_target::stuck_in_jump_pad): ...this.

Update the caller below.

(linux_process_target::stabilize_threads)

* linux-x86-low.cc (class x86_target) <low_get_thread_area>:
Declare.
(x86_get_thread_area): Turn into...
(x86_target::low_get_thread_area): ...this.
(the_low_target): Remove the op field.
* linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>:
Declare.
(aarch64_get_thread_area): Turn into...
(aarch64_target::low_get_thread_area): ...this.
(the_low_target): Remove the op field.
* linux-ppc-low.cc (class ppc_target) <low_get_thread_area>:
Declare.
(ppc_get_thread_area): Turn into...
(ppc_target::low_get_thread_area): ...this.
(the_low_target): Remove the op field.
* linux-s390-low.cc (class s390_target) <low_get_thread_area>:
Declare.
(s390_get_thread_area): Turn into...
(s390_target::low_get_thread_area): ...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-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.

16 files changed:
gdbserver/ChangeLog
gdbserver/linux-aarch64-low.cc
gdbserver/linux-arm-low.cc
gdbserver/linux-bfin-low.cc
gdbserver/linux-crisv32-low.cc
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/linux-m32r-low.cc
gdbserver/linux-m68k-low.cc
gdbserver/linux-ppc-low.cc
gdbserver/linux-s390-low.cc
gdbserver/linux-sh-low.cc
gdbserver/linux-tic6x-low.cc
gdbserver/linux-tile-low.cc
gdbserver/linux-x86-low.cc
gdbserver/linux-xtensa-low.cc

index a7635e06b1e98a244fd4297df9e520fbcc8eeabf..e0c1f20720ee16507c5a4f116fc23339cd7676c4 100644 (file)
@@ -1,3 +1,53 @@
+2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       Turn the 'get_thread_area' linux target op into a method of
+       process_stratum_target.
+
+       * linux-low.h (struct linux_target_ops): Remove the op.
+       (class linux_process_target) <stuck_in_jump_pad>
+       <linux_fast_tracepoint_collecting>
+       <low_get_thread_area>: Declare.
+       * linux-low.cc (supports_fast_tracepoints): Remove.
+       (linux_fast_tracepoint_collecting): Turn into...
+       (linux_process_target::linux_fast_tracepoint_collecting): ...this.
+       (linux_process_target::low_get_thread_area): Define.
+       (stuck_in_jump_pad_callback): Turn into...
+       (linux_process_target::stuck_in_jump_pad): ...this.
+
+       Update the caller below.
+
+       (linux_process_target::stabilize_threads)
+
+       * linux-x86-low.cc (class x86_target) <low_get_thread_area>:
+       Declare.
+       (x86_get_thread_area): Turn into...
+       (x86_target::low_get_thread_area): ...this.
+       (the_low_target): Remove the op field.
+       * linux-aarch64-low.cc (class aarch64_target) <low_get_thread_area>:
+       Declare.
+       (aarch64_get_thread_area): Turn into...
+       (aarch64_target::low_get_thread_area): ...this.
+       (the_low_target): Remove the op field.
+       * linux-ppc-low.cc (class ppc_target) <low_get_thread_area>:
+       Declare.
+       (ppc_get_thread_area): Turn into...
+       (ppc_target::low_get_thread_area): ...this.
+       (the_low_target): Remove the op field.
+       * linux-s390-low.cc (class s390_target) <low_get_thread_area>:
+       Declare.
+       (s390_get_thread_area): Turn into...
+       (s390_target::low_get_thread_area): ...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-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.
+
 2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        Remote the 'supports_tracepoints' linux target op and let the
index cbca3d6a9ad1f7ac3b0be9ce394e6d557b3bf99f..c58fb44ec8a689ed4c0fe83eca037c9675b26b23 100644 (file)
@@ -107,6 +107,8 @@ protected:
   void low_new_fork (process_info *parent, process_info *child) override;
 
   void low_prepare_to_resume (lwp_info *lwp) override;
+
+  int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
 };
 
 /* The singleton target ops object.  */
@@ -731,10 +733,10 @@ aarch64_target::supports_tracepoints ()
     }
 }
 
-/* Implementation of linux_target_ops method "get_thread_area".  */
+/* Implementation of linux target ops method "low_get_thread_area".  */
 
-static int
-aarch64_get_thread_area (int lwpid, CORE_ADDR *addrp)
+int
+aarch64_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
 {
   struct iovec iovec;
   uint64_t reg;
@@ -3149,7 +3151,6 @@ aarch64_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  aarch64_get_thread_area,
   aarch64_install_fast_tracepoint_jump_pad,
   aarch64_emit_ops,
   aarch64_get_min_fast_tracepoint_insn_len,
index 383f217277add4953ae31e5b28af96ccac6d9c14..e52341da63a614778313c54044b2ce01e402a6c5 100644 (file)
@@ -1117,7 +1117,6 @@ arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index 06fcf76bf50f727e51382827a731b70478f49f88..7a11c5b7b096619b4af86ef23c1955c826b6a9ef 100644 (file)
@@ -171,7 +171,6 @@ bfin_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index ab711c41690dc9a84d713877f9b6fef64f55cfb1..1aecd252ce75a202b0ebc0455da6ab17d41838ed 100644 (file)
@@ -468,7 +468,6 @@ crisv32_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index 2b522348201750a6946f638c92bd3b0ef52b36bf..7172194610889fc31d23ecedea3c3414929e6cc6 100644 (file)
@@ -322,16 +322,6 @@ linux_process_target::low_decr_pc_after_break ()
   return 0;
 }
 
-/* Returns true if this target can support fast tracepoints.  This
-   does not mean that the in-process agent has been loaded in the
-   inferior.  */
-
-static int
-supports_fast_tracepoints (void)
-{
-  return the_low_target.install_fast_tracepoint_jump_pad != NULL;
-}
-
 /* True if LWP is stopped in its stepping range.  */
 
 static int
@@ -1997,29 +1987,29 @@ handle_tracepoints (struct lwp_info *lwp)
   return 0;
 }
 
-/* Convenience wrapper.  Returns information about LWP's fast tracepoint
-   collection status.  */
-
-static fast_tpoint_collect_result
-linux_fast_tracepoint_collecting (struct lwp_info *lwp,
-                                 struct fast_tpoint_collect_status *status)
+fast_tpoint_collect_result
+linux_process_target::linux_fast_tracepoint_collecting
+  (lwp_info *lwp, fast_tpoint_collect_status *status)
 {
   CORE_ADDR thread_area;
   struct thread_info *thread = get_lwp_thread (lwp);
 
-  if (the_low_target.get_thread_area == NULL)
-    return fast_tpoint_collect_result::not_collecting;
-
   /* Get the thread area address.  This is used to recognize which
      thread is which when tracing with the in-process agent library.
      We don't read anything from the address, and treat it as opaque;
      it's the address itself that we assume is unique per-thread.  */
-  if ((*the_low_target.get_thread_area) (lwpid_of (thread), &thread_area) == -1)
+  if (low_get_thread_area (lwpid_of (thread), &thread_area) == -1)
     return fast_tpoint_collect_result::not_collecting;
 
   return fast_tracepoint_collecting (thread_area, lwp->stop_pc, status);
 }
 
+int
+linux_process_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
+{
+  return -1;
+}
+
 bool
 linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
 {
@@ -2834,7 +2824,6 @@ unsuspend_all_lwps (struct lwp_info *except)
     });
 }
 
-static bool stuck_in_jump_pad_callback (thread_info *thread);
 static bool lwp_running (thread_info *thread);
 
 /* Stabilize threads (move out of jump pads).
@@ -2870,7 +2859,10 @@ static bool lwp_running (thread_info *thread);
 void
 linux_process_target::stabilize_threads ()
 {
-  thread_info *thread_stuck = find_thread (stuck_in_jump_pad_callback);
+  thread_info *thread_stuck = find_thread ([this] (thread_info *thread)
+                               {
+                                 return stuck_in_jump_pad (thread);
+                               });
 
   if (thread_stuck != NULL)
     {
@@ -2926,7 +2918,10 @@ linux_process_target::stabilize_threads ()
 
   if (debug_threads)
     {
-      thread_stuck = find_thread (stuck_in_jump_pad_callback);
+      thread_stuck = find_thread ([this] (thread_info *thread)
+                      {
+                        return stuck_in_jump_pad (thread);
+                      });
 
       if (thread_stuck != NULL)
        debug_printf ("couldn't stabilize, LWP %ld got stuck in jump pad\n",
@@ -3949,13 +3944,8 @@ linux_process_target::wait_for_sigstop ()
     }
 }
 
-/* Returns true if THREAD is stopped in a jump pad, and we can't
-   move it out, because we need to report the stop event to GDB.  For
-   example, if the user puts a breakpoint in the jump pad, it's
-   because she wants to debug it.  */
-
-static bool
-stuck_in_jump_pad_callback (thread_info *thread)
+bool
+linux_process_target::stuck_in_jump_pad (thread_info *thread)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
 
index 223b19ddafdf19bde60b4c4cf5e2c4f771a23e6c..58e5e67c1982e9247f62b82cd65a6355318c0dfe 100644 (file)
@@ -131,10 +131,6 @@ struct lwp_info;
 
 struct linux_target_ops
 {
-  /* Fill ADDRP with the thread area address of LWPID.  Returns 0 on
-     success, -1 on failure.  */
-  int (*get_thread_area) (int lwpid, CORE_ADDR *addrp);
-
   /* Install a fast tracepoint jump pad.  See target.h for
      comments.  */
   int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
@@ -624,6 +620,17 @@ private: /* Back to private.  */
   ptid_t filter_exit_event (lwp_info *event_child,
                            target_waitstatus *ourstatus);
 
+  /* Returns true if THREAD is stopped in a jump pad, and we can't
+     move it out, because we need to report the stop event to GDB.  For
+     example, if the user puts a breakpoint in the jump pad, it's
+     because she wants to debug it.  */
+  bool stuck_in_jump_pad (thread_info *thread);
+
+  /* Convenience wrapper.  Returns information about LWP's fast tracepoint
+     collection status.  */
+  fast_tpoint_collect_result linux_fast_tracepoint_collecting
+    (lwp_info *lwp, fast_tpoint_collect_status *status);
+
 protected:
   /* The architecture-specific "low" methods are listed below.  */
 
@@ -710,6 +717,10 @@ protected:
   /* Hook to call prior to resuming a thread.  */
   virtual void low_prepare_to_resume (lwp_info *lwp);
 
+  /* Fill ADDRP with the thread area address of LWPID.  Returns 0 on
+     success, -1 on failure.  */
+  virtual int low_get_thread_area (int lwpid, CORE_ADDR *addrp);
+
   /* How many bytes the PC should be decremented after a break.  */
   virtual int low_decr_pc_after_break ();
 };
index 601522bc6111e66fdea33d313f9dd447ee4d1060..48dadd69f7ec057b294bd29970ebc86461762218 100644 (file)
@@ -161,7 +161,6 @@ m32r_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index 6e16764d394b009b57998efcd945cc257c4f454f..acbb6dde1d7e86da334347f6db28c6e2c1165368 100644 (file)
@@ -265,7 +265,6 @@ m68k_supports_hardware_single_step (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index 063707c5c7c6aa10c81f6dae5a8f0d48f294c7ef..5935c42a7764f9e8200edb19ee995cbda81a4c01 100644 (file)
@@ -86,6 +86,8 @@ protected:
 
   int low_remove_point (raw_bkpt_type type, CORE_ADDR addr,
                        int size, raw_breakpoint *bp) override;
+
+  int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
 };
 
 /* The singleton target ops object.  */
@@ -1040,8 +1042,8 @@ ppc_target::supports_tracepoints ()
    don't read anything from the address, and treat it as opaque; it's
    the address itself that we assume is unique per-thread.  */
 
-static int
-ppc_get_thread_area (int lwpid, CORE_ADDR *addr)
+int
+ppc_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
 {
   struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid));
   struct thread_info *thr = get_lwp_thread (lwp);
@@ -3431,7 +3433,6 @@ ppc_get_ipa_tdesc_idx (void)
 }
 
 struct linux_target_ops the_low_target = {
-  ppc_get_thread_area,
   ppc_install_fast_tracepoint_jump_pad,
   ppc_emit_ops,
   ppc_get_min_fast_tracepoint_insn_len,
index 22305fe9ce910f52236c40e18ede04e91a5a88b7..28a0a8b449f1834f5966ca07212823197b90f23d 100644 (file)
@@ -88,6 +88,8 @@ protected:
   int low_decr_pc_after_break () override;
 
   bool low_breakpoint_at (CORE_ADDR pc) override;
+
+  int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
 };
 
 /* The singleton target ops object.  */
@@ -780,10 +782,10 @@ s390_target::supports_tracepoints ()
   return true;
 }
 
-/* Implementation of linux_target_ops method "get_thread_area".  */
+/* Implementation of linux target ops method "low_get_thread_area".  */
 
-static int
-s390_get_thread_area (int lwpid, CORE_ADDR *addrp)
+int
+s390_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
 {
   CORE_ADDR res = ptrace (PTRACE_PEEKUSER, lwpid, (long) PT_ACR0, (long) 0);
 #ifdef __s390x__
@@ -2847,7 +2849,6 @@ s390_emit_ops (void)
 }
 
 struct linux_target_ops the_low_target = {
-  s390_get_thread_area,
   s390_install_fast_tracepoint_jump_pad,
   s390_emit_ops,
   s390_get_min_fast_tracepoint_insn_len,
index 4fead793f9730636100647346a3e16acd56167a5..30a966d5b4f34bb746d8c31f15e0ec92d025d11a 100644 (file)
@@ -192,7 +192,6 @@ sh_target::low_arch_setup ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index e385edd4324d873dc21b184070eac391d644f5af..f0f9917c6f079c63d24b4a904c7d01da981bbe77 100644 (file)
@@ -423,7 +423,6 @@ tic6x_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index ad2e716e4340488db4b6790f5eda45300ff733d5..d64d63bdeae0840e6dc618973bd908644b6d9394 100644 (file)
@@ -224,7 +224,6 @@ tile_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
index b7bbc81cbee5b2c61b386cda43041e5e398079a0..664d0d9f19912cf924eebaf6a44f5d540e82cfc3 100644 (file)
@@ -158,6 +158,8 @@ protected:
 
   void low_prepare_to_resume (lwp_info *lwp) override;
 
+  int low_get_thread_area (int lwpid, CORE_ADDR *addrp) override;
+
 private:
 
   /* Update all the target description of all processes; a new GDB
@@ -311,8 +313,8 @@ ps_get_thread_area (struct ps_prochandle *ph,
    don't read anything from the address, and treat it as opaque; it's
    the address itself that we assume is unique per-thread.  */
 
-static int
-x86_get_thread_area (int lwpid, CORE_ADDR *addr)
+int
+x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
 {
 #ifdef __x86_64__
   int use_64bit = is_64bit_tdesc ();
@@ -2969,7 +2971,6 @@ x86_get_ipa_tdesc_idx (void)
 
 struct linux_target_ops the_low_target =
 {
-  x86_get_thread_area,
   x86_install_fast_tracepoint_jump_pad,
   x86_emit_ops,
   x86_get_min_fast_tracepoint_insn_len,
index 5a009df551d8666d14883c2ba79415b959b35757..7bef61ac32994813404027b09497bf654459273f 100644 (file)
@@ -329,7 +329,6 @@ xtensa_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_thread_area */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* get_min_fast_tracepoint_insn_len */
This page took 0.038136 seconds and 4 git commands to generate.