public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods
@ 2020-02-20 16:41 Tankut Baris Aktemur
  0 siblings, 0 replies; only message in thread
From: Tankut Baris Aktemur @ 2020-02-20 16:41 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=29e8dc09ff78e102ede0cdbb802cb771613bb8b1

commit 29e8dc09ff78e102ede0cdbb802cb771613bb8b1
Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Date:   Mon Feb 17 16:12:00 2020 +0100

    gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods
    
    gdbserver/ChangeLog:
    2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
    
    	Turn process_stratum_target's pause_all and unpause_all ops
    	into methods of process_target.
    
    	* target.h (struct process_stratum_target): Remove the target ops.
    	(class process_target): Add the target ops.
    	(pause_all): Update the macro and rename to...
    	(target_pause_all): ... this.
    	(unpause_all): Update the macro and rename to...
    	(target_unpause_all): ... this.
    	* target.cc (process_target::pause_all): Define.
    	(process_target::unpause_all): Define.
    
    	Update the derived classes and callers below.
    
    	* server.cc (handle_status): Update.
    	* tracepoint.cc (clear_installed_tracepoints): Update.
    	(cmd_qtdp): Update.
    	(cmd_qtstart): Update.
    	(stop_tracing): Update.
    	(cmd_qtstatus): Update.
    	(upload_fast_traceframes): Update.
    	(run_inferior_command): Update.
    	* linux-low.cc (linux_target_ops): Update.
    	(linux_pause_all): Turn into ...
    	(linux_process_target::pause_all): ... this.
    	(linux_unpause_all): Turn into ...
    	(linux_process_target::unpause_all): ... this.
    	(linux_process_target::prepare_to_access_memory): Update.
    	(linux_process_target::done_accessing_memory): Update.
    	* 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.

Diff:
---
 gdbserver/ChangeLog     | 36 ++++++++++++++++++++++++++++++++++++
 gdbserver/linux-low.cc  | 14 ++++++--------
 gdbserver/linux-low.h   |  4 ++++
 gdbserver/lynx-low.cc   |  2 --
 gdbserver/nto-low.cc    |  2 --
 gdbserver/server.cc     |  2 +-
 gdbserver/target.cc     | 12 ++++++++++++
 gdbserver/target.h      | 40 ++++++++++++++++------------------------
 gdbserver/tracepoint.cc | 34 +++++++++++++++++-----------------
 gdbserver/win32-low.cc  |  2 --
 10 files changed, 92 insertions(+), 56 deletions(-)

diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index acbc7ad..162077b 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,5 +1,41 @@
 2020-02-20  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
+	Turn process_stratum_target's pause_all and unpause_all ops
+	into methods of process_target.
+
+	* target.h (struct process_stratum_target): Remove the target ops.
+	(class process_target): Add the target ops.
+	(pause_all): Update the macro and rename to...
+	(target_pause_all): ... this.
+	(unpause_all): Update the macro and rename to...
+	(target_unpause_all): ... this.
+	* target.cc (process_target::pause_all): Define.
+	(process_target::unpause_all): Define.
+
+	Update the derived classes and callers below.
+
+	* server.cc (handle_status): Update.
+	* tracepoint.cc (clear_installed_tracepoints): Update.
+	(cmd_qtdp): Update.
+	(cmd_qtstart): Update.
+	(stop_tracing): Update.
+	(cmd_qtstatus): Update.
+	(upload_fast_traceframes): Update.
+	(run_inferior_command): Update.
+	* linux-low.cc (linux_target_ops): Update.
+	(linux_pause_all): Turn into ...
+	(linux_process_target::pause_all): ... this.
+	(linux_unpause_all): Turn into ...
+	(linux_process_target::unpause_all): ... this.
+	(linux_process_target::prepare_to_access_memory): Update.
+	(linux_process_target::done_accessing_memory): Update.
+	* 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 get_tib_address op into a method of
 	process_target.
 
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index c7ebffd..1a1af79 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6586,8 +6586,8 @@ linux_process_target::thread_stopped (thread_info *thread)
 
 /* This exposes stop-all-threads functionality to other modules.  */
 
-static void
-linux_pause_all (int freeze)
+void
+linux_process_target::pause_all (bool freeze)
 {
   stop_all_lwps (freeze, NULL);
 }
@@ -6595,8 +6595,8 @@ linux_pause_all (int freeze)
 /* This exposes unstop-all-threads functionality to other gdbserver
    modules.  */
 
-static void
-linux_unpause_all (int unfreeze)
+void
+linux_process_target::unpause_all (bool unfreeze)
 {
   unstop_all_lwps (unfreeze, NULL);
 }
