From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id BD8963857C7A for ; Wed, 24 Nov 2021 22:17:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BD8963857C7A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 75E9B9B347; Wed, 24 Nov 2021 22:17:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzwNm20Qhz4lWR; Wed, 24 Nov 2021 22:17:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id D106D2953; Wed, 24 Nov 2021 22:17:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <7c3d3b67-9975-0011-7bc5-20f71dadec65@FreeBSD.org> Date: Wed, 24 Nov 2021 14:17:26 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-US To: Andrew Burgess Cc: gdb-patches@sourceware.org References: <20210803185000.22171-1-jhb@FreeBSD.org> <20210803185000.22171-9-jhb@FreeBSD.org> <20211124150047.GH2662946@redhat.com> From: John Baldwin Subject: Re: [PATCH v2 08/13] fbsd-nat: Implement async target support. In-Reply-To: <20211124150047.GH2662946@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637792248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p/UV35klbMwI1xmL/Y3+v6I6aCGWCn4LjBqgS9Tclcs=; b=ak3EakjvYr+perSwIlmWSMiDnl3xgCMCStjBIct6jhp7gQoe+QBVNMeEftceg0MPWhO+Tj dQz6m+657Dx7j6LJUQ37QqiPz+XRjhbWQAmekhZfPtkddfjvDDxIw2FURnz0VT+nhXjpYU rMwbVcCZgr2HAV/7j5nKM1mv/p/yj1rm9RVmaDxEjtdHrpvu2B9H/DHg3dgqPdCw39Dx8Z AXka25mbILX5+TQUu2pnImx2esL5B07MpkGghG2aOki952WBzL/QLTV5j0CFmYwA60TCxc 3w/kKfFB+pWwjptNFmcx3QUMXf8B8IgdCJx6VXdcVEHbsf8/m/53r8RHIHaV3g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637792248; a=rsa-sha256; cv=none; b=fQKzCIYKTLpiA3omA1Zv16qDcr4ogFqbypouahKz0NSNnbYGE5NODcC7lDkHvemkOw6WLt ehAGVfPKmuGXNfAz5HhmXI6jsaoiBkKTzcqD921DuddvgyfIuBGiQSjF2e4Qtd/48V57sR XIz0WyBXNNqz5n8443lYl5dG/letEwg4yqsnMgfwqwoqAS4rKoRuXoINfshb62muqV+oNd O3jG97Fr0+bgF1yi7kXEZQfxrHWSAsfAGwNpOAB+bF67+2VI51kWS1t+Y1+lH2SAOE2I8w kEYcyHlLiAhf1VV5TORkSW/Qisg6aB251ehSl1qPcOkv5pxTwBVCHvlAKlFQIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2021 22:17:39 -0000 On 11/24/21 7:00 AM, Andrew Burgess wrote: > * John Baldwin [2021-08-03 11:49:55 -0700]: >> @@ -1377,6 +1493,33 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, >> } >> } >> >> +ptid_t >> +fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, >> + target_wait_flags target_options) >> +{ >> + ptid_t wptid; >> + >> + fbsd_nat_debug_printf ("[%s], [%s]", target_pid_to_str (ptid).c_str (), >> + target_options_to_string (target_options).c_str ()); >> + >> + /* Ensure any subsequent events trigger a new event in the loop. */ >> + if (is_async_p ()) >> + fbsd_nat_event_pipe.flush (); >> + >> + wptid = wait_1 (ptid, ourstatus, target_options); >> + >> + /* If we are in async mode and found an event, there may still be >> + another event pending. Trigger the event pipe so that that the >> + event loop keeps polling until no event is returned. */ >> + if (is_async_p () && ourstatus->kind != TARGET_WAITKIND_IGNORE) >> + fbsd_nat_event_pipe.mark (); > > I notice you use a different condition here to the one present in > linux-nat.c, specifically, if you get an event of type > TARGET_WAITKIND_NO_RESUMED, you'll remark the pipe, while Linux > doesn't. > > Is there a reason for this difference? Hmm. Initially I had been returning IGNORE instead of NO_RESUMED for the ECHILD error from waitpid() and Pedro had suggested fixing the waitkind for ECHILD during the review of version 1 of the series. I think when I made that change to inf-ptrace.c I failed to update this hunk. We probably do not want to keep calling waitpid() after an ECHILD. In terms of the check in linux-nat.c for the ptid being minus_one_ptid, here I'm less certain. I suppose the edge case there is if the core is waiting for an event for a specific ptid (such as a step) and another process raises SIGCLD, we might miss the other process' event. Presumably the event raised by inferior_event_handler is going to always do a wait() with minus_one_ptid so it shouldn't spin endlessly to always mark after a wait() for a specific ptid. >> @@ -1510,6 +1653,11 @@ fbsd_nat_target::follow_fork (ptid_t child_ptid, target_waitkind fork_kind, >> /* Schedule a fake VFORK_DONE event to report on the next >> wait. */ >> fbsd_add_vfork_done (inferior_ptid); >> + >> + /* If we're in async mode, need to tell the event loop >> + there's something here to process. */ >> + if (is_async_p ()) >> + fbsd_nat_event_pipe.mark (); > > If feels like this marking of the event pipe should be within > fbsd_add_vfork_done maybe? The two actions, queuing the fake event, > and marking the async event pipe are tightly coupled, right? > > I guess you might need to make fbsd_add_vfork_done a private member > function so you can easily call is_async_p(), or just call > 'target_is_async_p()' instead. Done. I went with just using target_is_async_p(). -- John Baldwin