public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix lwp_suspend/unsuspend imbalance in linux_wait_1
@ 2016-08-31 17:14 Antoine Tremblay
  2016-08-31 17:14 ` [PATCH 2/2] Enable range stepping for ARM on GDBServer Antoine Tremblay
  2016-08-31 17:40 ` [PATCH 1/2] Fix lwp_suspend/unsuspend imbalance in linux_wait_1 Pedro Alves
  0 siblings, 2 replies; 21+ messages in thread
From: Antoine Tremblay @ 2016-08-31 17:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

This patch fixes imbalanced lwp_suspend/unsuspend calls caused by the
premature choosing of another event for fairness.

select_event_lwp would switch the event before a call to
unsuspend_all_lwps, thus it would be called with the wrong event.

This caused an assertion failure: unsuspend LWP xx, suspended=-1 when
testing  gdb.threads/non-stop-fair-events.exp with ARM range stepping in
GDBServer.

This patch moves the switch of event after the unsuspend/unstop calls.

No regressions, tested on ubuntu 14.04 ARMv7 and x86.
With gdbserver-native.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_wait_1): Move event switch after unsuspend_lwps.
---
 gdb/gdbserver/linux-low.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 45061ac..cdff436 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -3771,24 +3771,6 @@ linux_wait_1 (ptid_t ptid,
       if (!non_stop)
 	stop_all_lwps (0, NULL);
 
-      /* If we're not waiting for a specific LWP, choose an event LWP
-	 from among those that have had events.  Giving equal priority
-	 to all LWPs that have had events helps prevent
-	 starvation.  */
-      if (ptid_equal (ptid, minus_one_ptid))
-	{
-	  event_child->status_pending_p = 1;
-	  event_child->status_pending = w;
-
-	  select_event_lwp (&event_child);
-
-	  /* current_thread and event_child must stay in sync.  */
-	  current_thread = get_lwp_thread (event_child);
-
-	  event_child->status_pending_p = 0;
-	  w = event_child->status_pending;
-	}
-
       if (step_over_finished)
 	{
 	  if (!non_stop)
@@ -3813,6 +3795,25 @@ linux_wait_1 (ptid_t ptid,
 	    }
 	}
 
+      /* If we're not waiting for a specific LWP, choose an event LWP
+	 from among those that have had events.  Giving equal priority
+	 to all LWPs that have had events helps prevent
+	 starvation.  */
+      if (ptid_equal (ptid, minus_one_ptid))
+	{
+	  event_child->status_pending_p = 1;
+	  event_child->status_pending = w;
+
+	  select_event_lwp (&event_child);
+
+	  /* current_thread and event_child must stay in sync.  */
+	  current_thread = get_lwp_thread (event_child);
+
+	  event_child->status_pending_p = 0;
+	  w = event_child->status_pending;
+	}
+
+
       /* Stabilize threads (move out of jump pads).  */
       if (!non_stop)
 	stabilize_threads ();
-- 
2.9.2

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-09-18 19:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-31 17:14 [PATCH 1/2] Fix lwp_suspend/unsuspend imbalance in linux_wait_1 Antoine Tremblay
2016-08-31 17:14 ` [PATCH 2/2] Enable range stepping for ARM on GDBServer Antoine Tremblay
2016-08-31 17:50   ` Pedro Alves
2016-08-31 18:15     ` Antoine Tremblay
2016-08-31 18:39       ` Pedro Alves
2016-08-31 19:14         ` Antoine Tremblay
2016-09-01 13:37           ` Pedro Alves
2016-09-01 15:21             ` Antoine Tremblay
2016-09-01 15:59               ` Pedro Alves
2016-09-01 16:44                 ` Yao Qi
2016-09-01 17:02                   ` Pedro Alves
2016-09-01 17:06                   ` Antoine Tremblay
2016-09-01 16:46                 ` Antoine Tremblay
2016-09-18 19:58         ` Yao Qi
2016-08-31 17:40 ` [PATCH 1/2] Fix lwp_suspend/unsuspend imbalance in linux_wait_1 Pedro Alves
2016-08-31 17:50   ` Antoine Tremblay
2016-08-31 17:52     ` Pedro Alves
2016-08-31 18:25       ` Antoine Tremblay
2016-08-31 19:16         ` Antoine Tremblay
2016-09-01 13:09           ` Pedro Alves
2016-09-01 15:12             ` Antoine Tremblay

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).