From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id D7D613858433 for ; Mon, 17 Jul 2023 19:21:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7D613858433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.com (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id F3A651A84C70 for ; Mon, 17 Jul 2023 15:20:54 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 0/8] Fixes for multiprocess for FreeBSD's native target Date: Mon, 17 Jul 2023 12:20:31 -0700 Message-Id: <20230717192039.13976-1-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Mon, 17 Jul 2023 15:20:55 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,KAM_DMARC_STATUS,KHOP_HELO_FCRDNS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: While this series is not perfect, it does result in a net improvement in testsuite results on FreeBSD/amd64 and is also a significantly better experience debugging forking processes. I'm less confident about the last two patches but would like to get the first 6 patches into GDB 14. Changes since V1: - A few early trivial patches were merged. - The list of pending events are now stored as private class members of class fbsd_nat_target in Patch 1 along with various style fixes noted by Simon. I also added an assertion that a pending event always has an associated inferior when it is added to the list. - Patch 2 adds a bug trailer. - Patch 3 is a bit simpler since the methods to work with the pending list are now class methods so the "this" pointer doesn't have to be passed around as often. The ptid argument to resume is now renamed to scope_ptid. I also added handling for TARGET_WAITKIND_IGNORE in the stop_process helper to avoid adding a bogus pending event if the process has disappeared (so wait() fails with ECHILD). This case was caught by the new assertion in Patch 1. - In patch 4, a workaround in pending_ptrace_events for a kernel bug is now conditional since I've merged an upstream fix to FreeBSD's kernel since posting the first version at https://cgit.freebsd.org/src/commit/?id=653738e895ba022be1179a95a85089e7bc66dbbe - Patches 5 and 6 are unchanged. - Patches 7 is new and replaces the ptid_t to identify single LWP vs entire process being resumed with an unordered_set<> of resumed LWPs permitting multiple individual LWPs in a process to be resumed while other LWPs are still suspended. Since FreeBSD can only PT_CONTINUE entire processes at a time, this means that the resume target method can no longer use ptrace directly, but instead stores the requested actions as a set of pending actions in the per-inferior data structure. Later when either commit_resumed or wait is called, the target runs through all its non-exited inferiors comitting the cumulative results of earlier resume calls. Because that change is a bit hairy I've kept separate from the previous round of multiprocess fixes in patch 3 to make it easier to bisect in the future if there are regressions. - Patch 8 is new and adds an implementation of the stop target method. It wasn't clear to me if this is really needed for an all-stop-only target, but at least one test in the testsuite was calling this method when I made it gdb_assert() instead of being the default. John Baldwin (8): fbsd-nat: Add a list of pending events. fbsd-nat: Defer any ineligible events reported by wait. fbsd-nat: Fix resuming and waiting with multiple processes. fbsd-nat: Fix several issues with detaching. fbsd-nat: Fix thread_alive against a running thread. fbsd-nat: Stop a process if it is running before killing it. fbsd-nat: Defer resume of inferiors. fbsd-nat: Implement the target stop method. gdb/fbsd-nat.c | 971 ++++++++++++++++++++++++++++++++++++++++++------- gdb/fbsd-nat.h | 68 ++++ 2 files changed, 915 insertions(+), 124 deletions(-) -- 2.40.0