@@ -6607,7 +6607,7 @@ linux_process_target::prepare_to_access_memory ()
   /* Neither ptrace nor /proc/PID/mem allow accessing memory through a
      running LWP.  */
   if (non_stop)
-    linux_pause_all (1);
+    target_pause_all (true);
   return 0;
 }
 
@@ -6617,7 +6617,7 @@ linux_process_target::done_accessing_memory ()
   /* Neither ptrace nor /proc/PID/mem allow accessing memory through a
      running LWP.  */
   if (non_stop)
-    linux_unpause_all (1);
+    target_unpause_all (true);
 }
 
 static int
@@ -7455,8 +7455,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_pause_all,
-  linux_unpause_all,
   linux_stabilize_threads,
   linux_install_fast_tracepoint_jump_pad,
   linux_emit_ops,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index cbb2f48..e5d54c5 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -396,6 +396,10 @@ public:
   bool supports_thread_stopped () override;
 
   bool thread_stopped (thread_info *thread) override;
+
+  void pause_all (bool freeze) override;
+
+  void unpause_all (bool unfreeze) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 9f96faf..92c086d 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,8 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* pause_all */
-  NULL,  /* unpause_all */
   NULL,  /* stabilize_threads */
   NULL,  /* install_fast_tracepoint_jump_pad */
   NULL,  /* emit_ops */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 08f73fa..ee411a1 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,8 +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, /* pause_all */
-  NULL, /* unpause_all */
   NULL, /* stabilize_threads */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 7715593..670c0fe 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3323,7 +3323,7 @@ handle_status (char *own_buf)
     {
       thread_info *thread = NULL;
 
-      pause_all (0);
+      target_pause_all (false);
       stabilize_threads ();
       gdb_wants_all_threads_stopped ();
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 680adda..912f4b8 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -650,3 +650,15 @@ process_target::get_tib_address (ptid_t ptid, CORE_ADDR *address)
 {
   gdb_assert_not_reached ("target op get_tib_address not supported");
 }
+
+void
+process_target::pause_all (bool freeze)
+{
+  /* Nop.  */
+}
+
+void
+process_target::unpause_all (bool unfreeze)
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 4da15a0..60fb14f 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,18 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Pause all threads.  If FREEZE, arrange for any resume attempt to
-     be ignored until an unpause_all call unfreezes threads again.
-     There can be nested calls to pause_all, so a freeze counter
-     should be maintained.  */
-  void (*pause_all) (int freeze);
-
-  /* Unpause all threads.  Threads that hadn't been resumed by the
-     client should be left stopped.  Basically a pause/unpause call
-     pair should not end up resuming threads that were stopped before
-     the pause call.  */
-  void (*unpause_all) (int unfreeze);
-
   /* Stabilize all threads.  That is, force them out of jump pads.  */
   void (*stabilize_threads) (void);
 
@@ -494,6 +482,18 @@ public:
 
   /* Read Thread Information Block address.  */
   virtual int get_tib_address (ptid_t ptid, CORE_ADDR *address);
+
+  /* Pause all threads.  If FREEZE, arrange for any resume attempt to
+     be ignored until an unpause_all call unfreezes threads again.
+     There can be nested calls to pause_all, so a freeze counter
+     should be maintained.  */
+  virtual void pause_all (bool freeze);
+
+  /* Unpause all threads.  Threads that hadn't been resumed by the
+     client should be left stopped.  Basically a pause/unpause call
+     pair should not end up resuming threads that were stopped before
+     the pause call.  */
+  virtual void unpause_all (bool unfreeze);
 };
 
 extern process_stratum_target *the_target;
@@ -568,19 +568,11 @@ int kill_inferior (process_info *proc);
 #define target_thread_stopped(thread) \
   the_target->pt->thread_stopped (thread)
 
-#define pause_all(freeze)			\
-  do						\
-    {						\
-      if (the_target->pause_all)		\
-	(*the_target->pause_all) (freeze);	\
-    } while (0)
+#define target_pause_all(freeze)		\
+  the_target->pt->pause_all (freeze)
 
-#define unpause_all(unfreeze)			\
-  do						\
-    {						\
-      if (the_target->unpause_all)		\
-	(*the_target->unpause_all) (unfreeze);	\
-    } while (0)
+#define target_unpause_all(unfreeze)		\
+  the_target->pt->unpause_all (unfreeze)
 
 #define stabilize_threads()			\
   do						\
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index bbca48b..ffa819c 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2433,7 +2433,7 @@ clear_installed_tracepoints (void)
   struct tracepoint *tpoint;
   struct tracepoint *prev_stpoint;
 
