From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KeLcGMS/PmqThhkAWB0awg (envelope-from ) for ; Fri, 26 Jun 2026 14:07:00 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=uVKjyEfB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5A4971E098; Fri, 26 Jun 2026 14:07:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CEB2E1E024 for ; Fri, 26 Jun 2026 14:06:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 289724BA2E37 for ; Fri, 26 Jun 2026 18:06:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 289724BA2E37 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=uVKjyEfB Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 6B3F24BA2E16 for ; Fri, 26 Jun 2026 18:06:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B3F24BA2E16 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B3F24BA2E16 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782497194; cv=none; b=ABcm9a/a5dwg5hu8lPv9BuOkWu/koSYdCpsnT4+pk60KINypy01RKHr5FhQ0DHrUWvHnIHwvQHrFWuz7DO9YH//6NbjPXwyNzY1os8AIC7zBeE4Bo7CfyDoS5UUlppG/XA4N2nyHPSmqXEDy4ULdG9yNdn9v/ozQ3OBcCIpcY3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782497194; c=relaxed/simple; bh=OEinAFi+/LSNhEqKYQLm3OD5wRKO8ihLqMFp5SG0Fr8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=m7tBdGYXPFK2jCxeHEQrYqRq7usCJCa6k0hpl+AANVthY9zMIswA3V/PIX1I92yrcdgW7ziXbyYeYf3Bk1tmxKMkdq39KghC99JVrtRsZp2WJ2DqqdmcvqwNfperH88K8nsv5OLgM0r2eTQsS/daD34XnwaK277FLuZbXc6rVMI= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=uVKjyEfB DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B3F24BA2E16 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 65QI6Q1R205043 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jun 2026 14:06:30 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 65QI6Q1R205043 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1782497191; bh=eVXC9C8ycKKEfGlL6iSIwCSIDC+QAiGCNVOSpltHWT8=; h=Date:Subject:To:From:In-Reply-To:From; b=uVKjyEfBjkGSbogBP2mO7inKJvqrOKm9CKW20/VnVTOREukkqAQirVMcHEo7/+Wux XbRwsNqnQOvmXpRnXXIeTIKinO7uNvYN25YRUiEZIp/pLZikjKZ0sviBNRwcSk6gm/ /qcUtAedMmr0z0UDvWl6SwmT0avILcSy1AueQtHF4D00dD9B1vDe2uktfR3u5R3e9m EnG5jFnmKR6P3uIutW4MNbJTgNYOblT5ouDu561REgDi4TYVMGDb+M1PeHrubH1Gdu EYaq7sOIo1S8j4Tfd5Bdjj9rnJouj9N3awXNcHDN1cVfP+p8pjep2HjtipiRpvYTmC xTfFe4j4OAtJQ== Received: by simark.ca (Postfix) id 083FE1E024; Fri, 26 Jun 2026 14:06:25 -0400 (EDT) Message-ID: Date: Fri, 26 Jun 2026 14:06:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdbserver/linux-low: carry over stop_expected flag after exec (avoid spurious SIGSTOPs) To: Pedro Alves , gdb-patches@sourceware.org References: <20260626143242.4033142-1-simon.marchi@polymtl.ca> Content-Language: en-US From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 26 Jun 2026 18:06:26 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2026-06-26 14:04, Pedro Alves wrote: > On 2026-06-26 19:00, Simon Marchi wrote: >> On 2026-06-26 13:35, Pedro Alves wrote: >>>> + unsigned long execing_tid = event_ptid.lwp (); >>>> + if (ptrace (PTRACE_GETEVENTMSG, event_ptid.lwp (), (PTRACE_TYPE_ARG3) 0, >>>> + &execing_tid) != 0) >>>> + execing_tid = event_ptid.lwp (); >>> >>> This gave me pause -- this is setting execing_tid to the event lwp if ptrace fails. >>> But execing_tid is already initialized to the event lwp. I think it'd be clearer not >>> to initialize it, like: >>> >>> unsigned long execing_tid; >>> if (ptrace (PTRACE_GETEVENTMSG, event_ptid.lwp (), (PTRACE_TYPE_ARG3) 0, >>> &execing_tid) != 0) >>> execing_tid = event_ptid.lwp (); >> >> Well, the question then is: what if the ptrace call fails? It probably >> never fails, but we still have to think about it. execing_tid would be >> used uninitialized. I see three options: > > I'm confused with the question. In the snippet I proposed, if ptrace fails, > then we set execing_tid: > > unsigned long execing_tid; > if (ptrace (PTRACE_GETEVENTMSG, event_ptid.lwp (), (PTRACE_TYPE_ARG3) 0, > &execing_tid) != 0) > execing_tid = event_ptid.lwp (); <<< ptrace failed. > > So this behaves exactly like your original code, just without the redundant > initialization. > > Am I missing something? No, I did miss that assignment. I will add a comment to say that we fall back to the leader if ptrace fails, not ideal but should be correct most of the time. Simon