From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6454 invoked by alias); 15 Jun 2015 13:01:29 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 6444 invoked by uid 89); 15 Jun 2015 13:01:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_50,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS 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; Mon, 15 Jun 2015 13:01:28 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id F0E7A3679FD; Mon, 15 Jun 2015 13:01:26 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5FD1PA9002035; Mon, 15 Jun 2015 09:01:26 -0400 Message-ID: <557ECCA5.7050506@redhat.com> Date: Mon, 15 Jun 2015 13:01: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: Eli Zaretskii CC: gdb@sourceware.org Subject: Re: Inadvertently run inferior threads References: <83h9tq3zu3.fsf@gnu.org> <55043A63.6020103@redhat.com> <8361a339xd.fsf@gnu.org> <5504555C.804@redhat.com> <550458E0.10206@redhat.com> <83y4jrsgui.fsf@gnu.org> In-Reply-To: <83y4jrsgui.fsf@gnu.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-06/txt/msg00024.txt.bz2 On 06/10/2015 04:50 PM, Eli Zaretskii wrote: >> I can't explain why you see _all_ threads as running instead of >> only the new ones, though. > > I think I can explain that. Thanks for the investigation. > > First, in MinGW native debugging the function set_running, as well as > most other thread-related functions that change state, are always > called with minus_one_ptid as their ptid argument, and therefore they > change the state of all the threads. > > The second part of the puzzle is that when these threads are started, > we are inside the 'proceed' call made by 'run_inferior_call'. When a > thread like this is started during this time, we get > TARGET_WAITKIND_SPURIOUS event inside 'handle_inferior_event', and > call 'resume'. But when 'resume' is called like that, inferior_ptid > is set to the thread ID of the new thread that was started, and which > triggered TARGET_WAITKIND_SPURIOUS. So when 'resume' wants to > suppress the stopped -> running transition, here: > > if (!tp->control.in_infcall) > set_running (user_visible_resume_ptid (user_step), 1); > > it winds up calling 'set_running', because the in_infcall flag is set > on the thread that called the inferior function, not on the thread > which was started and triggered TARGET_WAITKIND_SPURIOUS. > > So 'set_running' is called, and it is called with minus_one_ptid, > which then has the effect of marking all the threads as running. So that should mean that even for GNU/Linux, it should be possible to end in the exact same, when any thread other than the one that we had started the infcall in reports an event that doesn't cause a stop. E.g., a thread specific breakpoint, a "handle nostop" signal, etc. Thanks, Pedro Alves