From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization)
Date: Thu, 19 Mar 2015 16:14:00 -0000 [thread overview]
Message-ID: <550AF5F7.5080909@redhat.com> (raw)
In-Reply-To: <550AC5E7.5030200@redhat.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
next prev parent reply other threads:[~2015-03-19 16:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 19:58 [PATCH 0/6] Fix problems if inferior disappears while being debugged Pedro Alves
2015-03-06 19:58 ` [PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint Pedro Alves
2015-03-19 12:37 ` [pushed] native/Linux: internal error if resume is short-circuited (Re: [PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint) Pedro Alves
2015-03-19 12:49 ` [pushed] gdbserver/Linux: unbreak thread event randomization (Re: [pushed] native/Linux: internal error if resume is short-circuited) Pedro Alves
2015-03-19 16:14 ` Pedro Alves [this message]
2015-03-19 16:54 ` [pushed] Re: [PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization) Pedro Alves
2015-03-06 19:58 ` [PATCH 3/6] Fix race exposed by gdb.threads/killed.exp Pedro Alves
2015-03-19 17:39 ` Pedro Alves
2015-03-06 19:58 ` [PATCH 5/6] gdbserver/Linux: internal error when killing a process that is already gone Pedro Alves
2015-03-06 19:58 ` [PATCH 2/6] Introduce throw_ptrace_error Pedro Alves
2015-03-06 21:04 ` Mark Kettenis
2015-03-06 21:40 ` Pedro Alves
2015-03-08 20:30 ` Mark Kettenis
2015-03-08 21:48 ` Pedro Alves
2015-03-10 14:53 ` Mark Kettenis
2015-03-11 15:44 ` Pedro Alves
2015-03-19 17:33 ` [pushed] Fix race exposed by gdb.threads/killed.exp (Re: [PATCH 2/6] Introduce throw_ptrace_error) Pedro Alves
2015-03-06 19:58 ` [PATCH 1/6] Move throw_perror_with_name to common/ Pedro Alves
2015-03-06 20:27 ` [PATCH 6/6] Add test that exercises the inferior being killed while stopped under GDB Pedro Alves
2015-07-14 10:22 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550AF5F7.5080909@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox