From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25703 invoked by alias); 22 Aug 2018 16:10:22 -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 25692 invoked by uid 89); 22 Aug 2018 16:10:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1961, Weird X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Aug 2018 16:10:20 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E234840216E9; Wed, 22 Aug 2018 16:10:18 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 456A17C5A; Wed, 22 Aug 2018 16:10:18 +0000 (UTC) Subject: Re: [RFA 4/5] Darwin: fix thread ptid started by fork_inferior To: Xavier Roirand , gdb-patches@sourceware.org References: <1534932677-9496-1-git-send-email-roirand@adacore.com> <1534932677-9496-5-git-send-email-roirand@adacore.com> Cc: brobecker@adacore.com From: Pedro Alves Message-ID: <151c55c9-a622-d01e-7431-8e49c5193751@redhat.com> Date: Wed, 22 Aug 2018 16:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1534932677-9496-5-git-send-email-roirand@adacore.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-08/txt/msg00539.txt.bz2 On 08/22/2018 11:11 AM, Xavier Roirand wrote: > > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c > index 96f70cf..9ad4a87 100644 > --- a/gdb/darwin-nat.c > +++ b/gdb/darwin-nat.c > @@ -344,8 +344,22 @@ darwin_check_new_threads (struct inferior *inf) > pti->gdb_port = new_id; > pti->msg_state = DARWIN_RUNNING; > > - /* Add the new thread. */ > - add_thread_with_info (ptid_t (inf->pid, 0, new_id), pti); > + if (old_nbr == 0 && new_ix == 0) > + { > + /* A ptid is created when the inferior is started (see > + fork-child.c) with lwp=tid=0. It looks like this patch was written against an older gdb, because fork-child.c doesn't add a thread nowadays. For GNU/Linux, it's inf-ptrace.c that adds the initial thread, but only after fork_inferior returns (inf_ptrace_target::create_inferior). But were is that equivalent code in darwin-nat.c? /me looks. Answer: it's nowhere. It does not exist. So, when then shared fork-child.c was created a while ago, the add_thread call was moved to darwin-nat.c's target_create_inferior implementation. But, later on, Simon removed that add_thread call with: commit db665f427ca781d631d9e29b1bb744fb11ffcbba Author: Simon Marchi AuthorDate: Tue Jun 27 10:55:36 2017 +0200 Commit: Simon Marchi CommitDate: Tue Jun 27 10:56:53 2017 +0200 darwin: Do not add a dummy thread (Weird, I can't find that patch on the list's archives, even though I received a local copy.) It sounds to me like you need to reevaluate the patch from scratch, because its premise is invalid. > @@ -1933,6 +1956,8 @@ darwin_nat_target::attach (const char *args, int from_tty) > inferior_appeared (inf, pid); > inf->attach_flag = 1; > > + add_thread_silent (inferior_ptid); > + > darwin_attach_pid (inf); > > darwin_suspend_inferior (inf); This surely is not related to "run" and/or fork-inferior.c Thanks, Pedro Alves