-  pause_all (1);
+  target_pause_all (true);
 
   prev_stpoint = NULL;
 
@@ -2486,7 +2486,7 @@ clear_installed_tracepoints (void)
       tpoint->handle = NULL;
     }
 
-  unpause_all (1);
+  target_unpause_all (true);
 }
 
 /* Parse a packet that defines a tracepoint.  */
@@ -2602,14 +2602,14 @@ cmd_qtdp (char *own_buf)
       struct tracepoint *tp = NULL;
 
       /* Pause all threads temporarily while we patch tracepoints.  */
-      pause_all (0);
+      target_pause_all (false);
 
       /* download_tracepoint will update global `tracepoints'
 	 list, so it is unsafe to leave threads in jump pad.  */
       stabilize_threads ();
 
       /* Freeze threads.  */
-      pause_all (1);
+      target_pause_all (true);
 
 
       if (tpoint->type != trap_tracepoint)
@@ -2658,7 +2658,7 @@ cmd_qtdp (char *own_buf)
 	    write_ok (own_buf);
 	}
 
-      unpause_all (1);
+      target_unpause_all (true);
       return;
     }
 
@@ -3220,7 +3220,7 @@ cmd_qtstart (char *packet)
   trace_debug ("Starting the trace");
 
   /* Pause all threads temporarily while we patch tracepoints.  */
-  pause_all (0);
+  target_pause_all (false);
 
   /* Get threads out of jump pads.  Safe to do here, since this is a
      top level command.  And, required to do here, since we're
@@ -3229,7 +3229,7 @@ cmd_qtstart (char *packet)
   stabilize_threads ();
 
   /* Freeze threads.  */
-  pause_all (1);
+  target_pause_all (true);
 
   /* Sync the fast tracepoints list in the inferior ftlib.  */
   if (agent_loaded_p ())
@@ -3370,7 +3370,7 @@ cmd_qtstart (char *packet)
       clear_installed_tracepoints ();
       if (*packet == '\0')
 	write_enn (packet);
-      unpause_all (1);
+      target_unpause_all (true);
       return;
     }
 
@@ -3418,7 +3418,7 @@ cmd_qtstart (char *packet)
 	error ("Error setting flush_trace_buffer breakpoint");
     }
 
-  unpause_all (1);
+  target_unpause_all (true);
 
   write_ok (packet);
 }
@@ -3445,7 +3445,7 @@ stop_tracing (void)
      when we're sure we can move all threads out of the jump pads).
      We can't now, since we may be getting here due to the inferior
      agent calling us.  */
-  pause_all (1);
+  target_pause_all (true);
 
   /* Stop logging. Tracepoints can still be hit, but they will not be
      recorded.  */
@@ -3522,7 +3522,7 @@ stop_tracing (void)
       flush_trace_buffer_bkpt = NULL;
     }
 
-  unpause_all (1);
+  target_unpause_all (true);
 }
 
 static int
@@ -3668,11 +3668,11 @@ cmd_qtstatus (char *packet)
 
   if (agent_loaded_p ())
     {
-      pause_all (1);
+      target_pause_all (true);
 
       upload_fast_traceframes ();
 
-      unpause_all (1);
+      target_unpause_all (true);
    }
 
   stop_reason_rsp = (char *) tracing_stop_reason;
@@ -6578,12 +6578,12 @@ upload_fast_traceframes (void)
 
   trace_debug ("Done uploading traceframes [%d]\n", curr_tbctrl_idx);
 
-  pause_all (1);
+  target_pause_all (true);
 
   delete_breakpoint (about_to_request_buffer_space_bkpt);
   about_to_request_buffer_space_bkpt = NULL;
 
-  unpause_all (1);
+  target_unpause_all (true);
 
   if (trace_buffer_is_full)
     stop_tracing ();
@@ -6861,13 +6861,13 @@ run_inferior_command (char *cmd, int len)
 
   trace_debug ("run_inferior_command: running: %s", cmd);
 
-  pause_all (0);
+  target_pause_all (false);
   uninsert_all_breakpoints ();
 
   err = agent_run_command (pid, (const char *) cmd, len);
 
   reinsert_all_breakpoints ();
-  unpause_all (0);
+  target_unpause_all (false);
 
   return err;
 }
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9bffdaa..a06cea2 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,8 +1858,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, /* pause_all */
-  NULL, /* unpause_all */
   NULL, /* stabilize_threads */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-20 16:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 16:41 [binutils-gdb] gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods Tankut Baris Aktemur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).