gdbserver: turn target ops 'thread_name' and 'thread_handle' into methods
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 17 Feb 2020 15:12:02 +0000 (16:12 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 20 Feb 2020 16:35:18 +0000 (17:35 +0100)
gdbserver/ChangeLog:
2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

Turn process_stratum_target's thread_name and thread_handle ops
into methods of process_target.

* target.h (struct process_stratum_target): Remove the target ops.
(class process_target): Add the target ops.
(target_thread_name): Update the macro.
(target_thread_handle): Update the macro.
* target.cc (process_target::thread_name): Define.
(process_target::thread_handle): Define.

Update the derived classes and callers below.

* linux-low.cc (linux_target_ops): Update.
(linux_process_target::thread_name): Define.
(linux_process_target::thread_handle): Define.
* linux-low.h (class linux_process_target): Update.
* lynx-low.cc (lynx_target_ops): Update.
* nto-low.cc (nto_target_ops): Update.
* win32-low.cc (win32_target_ops): Update.

gdbserver/ChangeLog
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/lynx-low.cc
gdbserver/nto-low.cc
gdbserver/target.cc
gdbserver/target.h
gdbserver/win32-low.cc

index 694792265db7bb8439c60bf1d1c3b035d68e63c0..592697aaa48eb57e7d9edc8502f13c81bcef5e4a 100644 (file)
@@ -1,3 +1,25 @@
+2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       Turn process_stratum_target's thread_name and thread_handle ops
+       into methods of process_target.
+
+       * target.h (struct process_stratum_target): Remove the target ops.
+       (class process_target): Add the target ops.
+       (target_thread_name): Update the macro.
+       (target_thread_handle): Update the macro.
+       * target.cc (process_target::thread_name): Define.
+       (process_target::thread_handle): Define.
+
+       Update the derived classes and callers below.
+
+       * linux-low.cc (linux_target_ops): Update.
+       (linux_process_target::thread_name): Define.
+       (linux_process_target::thread_handle): Define.
+       * linux-low.h (class linux_process_target): Update.
+       * lynx-low.cc (lynx_target_ops): Update.
+       * nto-low.cc (nto_target_ops): Update.
+       * win32-low.cc (win32_target_ops): Update.
+
 2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        Turn process_stratum_target's breakpoint_kind_from_pc,
index 20a936bb8700d12953af4c2bfa84a3d83b6cc6f2..f9108664f4636cfeaf9acc668f629e77acbea118 100644 (file)
@@ -7397,6 +7397,21 @@ linux_process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
     return breakpoint_kind_from_pc (pcptr);
 }
 
+const char *
+linux_process_target::thread_name (ptid_t thread)
+{
+  return linux_proc_tid_get_name (thread);
+}
+
+#if USE_THREAD_DB
+bool
+linux_process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
+                                    int *handle_len)
+{
+  return thread_db_thread_handle (ptid, handle, handle_len);
+}
+#endif
+
 /* Default implementation of linux_target_ops method "set_pc" for
    32-bit pc register which is literally named "pc".  */
 
@@ -7509,15 +7524,9 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_proc_tid_get_name,
   linux_supports_software_single_step,
   linux_supports_catch_syscall,
   linux_get_ipa_tdesc_idx,
-#if USE_THREAD_DB
-  thread_db_thread_handle,
-#else
-  NULL,
-#endif
   &the_linux_target,
 };
 
index ae422b8387969ad07b3acb3fdad035999be83650..2acd65f28286d93fbc906d86d72883d834414fc4 100644 (file)
@@ -468,6 +468,13 @@ public:
   const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
 
   int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
