[GDBserver] step over shouldn't be ongoing in proceed_one_lwp

Message ID 1461917301-1959-1-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi April 29, 2016, 8:08 a.m. UTC
  Hi,
proceed_one_lwp is called by either unstop_all_lwps or proceed_all_lwps,
and the step over shouldn't be ongoing, either not started or finished,
so the "else if (lwp->bp_reinsert != 0)" looks like a dead code.  This
patch is to remove it, add an assert that "lwp->bp_reinsert == 0", and
remove some comments in proceed_one_lwp.

Regression tested on x86_64-linux and arm-linux.

gdb/gdbserver:

2016-04-29  Yao Qi  <yao.qi@linaro.org>

	* linux-low.c (proceed_one_lwp): Remove comments.  Assert on
	"lwp->bp_reinsert == 0".  Remove code if (lwp->bp_reinsert != 0).
---
 gdb/gdbserver/linux-low.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
  

Comments

Yao Qi May 17, 2016, 9:15 a.m. UTC | #1
Yao Qi <qiyaoltc@gmail.com> writes:

> proceed_one_lwp is called by either unstop_all_lwps or proceed_all_lwps,
> and the step over shouldn't be ongoing, either not started or finished,
> so the "else if (lwp->bp_reinsert != 0)" looks like a dead code.  This
> patch is to remove it, add an assert that "lwp->bp_reinsert == 0", and
> remove some comments in proceed_one_lwp.

The assert added by this patch can be triggered if GDBserver pauses all
lwps (due to requested memory access) when one thread is stepping over a
breakpoint, for example, we have a target-side conditional breakpoint,
continue inferior in background, and request memory access from GDB
(disassemble main).
  

Patch

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 8e1e2fc..2737d27 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4943,11 +4943,7 @@  linux_resume (struct thread_resume *resume_info, size_t n)
 /* This function is called once per thread.  We check the thread's
    last resume request, which will tell us whether to resume, step, or
    leave the thread stopped.  Any signal the client requested to be
-   delivered has already been enqueued at this point.
-
-   If any thread that GDB wants running is stopped at an internal
-   breakpoint that needs stepping over, we start a step-over operation
-   on that particular thread, and leave all others stopped.  */
+   delivered has already been enqueued at this point.  */
 
 static int
 proceed_one_lwp (struct inferior_list_entry *entry, void *except)
@@ -5017,6 +5013,9 @@  proceed_one_lwp (struct inferior_list_entry *entry, void *except)
       send_sigstop (lwp);
     }
 
+  /* All step-overs shouldn't be ongoing when proceeding lwps.  */
+  gdb_assert (lwp->bp_reinsert == 0);
+
   if (thread->last_resume_kind == resume_step)
     {
       if (debug_threads)
@@ -5024,13 +5023,6 @@  proceed_one_lwp (struct inferior_list_entry *entry, void *except)
 		      lwpid_of (thread));
       step = 1;
     }
-  else if (lwp->bp_reinsert != 0)
-    {
-      if (debug_threads)
-	debug_printf ("   stepping LWP %ld, reinsert set\n",
-		      lwpid_of (thread));
-      step = 1;
-    }
   else
     step = 0;