From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46659 invoked by alias); 19 Mar 2015 16:14:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 46644 invoked by uid 89); 19 Mar 2015 16:14:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 Mar 2015 16:14:50 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2JGEnYN014527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 19 Mar 2015 12:14:49 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2JGElje024668 for ; Thu, 19 Mar 2015 12:14:48 -0400 Message-ID: <550AF5F7.5080909@redhat.com> Date: Thu, 19 Mar 2015 16:14:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization) References: <1425671886-7798-1-git-send-email-palves@redhat.com> <1425671886-7798-5-git-send-email-palves@redhat.com> <550AC2EB.10801@redhat.com> <550AC5E7.5030200@redhat.com> In-Reply-To: <550AC5E7.5030200@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-03/txt/msg00591.txt.bz2 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 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 * 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