From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id v2LnBf1ZnWih+wIAWB0awg (envelope-from ) for ; Wed, 13 Aug 2025 23:37:33 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=wZeUFXlx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 097271E0B3; Wed, 13 Aug 2025 23:37:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 E793D1E087 for ; Wed, 13 Aug 2025 23:37:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 480A03858C53 for ; Thu, 14 Aug 2025 03:37:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 480A03858C53 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=wZeUFXlx Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 438BC3858D20 for ; Thu, 14 Aug 2025 03:36:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 438BC3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 438BC3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755142616; cv=none; b=SdydayShVbsXMEJ81Z/JSkTEW3IdpXoeUb2a/BQTxpe1KDuLpLsH70JAiKmvYFKctDpEfRGd0us5jnZ+b5BiozVvfu5i0fASjPlH6SwX9u5/ISzx+nn+aAO1CAEyLLE9BTdZ5LoZ022oEfj/djf3UPOukz2d3alFOdGy55B49Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755142616; c=relaxed/simple; bh=uDJQPbW6zgjslxFlvGZ6/00WLz31Z8GVlLMPNxlQOAQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CAMrJ+XYgthhWCmWeTPmUtpU5HYgpiKAd4tDRUnZem2G8Pa+JDDLap8uFzgHl3qFsGdCGCOW4R/LJxkRmc+ASEEkEPro8B8uGFTCgu8zo1bnsdKOtX2AOoh7m2d09YZAJLW20kwA8GCHHcehXOkGYVlEZqxU488xXTitH2x/exg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 438BC3858D20 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-b47175d02dcso537453a12.3 for ; Wed, 13 Aug 2025 20:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755142615; x=1755747415; darn=sourceware.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=PKPy3gbRQodaS++CB1AiyFaAmEmno7rNfN9j33cXOkc=; b=wZeUFXlxg1NcU4vdtWSsM1Dd8Aw4PBgaAOMTl2we17UQF7o0t7Y5Dtac+5QRqRQOdj Obr7nHKwMLi6GCQ/Nx8lLJRB8NP3LS0XpPBTV6h3pmYDVwhpA+8g48/ATEQ7z1Ui7/Lc 9v/M5ZebBtkLlLiZVS5QD+X0ZThjlzRTF5uB6g2zTRMGSP9THfiSQB41BRZmYQxJINti Rqmr15l5by2ccTLbQhNtCQVbKCbQxfvF0liT5M2+XYU5+y8mM2Zykx7cC7DLJuEvfer/ NayC4wzbQyeNjV3obSakp+AakwmVfEtPpTClC7aum2s9Ty2B9vIIL3JkwvOe1AyYcfT8 Ving== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755142615; x=1755747415; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PKPy3gbRQodaS++CB1AiyFaAmEmno7rNfN9j33cXOkc=; b=GYoOkMgn805htfxMomBulphfpSCWYProqoWtaVrhynkSzdvZlbupyWEftfn6PsoFIe FiHQJghENVV+jAq/uxxBCwiWnVM5k67mEAi1/adlxxSqO75umSR5CkSbpdXoGr91t8/t mOpOhvUAzWs05wyXfpgODXDVEQGctLjuMizakDZ195HadsNgwoaum8yCf1/he1cIOWy9 wnRLzNpAdUIxL6lkHURRN13k4mJnOpKl1fLq4G8e50mXBnuJ73n2YzWFCOSQ8jr78Ohm QoOB5Nef7hMLMYCRcr2WKpyrtI/BBV6zi+pJjc2U8lyrkQMmyEcn9f/gP+ECP8rVGJOq uIaw== X-Gm-Message-State: AOJu0YxrU7o/Tpyojpe/K4/cjGxYpwwrtOBJQ6LCJx5IYrkWcLoHFs1u hB6ID4lQD/VnFWQrGjGb7HPBHTOhb3yCnEE96wEd/BXxmHvg0ZOw84JcmlWYzz4EQUu6F6+JoGO eeDsq X-Gm-Gg: ASbGncuqFsNf8NLjzfCL5VSiW0/Bgc0fKd0XQDGzVEfdsFWyRZU3ncZPdWf1ZHgYrJg uXAjmCRooFQiIp+tBihzdoLWM41kmCwbmp7OriEd73A1ubRLSgcxMdGUK2+mJyS+GjjVkmVOyrH FtnAdObxHS7p5KML7GGr6FeO7fwrBaPytim+PZlkguhH4bSIFJyF83DcsWfEQWOlZQQyFKMB7A5 foV3a5fM40j3vNgZ6Of0GzBz/qVyqtJpMgBI/Iq+Rmin6GBfTGPWernq7xolsoAUkLUUmCI/dlZ RRFcem8FYtW5ItVKLdTGsqVu3LeyZszJ18ggRA6jJK/VBlNG/AGBi4utRs0x6c1Q/4tep/pORnY dB3YrR1RftNlG2vQFe9oOqhvXC9bSY+5F X-Google-Smtp-Source: AGHT+IGLSxO7P7bUdfMn+0FyCa2fAe6v9UuB+X/RSiUnm+05+4yJWKRhFIK59UBzGgZ2/EVIcedMfw== X-Received: by 2002:a05:6a20:728e:b0:240:c3d:2449 with SMTP id adf61e73a8af0-240bd2b465emr2317805637.42.1755142615136; Wed, 13 Aug 2025 20:36:55 -0700 (PDT) Received: from localhost ([2804:14c:87d5:567d:70c5:d1b9:6081:7458]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bccfd88dbsm33255996b3a.103.2025.08.13.20.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Aug 2025 20:36:54 -0700 (PDT) From: Thiago Jung Bauermann To: Markus Metzger Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids In-Reply-To: <20250805071914.3832823-1-markus.t.metzger@intel.com> (Markus Metzger's message of "Tue, 5 Aug 2025 07:19:13 +0000") References: <20250805071914.3832823-1-markus.t.metzger@intel.com> User-Agent: mu4e 1.12.11; emacs 30.1 Date: Thu, 14 Aug 2025 00:36:51 -0300 Message-ID: <87wm76zi98.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Hello Markus, Markus Metzger writes: > The special thread id '-1' means 'all threads'. > The special thread id '0' means 'any thread'. > > Read_ptid () currently returns > > .-1.0 > > and > > .0.0 > > respectively. > > Change that to minus_one_ptid for '-1' and to null_ptid for '0'. > > CC: Thiago Jung Bauermann > --- > gdbserver/remote-utils.cc | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) Nice improvement. Just a minor comment. > diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc > index 15f073dd6be..9562cc2e1fb 100644 > --- a/gdbserver/remote-utils.cc > +++ b/gdbserver/remote-utils.cc > @@ -566,6 +566,26 @@ read_ptid (const char *buf, const char **obuf) > const char *p = buf; > const char *pp; > > + /* Handle special thread ids. */ > + if (*p == '0') I think this should also check the character after '0': - if (*p == '0') + if (*p == '0' && !isxdigit (p[1])) > + { > + if (obuf) > + *obuf = p + 1; > + > + return null_ptid; > + } > + > + if (*p == '-') > + { > + if (p[1] != '1') Same here: - if (p[1] != '1') + if (p[1] != '1' || isxdigit (p[2])) > + return null_ptid; > + > + if (obuf) > + *obuf = p + 2; > + > + return minus_one_ptid; > + } > + > if (*p == 'p') > { > ULONGEST pid; >From reading the RSP documentation, thread ids are followed only by ',', ';', ':' or '\0', but checking for an hex digit should be enough. With the changes: Reviewed-by: Thiago Jung Bauermann -- Thiago