From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96015 invoked by alias); 3 Mar 2015 16:25:12 -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 96004 invoked by uid 89); 3 Mar 2015 16:25:12 -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; Tue, 03 Mar 2015 16:25:11 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t23GP97u027774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Mar 2015 11:25:09 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t23GP850009547; Tue, 3 Mar 2015 11:25:09 -0500 Message-ID: <54F5E064.8070205@redhat.com> Date: Tue, 03 Mar 2015 16:25:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Mark Kettenis CC: gdb-patches@sourceware.org Subject: Re: [PATCH] Linux/ptrace: don't convert ptids when asking inf-ptrace layer to resume LWP References: <201503031439.t23EdHZv020814@glazunov.sibelius.xs4all.nl> <54F5CF70.2090706@redhat.com> <201503031604.t23G4JqR008694@glazunov.sibelius.xs4all.nl> In-Reply-To: <201503031604.t23G4JqR008694@glazunov.sibelius.xs4all.nl> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-03/txt/msg00102.txt.bz2 On 03/03/2015 04:04 PM, Mark Kettenis wrote: >> > Date: Tue, 03 Mar 2015 15:12:48 +0000 >> > From: Pedro Alves >> > >> > Or is it that if there are multiple kernel threads in the >> > process, ptrace(PTRACE_CONT, PID) on bsd actually resumes >> > them all? Then other things must be broken anyway. > I can only speak for OpenBSD here, but yes, on OpenBSD, if you pass > "PID" here, all threads within a process are resumed. If you want to > resume an individual thread, you need to pass its thread ID. Thread > IDs are also integers, but start at THREAD_PID_OFFSET, which is > currently defined as 1000000. > > Are things broken? Perhaps. GDB used to properly support an > all-stop/all-go model, and things still seem to work mostly ok. > Perhaps this diff will actually make things better if there are places > where GDB wants to resume or step a single thread that isn't the > thread that stopped the process in the first place. Yes, I assume so. Things like schedlock and stepping over a breakpoint must have been subtly broken thus far, if they have been letting all threads run while core gdb wants only one thread to run. > > I've always considered it a serious flaw that Linux doesn't have a way > to resume the entire process and that we need almost 5000 lines of > code to deal with the consequences. :-) > >> > I was assuming that on BSD targets that use this method, >> > there would only be one thread in the core thread list, and >> > it would either have LWPID==0, or have PID==LWPID, thus it didn't >> > matter if get_ptrace_pid returned the PID or the LWPID. > That assumption is incorrect. OK. > I see that this assumption has made its way into infrun.c: > > inferior_ptid = ptid_build (child_pid, child_pid, 0); > > That's wrong. The OS-specific code should fill in the LWPID part with > the appropriate value by using thread_change_ptid(). AFAICT, the > linux-nat.c code does that properly. I think you're pointing at the follow fork code. That was born out of a generalization of code that used to live in linux-nat.c, inf-ptrace.c, etc. (d83ad864). The old inf-ptrace.c code used to do: /* Switch inferior_ptid out of the parent's way. */ inferior_ptid = pid_to_ptid (fpid); /* Delete the parent. */ detach_inferior (pid); add_thread_silent (inferior_ptid); 'child_pid' is set at the top of follow_fork_inferior, like: child_pid = ptid_get_pid (inferior_thread ()->pending_follow.value.related_pid); I think I even remember that long ago "related_pid" used to be a single int, not a ptid. This is again another case of losing information. I think we could easily make that: child_pid = inferior_thread ()->pending_follow.value.related_pid; and drop that ptid_build, and things should work everywhere. I have no idea if "follow fork" actually works on BSD targets correctly. A buildbot slave would catch breakages like these. ( hint :-) ) > >> > If there anything that actually creates other threads with >> > a different LWPID on these targets? > The initial thread ID of an OpenBSD process will be PID + THREAD_PID_OFFSET. > Thanks, didn't know that. Pedro Alves