From nobody Thu Dec 22 22:10:54 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NdPdq0Lcqz1J24y; Thu, 22 Dec 2022 22:10:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NdPdp6Xhsz3jY6; Thu, 22 Dec 2022 22:10:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671747054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CDngZWK+Cqc+zltehgl7sYkHhgHe30zcnx3beKHTYTA=; b=FahlKNlsHxkQmQmyrq6fxRt1JlW5ENA3LWm+kgp63xctVp8Bd4+Ru/l3o2UXhsDnAz8jEY 013j6taFXkIHWP/yeLNIb7fFIZ/LoSY0W8B+upwzfUvfrM0KB0T29gbZ0VEk4Dn0Y9WG1w jQBnI2yDBbQnYRMRptY6bfpx3GfygE9Qt9CdRaamWyLkCquiYh22deBbvvtNtgh4ywtXFb 6hVzNPQ0vO0lgjLlTYJYTN/XJcg8wrA79TQndi9ZR+ev2IAjBglnPQx+E6r1SeUVNj/qyY 7Ol+jq+hRZGSLaRBM4gK6lM8yiS7BSKaO6VMhdvHUp5S5g9ROzt3DU7XhPKKcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671747054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CDngZWK+Cqc+zltehgl7sYkHhgHe30zcnx3beKHTYTA=; b=ys1OQXq7BiUPdOl/MFDTCU66Ayry9qy4x+jWY467BIVzAZ3bVmA5lGjCfInbE+WoEskOxI oMzGWRrRGbMcTYofNlbI4Iudn0XUMdaOqDZNJYkgbotP80u/l01q5DIXHEGOtxvA5c4lvb Rg3dqylPq/J1CD2HItsBNqztdOsSIua4dIiETww306ZHDOKeRArtF1/i8vCaK1UesZ42u7 FiZ/BY6t6xzckJcs/d8y5YHoPyOfSQT8sUYWsYvRbctvs2Ge/33xmWT62d7VvV9xkMjc7a DDsi+n/DLObjzHCWqOsmj6/qLoh94kpjv96YKwnOGMNMl2WVz3LJb1D4HqZi4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671747054; a=rsa-sha256; cv=none; b=NRiIZPaXGNz2R9+jalvEhQd/3lYLLgVckTVYZ9qJ8OmDwFp1D4sbjI/KnYhoK3jBcttcTO BBwSQA4iT/6yT9H3sTk25L+wvR+odAOlcGZid3TQ3Li9JBZ4LQI0QyJTCXiOy17sgttKXA 2c+6c+JFnSlT/8EkSZc1OijwcgCM4B+SWxJCnhnGljIJq9gmeyOhE+jzl8PX9wt3td6sFE NA1kk7LKGnmozzs0eyayS8mHUhqFXpYOOVcLOM9DASmmH2Pb/MOF137d6SwnfQPTZ2lSvE lEFzr7my9QQTFdeZRX8nTBeqZ/oudoq3m9wnRXSiBHRQFkLs8apTc0xiFXWY3w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NdPdp5dzVz18sK; Thu, 22 Dec 2022 22:10:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BMMAs6j038163; Thu, 22 Dec 2022 22:10:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BMMAsg2038162; Thu, 22 Dec 2022 22:10:54 GMT (envelope-from git) Date: Thu, 22 Dec 2022 22:10:54 GMT Message-Id: <202212222210.2BMMAsg2038162@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0e07241c372d - main - ptrace(2): explain how to select specific thread to operate on List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0e07241c372d7352537a4a786c96a580a721be3c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0e07241c372d7352537a4a786c96a580a721be3c commit 0e07241c372d7352537a4a786c96a580a721be3c Author: Konstantin Belousov AuthorDate: 2022-12-05 22:43:18 +0000 Commit: Konstantin Belousov CommitDate: 2022-12-22 21:11:35 +0000 ptrace(2): explain how to select specific thread to operate on Requested by: emaste Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37590 --- lib/libc/sys/ptrace.2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 4589fac92d26..01d83897a78b 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -122,6 +122,25 @@ Kernel drops any signals queued to the traced children, which could be either generated by not yet consumed debug events, or sent by other means, the later should not be done anyway. +.Sh SELECTING THE TARGET +The +.Fa pid +argument of the call specifies the target on which to perform +the requested operation. +For operations affecting the global process state, the process ID +is typically passed there. +Similarly, for operations affecting only a thread, the thread ID +needs to be passed. +.Pp +Still, for global operations, the ID of any thread can be used as the +target, and system will perform the request on the process owning +that thread. +If a thread operation got the process ID as +.Fa pid , +the system randomly selects a thread from among the threads owned +by the process. +For single-threaded processes there is no difference between specifying +process or thread ID as the target. .Sh DISABLING PTRACE The .Nm