This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization)
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 19 Mar 2015 16:14:47 +0000
- Subject: [PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization)
- Authentication-results: sourceware.org; auth=none
- References: <1425671886-7798-1-git-send-email-palves at redhat dot com> <1425671886-7798-5-git-send-email-palves at redhat dot com> <550AC2EB dot 10801 at redhat dot com> <550AC5E7 dot 5030200 at redhat dot com>
On 03/19/2015 12:49 PM, Pedro Alves wrote:
> However, running that against GNU/Linux gdbserver, I found that
> surprisingly, that FAILed. GDBserver always reported the breakpoint
> hit for the same thread.
>
> Turns out that I broke gdbserver's thread event randomization
> recently, with git commit 582511be ([gdbserver] linux-low.c: better
> starvation avoidance, handle non-stop mode too). In that commit I
> missed that the thread structure also has a status_pending_p field...
> The end result was that count_events_callback always returns 0, and
> then if no thread is stepping, select_event_lwp always returns the
> event thread. IOW, no randomization is happening at all. Quite
> curious how all the other changes in that patch were sufficient to fix
> non-stop-fair-events.exp anyway even with that broken.
... and now the buildbots caught another bug in the same functions.
Rerunning the tests locally, I can see it trigger too.
Testing this fix now.
---
>From aef94259924021e912d3c4a35fbdde7c767f0c49 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 19 Mar 2015 15:59:33 +0000
Subject: [PATCH] gdbserver/Linux: Unbreak non-stop
The previous change added an assertion that is catching yet another
bug in count_events_callback/select_event_lwp_callback:
(gdb)
PASS: gdb.mi/mi-nonstop.exp: interrupted
mi_expect_interrupt: expecting: \*stopped,(reason="signal-received",signal-name="0",signal-meaning="Signal 0"|reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt")[^
]*
/home/pedro/gdb/mygit/src/gdb/gdbserver/linux-low.c:2329: A problem internal to GDBserver has been detected.
select_event_lwp: Assertion `num_events > 0' failed.
=thread-group-exited,id="i1"
Certainly select_event_lwp_callback should always at least find one
event, as it's only called because an event triggered (though we may
have more than one: the point of the function is randomly picking
one).
An LWP that GDB previously asked to continue/step (thus is resumed)
resumed and gets a vCont;t request ends up with last_resume_kind ==
resume_stop. These functions in gdbserver used to filter out events
that weren't going to be reported to GDB; I think the last_resume_kind
kind check used to make sense at some point, but it no longer does.
gdb/gdbserver/ChangeLog:
2015-03-19 Pedro Alves <palves@redhat.com>
* linux-low.c (count_events_callback, select_event_lwp_callback):
No longer check whether the thread has resume_stop as last resume
kind.
---
gdb/gdbserver/linux-low.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index e53e0fc..2b988ec 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -2245,7 +2245,6 @@ count_events_callback (struct inferior_list_entry *entry, void *data)
/* Count only resumed LWPs that have an event pending. */
if (thread->last_status.kind == TARGET_WAITKIND_IGNORE
- && thread->last_resume_kind != resume_stop
&& lp->status_pending_p)
(*count)++;
@@ -2280,8 +2279,7 @@ select_event_lwp_callback (struct inferior_list_entry *entry, void *data)
gdb_assert (selector != NULL);
/* Select only resumed LWPs that have an event pending. */
- if (thread->last_resume_kind != resume_stop
- && thread->last_status.kind == TARGET_WAITKIND_IGNORE
+ if (thread->last_status.kind == TARGET_WAITKIND_IGNORE
&& lp->status_pending_p)
if ((*selector)-- == 0)
return 1;
--
1.9.3