From patchwork Tue Oct 18 12:40:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 58992 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 90F9D38582B8 for ; Tue, 18 Oct 2022 12:40:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by sourceware.org (Postfix) with ESMTPS id 18BBF3858C50 for ; Tue, 18 Oct 2022 12:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 18BBF3858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f54.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso14882965wma.1 for ; Tue, 18 Oct 2022 05:40:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+CoNbNx5eVb+mKMdiLfBWx5OdXuyGSLSIDAYbt6GrvQ=; b=gbFII7Mo/Er+1mjqexlFXqJ1NFMsCn2V3GK6XTvVIf3RTL+0FkE2jMwvAGOnDdcmkP EVMCvClyZSg6Oq7eR5AIpo/11tZeI1xfYq1aj66dEaHPLsk5bltyeyUJ7IswtCR6u354 UeCIt4vfAhcwjwDwlxjPKJk9YeeUxCnchtQHnCUeNs3F+X3m1/kumZmS/zxVwNLnRopu gCUDWDbMXWXZHTojrsiwn0uaHbcFxSwedVKD1KW/zVvEGmz8f5JNwqcI7mE/q+TUgXtI T4KBhTjtgU+bKaQLB1lLNHuy4PQdJXiIxeJkpeXak1HhrsP1GKg4uMICP4E5iZ9tb+CC jahg== X-Gm-Message-State: ACrzQf2lDK+j8r/GJVz+ljkWgbghJS8MftRYAsMHps0sid6lJ94xwNu1 FzqdTGsNB3JMq3vpKYvzXOdrK+r9XPMaCw== X-Google-Smtp-Source: AMsMyM6oC7JAUjAaRmwcc7OV/XVGZnwXbP98U03MxLYe1ZG17EteuwXYj5sfXpgRQBygTaUZBHSeog== X-Received: by 2002:a05:600c:310c:b0:3c6:f7c6:c7b6 with SMTP id g12-20020a05600c310c00b003c6f7c6c7b6mr1840982wmo.81.1666096836681; Tue, 18 Oct 2022 05:40:36 -0700 (PDT) Received: from ?IPv6:2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653? ([2001:8a0:f93a:3b00:e038:5cdc:b8bf:4653]) by smtp.gmail.com with ESMTPSA id v9-20020a05600c444900b003c6f8d30e40sm6116214wmn.31.2022.10.18.05.40.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Oct 2022 05:40:35 -0700 (PDT) Subject: [PATCH] Don't explicitly set clone child ptrace options (was: Re: [PATCH v2 04/29] Step over clone syscall w/ breakpoint, TARGET_WAITKIND_THREAD_CLONED) To: Simon Marchi , gdb-patches@sourceware.org References: <20220713222433.374898-1-pedro@palves.net> <20220713222433.374898-5-pedro@palves.net> From: Pedro Alves Message-ID: Date: Tue, 18 Oct 2022 13:40:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" On 2022-07-21 2:35 a.m., Simon Marchi wrote: >> + >> + lwp_info *new_lp = add_lwp (child_ptid); >> + new_lp->stopped = 1; >> + >> + /* If the thread_db layer is active, let it record the user >> + level thread id and status, and add the thread to GDB's >> + list. */ >> + if (!thread_db_notice_clone (inferior_ptid, new_lp->ptid)) >> + { >> + /* The process is not using thread_db. Add the LWP to >> + GDB's list. */ >> + target_post_attach (new_lp->ptid.lwp ()); > Can you explain why that target_post_attach call? Oh, I just noticed it > was already there. Still, can you explain? > Looks like I added this in the initial native Linux non-stop support, back in commit 4c28f408dfc2ab71b7995f061cc725d3f217ec9c Author: Pedro Alves AuthorDate: Thu Jul 10 22:58:37 2008 +0000 Commit: Pedro Alves CommitDate: Thu Jul 10 22:58:37 2008 +0000 Non-stop linux native. (back at CodeSourcery; the email is incorrect due to the cvs->git conversion) I can't explain the target_post_attach call, it does look unnecessary. Here's a patch removing it. From f02d5043307a2c79b38477e7bcbd369fcf53c104 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 14 Oct 2022 20:17:36 +0100 Subject: [PATCH] Don't explicitly set clone child ptrace options linux_handle_extended_wait calls target_post_attach if we're handling a PTRACE_EVENT_CLONE, and libthread_db.so isn't active. target_post_attach just calls linux_init_ptrace_procfs to set the lwp's ptrace options. However, this is completely unnecessary, because, as man ptrace [1] says, options are inherited: "Flags are inherited by new tracees created and "auto-attached" via active PTRACE_O_TRACEFORK, PTRACE_O_TRACEVFORK, or PTRACE_O_TRACECLONE options." This removes the unnecessary call. [1] - https://man7.org/linux/man-pages/man2/ptrace.2.html Change-Id: I533eaa60b700f7e40760311fc0d344d0b3f19a78 --- gdb/linux-nat.c | 1 - 1 file changed, 1 deletion(-) base-commit: 32e876a80f015281cd7fca46e8a589c6cf132d11 diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index d4639766088..2ef278a914f 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1915,7 +1915,6 @@ linux_handle_extended_wait (struct lwp_info *lp, int status) { /* The process is not using thread_db. Add the LWP to GDB's list. */ - target_post_attach (new_lp->ptid.lwp ()); add_thread (linux_target, new_lp->ptid); }