From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4c7lBlaFomgt7gUAWB0awg (envelope-from ) for ; Sun, 17 Aug 2025 21:43:50 -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=arJnHsCg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 16D881E0B3; Sun, 17 Aug 2025 21:43:50 -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 7C7221E048 for ; Sun, 17 Aug 2025 21:43:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A03A3858408 for ; Mon, 18 Aug 2025 01:43:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A03A3858408 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=arJnHsCg Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id D7B523858D1E for ; Mon, 18 Aug 2025 01:43:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7B523858D1E 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 D7B523858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755481386; cv=none; b=YIK/BKP8DJTh+3Iop1Du+7wWnTu0LwV6Xr1c5zESHXZWJfWdxwZbkTTXaMcFixQYdXz3eQe3Y5mkfhdWFriIvqBD/2fBw3AWflQ7vAvkFAAY0KZDp7xZ2Bc6Xg06goyznubbBvhsgmDcoeiuOrca7D1mK7/EZyVnMtRhYzqdqxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755481386; c=relaxed/simple; bh=xKBTfzOea49ENzgc08pbIdAXHt4BUW+oXRlcw1MP+98=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Z5oId/fKqlKmOWANQQFTpX2cPdv+/4ODFw9pA8KskawTkoc6EiLHPZ5YV5ksDxTXbJyYKlhN3Q0sIK05QzH3XXxJ5bGRmcTx2zDwhG05MWELtR1RzaqZk5zstLlSoho/Z9tLlNvqhjGKcIrwxB4/JVpBZ+/BYtMxMsyo2iO2pR4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7B523858D1E Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-b47174beb13so2611595a12.2 for ; Sun, 17 Aug 2025 18:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1755481384; x=1756086184; 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=H1OhG9IIHUWa2Cq/cOYREec6bcvwDcCvMAlGQVPf9zM=; b=arJnHsCglDutBbCwWcebAHOVjcevyxCTPI3OF/YcrkmvlILfMaTrRm5Nc7IsUcTZ4h pplZzAR+W2CGyUvh6oP4bWXPgWYTNu8H/fI00KI29hGQBbhLMjwVwZiokVuLblKtl1VI zWeFhXoYNKtxmLrChV3F9Sg8ZD6ODMa3yo1LNpV1MLJ71RW3YSCf0F9+5S8E6YIfUB24 30J3YP1aIuQ0OoPmu7PigY6BK2vIT9zSBhHZxUBpJOsFlBjWS9hz8xaUiJxZ6vvJjBL3 VWMe/Ca6VazdimjDoGsbxsTKFM+vtPGuQmJh5h+UKd3FI/qsbuCHErZg730nK5VTmId4 NqDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755481384; x=1756086184; 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=H1OhG9IIHUWa2Cq/cOYREec6bcvwDcCvMAlGQVPf9zM=; b=q4S/Ik6O4YRU33FVchs8eXPszhdZ53Mge1hyTOKbzM/e1HFYpofmJpl07ZSxTLERA8 OSn4VnEj7ZmQZN50zWzMFgHpIrkwWSw2LXzGAlIhzMlr6aB4j8S+GGOuzo1rVfcRWtwL Pj7+nUyl9lzMUSD2wXR1XvCPA+HyX0KleWp7a26QD+DQNSP7/8UFlSbKtoeP6Cf3DyoI +TvRyMkF2/aa8K/lBCOIWjYrK7KR+F5XbtmhR6WpDhF38IYaM+u/4A0RxNAv+Z/pWsIl vWdmVelkuIZZbuRUeiIF2bE3IvlaYlee5SXH7qSIpLRultOEvOB/kOGPrebUX3KbqzXZ McUw== X-Forwarded-Encrypted: i=1; AJvYcCU4u8sSP/WWpUkVJcfwbX+3X9UxrohjkG4BdcRhSVoCW+gTnoyJEHJVXK3e4cjrqPctGcIQuiNqU45fsw==@sourceware.org X-Gm-Message-State: AOJu0Yw+iRNCFMkwMe9dl3u85CWnw3sQVEKzt9YLToyUoHQr58VECRkn dYZpwLs6e4udj06sV0ujfvFYJLOnacIwxIKaR6eIHy6IbLlye8CbBGpGmv0aVMXh5BpblFf8Mlk 6HnQv X-Gm-Gg: ASbGncuqQvscre2gvsTDMammksnU2ymxOjJxeLoZLn5JNs1gDfKs4Vdz8N6o/LJhW9x KTVUpwuWpyK3WlLy8QnujdJul46M9HHlbqxIar/XdZsq4NPcc9159XTqpdfEN98UooFJOfMvgv9 xdsVpEhbelVEyQkYojWOyOUwFXOGEVLqlGJJJ7vU20MRPqzZYE1qE+OdahVhZgL6qHXho8L51DY 5kZ+Igv00qIEHrPnLd5ZB9DdOuUb6qbsPXSNoWpt7xjRD4CNatzdtQBkoX9Rmn94kfkQZ8XhJLy nRWlbtzV7YCVI8Um2WibDZ3iZLecDJXOisOGCLTFVjVuF0rzW9820vSYxJu8B0gZvEKfd6yytE0 U5ycWwwYUF0fIsbEsdXNQ567khqylW7o= X-Google-Smtp-Source: AGHT+IHLhEIHtFBROtjEVMet3aExUXL3JefWLlb/yf+054Faf6Pm/h/0pnrh7zooYeKozclJoWfeWA== X-Received: by 2002:a17:902:e790:b0:242:ffca:acff with SMTP id d9443c01a7336-2446d8c637cmr142136915ad.33.1755481383967; Sun, 17 Aug 2025 18:43:03 -0700 (PDT) Received: from localhost ([2804:14c:3d4:810f:3a09:bd6e:d091:5ec3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2446cb075b2sm65100165ad.59.2025.08.17.18.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 18:43:03 -0700 (PDT) From: Thiago Jung Bauermann To: Simon Marchi Cc: Markus Metzger , gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] gdb, remote: fix set_thread () in start_remote () In-Reply-To: (Simon Marchi's message of "Fri, 15 Aug 2025 01:33:31 -0400") References: <20250805071914.3832823-1-markus.t.metzger@intel.com> <20250805071914.3832823-2-markus.t.metzger@intel.com> <87cy8yzfu4.fsf@linaro.org> <877bz5zauo.fsf@linaro.org> User-Agent: mu4e 1.12.11; emacs 30.1 Date: Sun, 17 Aug 2025 22:43:01 -0300 Message-ID: <87a53xe76i.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 Simon Marchi writes: > On 2025-08-14 20:29, Thiago Jung Bauermann wrote: >> Simon Marchi writes: >> >>> On 8/14/25 12:29 AM, Thiago Jung Bauermann wrote: >>>> Markus Metzger writes: >>>>> - set_continue_thread (minus_one_ptid); >>>>> + set_general_thread (any_thread_ptid); >>>>> >>>>> if (thread_count (this) == 0) >>>>> { >>>> >>>> Also, your explanation implies that the doc comment in >>>> remote_target::set_thread isn't quite right. What about changing it to >>>> something along the following lines? >>>> >>>> -/* 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. If GEN is set, set the general thread, if not, then set >>>> - the step/continue thread. */ >>>> +/* If PTID is MAGIC_NULL_PTID or ANY_THREAD_PTID, set the thread to 0. >>>> + If PTID is MINUS_ONE_PTID, set the thread to -1. If GEN is set, set >>>> + the general thread, if not, then set the step/continue thread. If >>>> + the thread is 0 or -1 and GEN is set, the stub returns the thread in >>>> + the qC packet reply. */ >>> >>> The parts "set the thread to 0" and "set the thread to -1" seem not very >>> useful to me. What does that mean concretely? It would be more useful >>> to explain what that instruct the remote target to do. >>> >>> My understanding is that passing either MAGIC_NULL_PTID or >>> ANY_THREAD_PTID will result in sending `Hg0` or `Hc0`. Passing >>> MINUS_ONE_PTID will result in sending `Hg-1` or `Hc-1`. >>> >>> On the other side, all of these will result in variable THREAD_ID being >>> set to null_ptid. For Hg, we'll arbitrarily pick the first thread. For >>> Hc, we'll set cs.cont_thread to null_ptid. >>> >>> Does that sound right? >> >> For gdbserver, yes. My main doubt is whether we can assume other stubs >> "out there" behave the same way or do they treat Hg0 and Hg-1 >> differently? The comment and code in remote_target::set_thread assume >> the latter, so is that a bug? > > About the other stubs: I can't really help you there, I think the answer > is that we'll never really know. > > Can you clarify what you think might be a bug? I'm a bit concerned that GDB's remote_target::set_thread considers Hg-1 and Hg0 to be different things (doesn't say how they are different though) while gdbserver's process_serial_event handling of the H packet treats them as synonyms. I think that's strange, and was wondering if anyone knew why. Maybe they just diverged without any practical consequence and we can just bring them back to sync. Or maybe gdbserver changed its behaviour but there are stubs out there that didn't. This patches changes GDB from sending Hc-1 to Hg0. For gdbserver, the change from -1 to 0 is meaningless. My question is whether we can assume it will be meaningless to other stubs as well. But I agree that we'll never really know, and if we just keep all the RSP warts forever it will be hard to maintain and evolve it. All this was just a long way of saying that I wanted to add my Reviewed-by to this patch but I don't feel confident enough to do it. -- Thiago