+
+  const char *thread_name (ptid_t thread) override;
+
+#if USE_THREAD_DB
+  bool thread_handle (ptid_t ptid, gdb_byte **handle,
+                     int *handle_len) override;
+#endif
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
index b07412f0dcd645aa0a2581c283f3008786fa71c5..0c460be5f3186c35f3c65c13a1fddb43cfb9be10 100644 (file)
@@ -741,11 +741,9 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* thread_name */
   NULL,  /* supports_software_single_step */
   NULL,  /* supports_catch_syscall */
   NULL,  /* get_ipa_tdesc_idx */
-  NULL,  /* thread_handle */
   &the_lynx_target,
 };
 
index b0ac86f8790b47e701b0520feccb2beb43035c1d..4c3c5a3a42d9aaa3953df885f9ddc77b32976625 100644 (file)
@@ -947,11 +947,9 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* thread_name */
   NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
-  NULL, /* thread_handle */
   &the_nto_target,
 };
 
index 76eef626ce88a42d7c94695156e2448b309dcf53..b7ed26b22f449fbd15862169baa4ea3918988d78 100644 (file)
@@ -801,3 +801,16 @@ process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
 {
   return breakpoint_kind_from_pc (pcptr);
 }
+
+const char *
+process_target::thread_name (ptid_t thread)
+{
+  return nullptr;
+}
+
+bool
+process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
+                              int *handle_len)
+{
+  return false;
+}
index 4651e449a805d65238b6581845097962f932288f..4d9de5513aa50d74b4b07ffa28cc9a1813b5bf1d 100644 (file)
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return the thread's name, or NULL if the target is unable to determine it.
-     The returned value must not be freed by the caller.  */
-  const char *(*thread_name) (ptid_t thread);
-
   /* Returns true if the target can software single step.  */
   int (*supports_software_single_step) (void);
 
@@ -84,11 +80,6 @@ struct process_stratum_target
   /* Return tdesc index for IPA.  */
   int (*get_ipa_tdesc_idx) (void);
 
-  /* Thread ID to (numeric) thread handle: Return true on success and
-     false for failure.  Return pointer to thread handle via HANDLE
-     and the handle's length via HANDLE_LEN.  */
-  bool (*thread_handle) (ptid_t ptid, gdb_byte **handle, int *handle_len);
-
   /* The object that will gradually replace this struct.  */
   process_target *pt;
 };
@@ -503,6 +494,17 @@ public:
      PC.  The PCPTR is adjusted to the real memory location in case a
      flag (e.g., the Thumb bit on ARM) is present in the  PC.  */
   virtual int breakpoint_kind_from_current_state (CORE_ADDR *pcptr);
+
+  /* Return the thread's name, or NULL if the target is unable to
+     determine it.  The returned value must not be freed by the
+     caller.  */
+  virtual const char *thread_name (ptid_t thread);
+
+  /* Thread ID to (numeric) thread handle: Return true on success and
+     false for failure.  Return pointer to thread handle via HANDLE
+     and the handle's length via HANDLE_LEN.  */
+  virtual bool thread_handle (ptid_t ptid, gdb_byte **handle,
+                             int *handle_len);
 };
 
 extern process_stratum_target *the_target;
@@ -683,13 +685,10 @@ void done_accessing_memory (void);
   the_target->pt->core_of_thread (ptid)
 
 #define target_thread_name(ptid)                                \
-  (the_target->thread_name ? (*the_target->thread_name) (ptid)  \
-   : NULL)
+  the_target->pt->thread_name (ptid)
 
 #define target_thread_handle(ptid, handle, handle_len) \
-   (the_target->thread_handle ? (*the_target->thread_handle) \
-                                  (ptid, handle, handle_len) \
-   : false)
+  the_target->pt->thread_handle (ptid, handle, handle_len)
 
 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
 
index 71adf18ebb5edbb3c978a9df7ea7516552ad0f20..218f007bdec0a4da7df61270115b6876d500a20c 100644 (file)
@@ -1858,11 +1858,9 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* thread_name */
   NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
-  NULL, /* thread_handle */
   &the_win32_target,
 };
 
This page took 0.03619 seconds and 4 git commands to generate.