gdbserver: turn target op 'thread_stopped' into a method
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 17 Feb 2020 15:11:59 +0000 (16:11 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 20 Feb 2020 16:35:14 +0000 (17:35 +0100)
gdbserver/ChangeLog:
2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

Turn process_stratum_target's thread_stopped op into a method of
process_target.

* target.h (struct process_stratum_target): Remove the target op.
(class process_target): Add the target op.  Also add
'supports_thread_stopped'.
(target_thread_stopped): Update the macro.
* target.cc (process_target::thread_stopped): Define.
(process_target::supports_thread_stopped): Define.
(prepare_to_access_memory): Update.

Update the derived classes and callers below.

* server.cc (queue_stop_reply_callback): Update.
* linux-low.cc (linux_target_ops): Update.
(linux_process_target::supports_thread_stopped): Define.
(linux_thread_stopped): Turn into ...
(linux_process_target::thread_stopped): ... this.
* 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/server.cc
gdbserver/target.cc
gdbserver/target.h
gdbserver/win32-low.cc

index 871657780ba9b2a1f7e7f994df845fbd243978dc..60244e3153f014eda1b514d4139c9390c4e09321 100644 (file)
@@ -1,3 +1,28 @@
+2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       Turn process_stratum_target's thread_stopped op into a method of
+       process_target.
+
+       * target.h (struct process_stratum_target): Remove the target op.
+       (class process_target): Add the target op.  Also add
+       'supports_thread_stopped'.
+       (target_thread_stopped): Update the macro.
+       * target.cc (process_target::thread_stopped): Define.
+       (process_target::supports_thread_stopped): Define.
+       (prepare_to_access_memory): Update.
+
+       Update the derived classes and callers below.
+
+       * server.cc (queue_stop_reply_callback): Update.
+       * linux-low.cc (linux_target_ops): Update.
+       (linux_process_target::supports_thread_stopped): Define.
+       (linux_thread_stopped): Turn into ...
+       (linux_process_target::thread_stopped): ... this.
+       * 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 read_pc and write_pc ops into
index 90b5fcbcdcc18fbb47035c8aa8949ca2df42f09b..8d5881f49ffa347e1d57a4b812d23ab366cca608 100644 (file)
@@ -6572,8 +6572,14 @@ linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc)
   (*the_low_target.set_pc) (regcache, pc);
 }
 
-static int
-linux_thread_stopped (struct thread_info *thread)
+bool
+linux_process_target::supports_thread_stopped ()
+{
+  return true;
+}
+
+bool
+linux_process_target::thread_stopped (thread_info *thread)
 {
   return get_thread_lwp (thread)->stopped;
 }
@@ -7449,7 +7455,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_thread_stopped,
   NULL,
   linux_pause_all,
   linux_unpause_all,
index 67a36c8a67d2bdf540f365898a9d49ffd38daf04..cbb2f48e135befcf1a21db0411961d8ec55224a9 100644 (file)
@@ -392,6 +392,10 @@ public:
   CORE_ADDR read_pc (regcache *regcache) override;
 
   void write_pc (regcache *regcache, CORE_ADDR pc) override;
+
+  bool supports_thread_stopped () override;
+
+  bool thread_stopped (thread_info *thread) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
index 2ac59c3c14a6f0912749645e8e8e53b67dd7a48a..7cbde7c6e79308344bfbe27869613db027b25773 100644 (file)
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* thread_stopped */
   NULL,  /* get_tib_address */
   NULL,  /* pause_all */
   NULL,  /* unpause_all */
index 2b5b02b69bda7d1d5ec26cc3d15c72286957df9b..c144d774f0cdd018694b9e8c09c6b3b6b3fda42d 100644 (file)
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* thread_stopped */
   NULL, /* get_tib_address */
   NULL, /* pause_all */
   NULL, /* unpause_all */
index df307f5594c2ea5b521a987ec19be4cefefcbb56..f3dca8d3ce0e7c9218711abdb13bf7210085e71a 100644 (file)
@@ -3217,7 +3217,7 @@ queue_stop_reply_callback (thread_info *thread)
 {
   /* For now, assume targets that don't have this callback also don't
      manage the thread's last_status field.  */
-  if (the_target->thread_stopped == NULL)
+  if (!the_target->pt->supports_thread_stopped ())
     {
       struct vstop_notif *new_notif = new struct vstop_notif;
 
@@ -3229,7 +3229,7 @@ queue_stop_reply_callback (thread_info *thread)
     }
   else
     {
-      if (thread_stopped (thread))
+      if (target_thread_stopped (thread))
        {
          if (debug_threads)
            {
index 4f8d91c171f30bf1d8f7096be06eebd2bbd6b0b8..b44170a7cddc86f43cc99d8fb6c0d4cb2bb534de 100644 (file)
@@ -66,8 +66,8 @@ prepare_to_access_memory (void)
     {
       if (mythread_alive (thread->id))
        {
-         if (stopped == NULL && the_target->thread_stopped != NULL
-             && thread_stopped (thread))
+         if (stopped == NULL && the_target->pt->supports_thread_stopped ()
+             && target_thread_stopped (thread))
            stopped = thread;
 
          if (first == NULL)
@@ -626,3 +626,15 @@ process_target::write_pc (regcache *regcache, CORE_ADDR pc)
 {
   gdb_assert_not_reached ("process_target::write_pc: Unable to update PC");
 }
+
+bool
+process_target::supports_thread_stopped ()
+{
+  return false;
+}
+
+bool
+process_target::thread_stopped (thread_info *thread)
+{
+  gdb_assert_not_reached ("target op thread_stopped not supported");
+}
index 2aef0208c11af0237acf8c4f6f4757c023e01846..49d5eca479ed3e039cb4260aba52b2c658cbf982 100644 (file)
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return true if THREAD is known to be stopped now.  */
-  int (*thread_stopped) (struct thread_info *thread);
-
   /* Read Thread Information Block address.  */
   int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);
 
@@ -488,6 +485,12 @@ public:
 
   /* Write PC to REGCACHE.  */
   virtual void write_pc (regcache *regcache, CORE_ADDR pc);
+
+  /* Return true if the thread_stopped op is supported.  */
+  virtual bool supports_thread_stopped ();
+
+  /* Return true if THREAD is known to be stopped now.  */
+  virtual bool thread_stopped (thread_info *thread);
 };
 
 extern process_stratum_target *the_target;
@@ -559,8 +562,8 @@ int kill_inferior (process_info *proc);
   (the_target->get_min_fast_tracepoint_insn_len                \
    ? (*the_target->get_min_fast_tracepoint_insn_len) () : 0)
 
-#define thread_stopped(thread) \
-  (*the_target->thread_stopped) (thread)
+#define target_thread_stopped(thread) \
+  the_target->pt->thread_stopped (thread)
 
 #define pause_all(freeze)                      \
   do                                           \
index a7329fe20cfafc6fcdc48399893349230c9fbbc9..712624852d6ace24e8e4f3b44349cefb9adfa023 100644 (file)
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* thread_stopped */
   win32_get_tib_address,
   NULL, /* pause_all */
   NULL, /* unpause_all */
This page took 0.037553 seconds and 4 git commands to generate.