This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Use reinsert_breakpoint for vCont;s


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

commit 8901d1936e4e691f0b3b976f5626ac5a8f27aa7f
Author: Yao Qi <yao.qi@linaro.org>
Date:   Thu Jul 21 12:12:18 2016 +0100

    Use reinsert_breakpoint for vCont;s
    
    This patch is to teach GDBserver using software single step to handle
    vCont;s.  Simply speaking, if the thread's resume request is resume_step,
    install reinsert breakpoint at the next pcs when GDBserver is about to
    resume threads.  These reinsert breakpoints of a thread are removed,
    when GDBserver gets an event from that thread and reports it back to
    GDB.
    
    gdb/gdbserver:
    
    2016-07-21  Yao Qi  <yao.qi@linaro.org>
    
    	* linux-low.c (resume_stopped_resumed_lwps): If resume request
    	is resume_step, call maybe_hw_step.
    	(linux_wait_1): Stop all threads, remove reinsert breakpoints,
    	and unstop them.
    	(linux_resume_one_lwp_throw): Don't assert the thread has reinsert
    	breakpoints or not.
    	(proceed_one_lwp): If resume request is resume_step, install
    	reinsert breakpoints and call maybe_hw_step.

Diff:
---
 gdb/gdbserver/ChangeLog   | 11 +++++++
 gdb/gdbserver/linux-low.c | 80 ++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 83 insertions(+), 8 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index e5aed82..e55bae0 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,16 @@
 2016-07-21  Yao Qi  <yao.qi@linaro.org>
 
+	* linux-low.c (resume_stopped_resumed_lwps): If resume request
+	is resume_step, call maybe_hw_step.
+	(linux_wait_1): Stop all threads, remove reinsert breakpoints,
+	and unstop them.
+	(linux_resume_one_lwp_throw): Don't assert the thread has reinsert
+	breakpoints or not.
+	(proceed_one_lwp): If resume request is resume_step, install
+	reinsert breakpoints and call maybe_hw_step.
+
+2016-07-21  Yao Qi  <yao.qi@linaro.org>
+
 	* linux-low.c (proceed_one_lwp): Declare.
 	(linux_resume_one_thread): Remove local variable 'step'.
 	Lift code enqueue signal.  Call proceed_one_lwp instead of
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index d9f847d..e251ac4 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -2641,7 +2641,10 @@ resume_stopped_resumed_lwps (struct inferior_list_entry *entry)
       && !lp->status_pending_p
       && thread->last_status.kind == TARGET_WAITKIND_IGNORE)
     {
-      int step = thread->last_resume_kind == resume_step;
+      int step = 0;
+
+      if (thread->last_resume_kind == resume_step)
+	step = maybe_hw_step (thread);
 
       if (debug_threads)
 	debug_printf ("RSRL: resuming stopped-resumed LWP %s at %s: step=%d\n",
@@ -3700,6 +3703,66 @@ linux_wait_1 (ptid_t ptid,
 
   /* Alright, we're going to report a stop.  */
 
+  /* Remove reinsert breakpoints.  */
+  if (can_software_single_step ())
+    {
+      /* Remove reinsert breakpoints or not.  It it is true, stop all
+	 lwps, so that other threads won't hit the breakpoint in the
+	 staled memory.  */
+      int remove_reinsert_breakpoints_p = 0;
+
+      if (non_stop)
+	{
+	  remove_reinsert_breakpoints_p
+	    = has_reinsert_breakpoints (current_thread);
+	}
+      else
+	{
+	  /* In all-stop, a stop reply cancels all previous resume
+	     requests.  Delete all reinsert breakpoints.  */
+	  struct inferior_list_entry *inf, *tmp;
+
+	  ALL_INFERIORS (&all_threads, inf, tmp)
+	    {
+	      struct thread_info *thread = (struct thread_info *) inf;
+
+	      if (has_reinsert_breakpoints (thread))
+		{
+		  remove_reinsert_breakpoints_p = 1;
+		  break;
+		}
+	    }
+	}
+
+      if (remove_reinsert_breakpoints_p)
+	{
+	  /* If we remove reinsert breakpoints from memory, stop all lwps,
+	     so that other threads won't hit the breakpoint in the staled
+	     memory.  */
+	  stop_all_lwps (0, event_child);
+
+	  if (non_stop)
+	    {
+	      gdb_assert (has_reinsert_breakpoints (current_thread));
+	      delete_reinsert_breakpoints (current_thread);
+	    }
+	  else
+	    {
+	      struct inferior_list_entry *inf, *tmp;
+
+	      ALL_INFERIORS (&all_threads, inf, tmp)
+		{
+		  struct thread_info *thread = (struct thread_info *) inf;
+
+		  if (has_reinsert_breakpoints (thread))
+		    delete_reinsert_breakpoints (thread);
+		}
+	    }
+
+	  unstop_all_lwps (0, event_child);
+	}
+    }
+
   if (!stabilizing_threads)
     {
       /* In all-stop, stop all threads.  */
@@ -4353,12 +4416,6 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp,
 
       step = maybe_hw_step (thread);
     }
-  else
-    {
-      /* If the thread isn't doing step-over, there shouldn't be any
-	 reinsert breakpoints.  */
-      gdb_assert (!has_reinsert_breakpoints (thread));
-    }
 
   if (fast_tp_collecting == 1)
     {
@@ -5166,7 +5223,14 @@ proceed_one_lwp (struct inferior_list_entry *entry, void *except)
       if (debug_threads)
 	debug_printf ("   stepping LWP %ld, client wants it stepping\n",
 		      lwpid_of (thread));
-      step = 1;
+
+      /* If resume_step is requested by GDB, install reinsert
+	 breakpoints when the thread is about to be actually resumed if
+	 the reinsert breakpoints weren't removed.  */
+      if (can_software_single_step () && !has_reinsert_breakpoints (thread))
+	install_software_single_step_breakpoints (lwp);
+
+      step = maybe_hw_step (thread);
     }
   else if (lwp->bp_reinsert != 0)
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]