From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id X1jdAYyYeWiSZhEAWB0awg (envelope-from ) for ; Thu, 17 Jul 2025 20:42:52 -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=uj/eudw8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EB1271E11C; Thu, 17 Jul 2025 20:42:51 -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.8 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_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE 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 C2C8E1E0C2 for ; Thu, 17 Jul 2025 20:42:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E428385EC35 for ; Fri, 18 Jul 2025 00:42:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E428385EC35 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=uj/eudw8 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id B0A303858D26 for ; Fri, 18 Jul 2025 00:42:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0A303858D26 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 B0A303858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752799322; cv=none; b=dq6DuZ7lIyBFL/7nPl5javKUXDmgoEsnXmMwreVK4z2rYNdlRTTXo4ZLmG1PK6gXuGV39yYYi6QDLjY0KC8qFypORU6C6wLL+EzzP33h1/LztSSVASQCet5poiBZBp0es216YzL/JlWMfpWaAhA+kGek6Xprl7b3Fn9964SFL24= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752799322; c=relaxed/simple; bh=4BDFSVsHxRs8GQl9mYX5vY4+E3lT6O7YbUcA5jCr4mM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mDcSMAPJh5sSof27EHz4GiYiQML3jQoQLrCa49tTYD204B0p4XGFrhLrEeVV1UIYt/NYy9ekxITVIwYt2HQFBXVCRyCk7aMXAaK2JOE/tTY/Z/wrOREnGGyGpN25Fcbt9OyJmIHPqwJFZ3bJvpNajG6mYeidsbnwhh47kLAnOKg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0A303858D26 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2ffb85aed35so1159378fac.0 for ; Thu, 17 Jul 2025 17:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752799321; x=1753404121; 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=PWlaDqpA0tFqFWrRVvVuZ+xysfwwWOfH38/9M/0pAEI=; b=uj/eudw8sLaORJ4BV+X3MvvztyosCVgm/S1Ly/lyUomYNlLb6HcTEDizGatJl4LNuf CrinWoEgT0vkngv0aZVWS4CUMRMzn3FNPqfzASlAF50PhhKtqzK5OpSUMD86r1Ss5u6w Du9Uo1Jd6P1vgCTC3cJ2jAb/7kXMXqXCXvQrdTGa8QIgq13J0+joQQIpKcsoJ0V99T/h DW2UsPTzx+hMBQeiHq3CVhTqhlqPu+N/uAzQIOnHGOzCsowjDA2wIv7AhviB0nXjwdTw v4M78+MYJCeOi5GeuZxbniJGfQQ8DQjQrgABTRvpngfn0Lm6RYP07EZsf3f+Um+l2Nbn jEww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752799321; x=1753404121; 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=PWlaDqpA0tFqFWrRVvVuZ+xysfwwWOfH38/9M/0pAEI=; b=DAyBqLgrIdJMXuyDlBOnIyCPr5i5MqsEQGBbSWDKdqtlp3vCid+V8aTioo5iq7I5f8 f3p78HEQoDWLnGMaLbAgo7FpwIU4KxLpanUs3wPnh7VYtT6+vhPwATGcknPR6Cw/KiPm spy8tBjeJtY6Lz7XPKlOC8V0PFJ7fcQplLM4bvpGNMqoWitP0IHP21l/W+/3OKj7hZSI ii74PkeEGb90YHfDrkeN38Pwa78fcAkY+D1lizzSb27HuMY1hUPMJiqf1LLaTZvbGqdU xInqJH5VBWZ7tbSkUOAp9QEb1aN1t4aqRkd3IN0oQB8AMJsCI3P6IkazxlDbWuP5Y+E3 uxQg== X-Gm-Message-State: AOJu0Yzjlw2sPTs3zAGLWkvbKV+s1dBZkkXHRvXyYBoDAyCgCDK6y9nm iLYmCIlm4/EpUkYblBcJCV/piRZjysGBynilhydJVh+Dmd6BSLpL1H7sSNFf71YUyVk= X-Gm-Gg: ASbGncvIq9VgzwKhctWtXSpLgDZsw5+nMfp5FhEUU7syvXM0HNchUZtIH85KK/srQ6g NRAevcDQ2H8sE3qTj1qBY1G6pDk/hPnN77kXtkhN5leRZi9sKCxpV07mlzPl+BgWo4UQgvrAP4C ORNxuM+XUMlDnBCaiDhyLr6gjzI7zSyrIf/NPXBL7FiWlqcuwbLdscb/HpHMjDtcyZ5ruWPQ8Fv HCNMhbOHZ/bfbijOCJWfFAz5/eiq4PAV0lN9IHL1CWnmCGZvfVUu1cXeUqz+mGr4Jua+cttpPaa iJeb4gqbNaB3n39hDYVfW/4TuCPdIRzLgX+kXWTBgfhKH+TeZhZxpApoGvHg793UwNWdNKu6uu2 vZNmM8SkjDMLCYlvT0KkbXsSa1TR1RbmW X-Google-Smtp-Source: AGHT+IEm65sIhS5LbX6RRbmEpq5BgIZ0Co7wuRVtX/likkHYXnk6XHhSXOz0CIqgXhnvw4Jvn3gfVw== X-Received: by 2002:a05:6871:7991:b0:2c2:3eb4:e53 with SMTP id 586e51a60fabf-2ffaf5a7551mr5884078fac.37.1752799320878; Thu, 17 Jul 2025 17:42:00 -0700 (PDT) Received: from localhost ([2804:14d:7e39:88d6:ed08:1c86:33a3:eac6]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-301017929desm190224fac.6.2025.07.17.17.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jul 2025 17:42:00 -0700 (PDT) From: Thiago Jung Bauermann To: Tankut Baris Aktemur Cc: gdb-patches@sourceware.org, Markus Metzger Subject: Re: [PATCH v2 13/47] gdb, remote, ze: fix "$Hc-1#09...Packet received: E01" during startup In-Reply-To: <20241213-upstream-intelgt-mvp-v2-13-5c4caeb7b33d@intel.com> (Tankut Baris Aktemur's message of "Fri, 13 Dec 2024 16:59:30 +0100") References: <20241213-upstream-intelgt-mvp-v2-0-5c4caeb7b33d@intel.com> <20241213-upstream-intelgt-mvp-v2-13-5c4caeb7b33d@intel.com> User-Agent: mu4e 1.12.11; emacs 30.1 Date: Thu, 17 Jul 2025 21:41:57 -0300 Message-ID: <878qkmfhyi.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, You know you're looking at an interesting patch when the commit message is one page long, but it changes only one line. :) Regarding the subject: Can you expand a bit on what conditions cause this error to happen? Is it broken only for the ze target, or do other targets also get the error? Is it returned when, during handling of 'H', find_thread_ptid can't find the ".-1" thread? I.e., by this code? else { /* The ptid represents a lwp/tid. */ if (find_thread_ptid (thread_id) == NULL) { write_enn (cs.own_buf); break; } } Tankut Baris Aktemur writes: > From: Markus Metzger > > When opening a connection, the remote target does > > set_continue_thread (minus_one_ptid); One interesting aspect of this line is the comment above it: /* Let the stub know that we want it to return the thread. */ set_continue_thread (minus_one_ptid); What does it "the stub [...] to return the thread" mean? I tried reading in gdbserver code what it would do if it understood the Hc packet as referring to null_ptid or minus_one_ptid, but I couldn't find anything that could be described as "returning the thread". And yet it appears to be the purpose of the line above. I'd say we need someone who understands this aspect to review the patch. > which results in > > $Hc-1#09 > > to be send to gdbserver. In remote-utils.c:read_ptid (), this is read as > > { , -1, 0 } Nit: I'd say "" rather than "". > and not recognized as minus_one_ptid when handling 'H' in > > ptid_t thread_id = read_ptid (&cs.own_buf[2], NULL); > > if (thread_id == null_ptid || thread_id == minus_one_ptid) > thread_id = null_ptid; > > Since minus_one_ptid and null_ptid are treated the same way, this is > probably what we want. Not sure I understood what "this" means in the sentence. If it means "we want our Hc packet to be interpreted as thread_id == nullptid in the if condition above", then that's not what this patch does (sorry if I misunderstood). As you noted, read_ptid can't return a minus_one_ptid, but it can't return a null_ptid either. With the patch applied, read_ptid will return { , 0, 0 }, which ptid_t::is_pid () considers a PID and thus the handling of 'H' will call find_any_thread_of_pid, which I'd guess is why this patch works. > In remote_target::remote_resume_with_hc (), we do > > if (ptid == minus_one_ptid) > set_continue_thread (any_thread_ptid); > else > set_continue_thread (ptid); There's no talk of wanting the stub to "return the thread" here though. > which amounts to the same thing as set_thread () does Not exactly. In the code below, there's one more "else if" branch: > *buf++ = 'H'; > *buf++ = gen ? 'g' : 'c'; > if (ptid == magic_null_ptid) > xsnprintf (buf, endbuf - buf, "0"); > else if (ptid == any_thread_ptid) > xsnprintf (buf, endbuf - buf, "0"); else if (ptid == minus_one_ptid) xsnprintf (buf, endbuf - buf, "-1"); So remote_target::set_thread doesn't treat any_thread_ptid and minus_one_ptid the same way, even though gdbserver apparently does. Also, the doc comment of set_thread says: "If PTID is MAGIC_NULL_PTID, don't set any thread. If PTID is MINUS_ONE_PTID, set the thread to -1, so the stub returns the thread." Here's the talk about asking the stub to "return the thread" again. Frustrating. > so any_thread_ptid is pretty much the same as null_ptid and as > minus_one_ptid in this context. gdbserver appears to think so, but GDB doesn't. I'm confused. > Use any_thread_ptid to align with remote_target::remote_resume_with_hc (). > --- > gdb/remote.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/remote.c b/gdb/remote.c > index 281e616eb83008e75da8a18efaee7001ddbf6d0d..3aaa1614211d617e0d7683eade88f0d00e1bee8b 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -5284,7 +5284,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p) > target_update_thread_list (); > > /* Let the stub know that we want it to return the thread. */ > - set_continue_thread (minus_one_ptid); > + set_continue_thread (any_thread_ptid); > > if (thread_count (this) == 0) > { -- Thiago