From patchwork Sun Aug 6 03:36:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 710886 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:d30:b0:129:c516:61db with SMTP id gp48csp827147rwb; Sat, 5 Aug 2023 20:43:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/0vUJEz88CjRPTJZ6RaKrA9AbonpFr1fesI3eM1QP03Kc8TObkq/A69WKJNIfGO4LfrTj X-Received: by 2002:ac8:5c13:0:b0:403:f45d:6baa with SMTP id i19-20020ac85c13000000b00403f45d6baamr8141533qti.32.1691293381104; Sat, 05 Aug 2023 20:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691293381; cv=none; d=google.com; s=arc-20160816; b=nno/WLTrqdp33qs6O8YfTy6LQ/Am1x8Em0mhx0kd9FjfFNgO+5+3feYGd/i4/rDTOn Pa/VOh6iBJLiuB6yteVzG7AoBlLGty66vPK+UDss3iIVDjykm92RNqcyWeziB13jXw6s 8nTBFmvlcuZItnEHfcKzna03o03vW5opA30NcxcnosmRIWtXVpdeyroPn6lWuDO4E/Ew 2hVA9ZfeGioq+zYB/zFIDqWaiGzLF8BlsVvGlbIwbXe0MxtFKCU0fVY2kwBuiAmEaJj1 hMiUwg6CAnJwLHt7V70q6Qi6pZ4t5GguvgiK2d8IYchQ4u0ZNTXFoFhWnecz7yP0fRvp grFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PGTKa1g9aGwPuG4tk4crlE1qhIW/f2V62gcPYilpvuU=; fh=2tnQCPLqmUYA/BoQGVU30HXpDTpJUwyLa9MIUyZ/Rgw=; b=YoqYT354AT8xS3yid9FRegEMoWQuwLntKt2PQSkeyJiZPpHwW9BMDRgE9cXD/E1OV6 V8B0gD7KVx08lPpZNNm47JRiJcxPn+/ltdWfBo4tocB382bo3TDKYdn2qIo4v+RVYfge LqFE2Ans/O4ulQRf0ogbjwjJpYxRG4o/sTVqHs9m/aNw4oJvDHNMcKqP9ZkGDC/9tSg4 AteShW3+oQZWU2+FTgu1aDeF5aQ10vL1DWUZk0sTUqsguIG0LKBafV/Yhx/CUqQdNp23 oawu8xEXv+pWB3V3xdTsGBwYj5MBD4qzTr6ZhOGpFzQoEvS61Ixx32HIahc5xo+PNKrf PO0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eRiAju0g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b3-20020ac87fc3000000b003e384f9d039si3445114qtk.336.2023.08.05.20.43.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 05 Aug 2023 20:43:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eRiAju0g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qSUa4-0003cu-PS; Sat, 05 Aug 2023 23:37:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qSUa2-0003Zt-6S for qemu-devel@nongnu.org; Sat, 05 Aug 2023 23:37:22 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qSUa0-0007WF-KK for qemu-devel@nongnu.org; Sat, 05 Aug 2023 23:37:21 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-26854159c05so1828867a91.2 for ; Sat, 05 Aug 2023 20:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691293039; x=1691897839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PGTKa1g9aGwPuG4tk4crlE1qhIW/f2V62gcPYilpvuU=; b=eRiAju0gWTsQuqYxsso8xl9xzggXxTNAthvnXoONu8Tuh9SHwwk25DNtJhb0hJALrC aki3q16tBtJTrgm+AOUwqkedhD/TH0q9UTQ9tC1PUCPPrQYJWIlOJcv6995zPR7ie3Sf y3OsuEvKI1ePtLM2qeqxfuH+6RLQDk77Oe0jfU4pbakcnVOqvYiFHFm6Tb14hK23z3Wd 0QuDjtLcg4YAGc5bZknZJb2B/M24M0zz4Hb0SaRMh0Sn+FVfY5atfJpbdqxU0Z+nHtku 52EEL7RxwuRAIy5qnCnmI5+isRqNMEg7EOZh6BtsL58Sg9PawMim+yNs0Gvs0xDcT/oI 4mSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691293039; x=1691897839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PGTKa1g9aGwPuG4tk4crlE1qhIW/f2V62gcPYilpvuU=; b=e3xCvMPR2QvU0ZoGjkYvZTlhoRm648rtGIx0WjljAHXtdkKetNwuPOZLKnGFGyoX3z ak5ZjbpAy1sEYnAwsJiY7kZSU/igRUHaMxX7L8OKqL9MaR1vOFscM+dtnTy5C6sNTTvk GTuQM1XwspzMFcjsXoQ/KcHyTmTP7JaLTEhahUAAdR6z8L/7AmhQNHYIc6WlrWK0pD4A u1CuhJ7RmnDtNT8WT23KhM84VzBm9FTJxvUEt9CoVXvKlngWjjjdsyj38CK7fLzSqejP Nr/KZIVX7sc5tTQ/83nSthD0WfaYyGWGMEVOKfPn5tcNtyxkIzWJxHiFoM6zaqCby7UR AoLg== X-Gm-Message-State: AOJu0YzdClTiHQKhw0n2b892g2EYbMWC6iRvUq9LfYB/NI+rHu/vKoKR XZm3XYFiIamDvnLeqeNwzKly/GmvGazZ2sGl178= X-Received: by 2002:a17:90b:3755:b0:263:fc43:5f39 with SMTP id ne21-20020a17090b375500b00263fc435f39mr4295795pjb.13.1691293039417; Sat, 05 Aug 2023 20:37:19 -0700 (PDT) Received: from stoup.. ([2602:47:d490:6901:9454:a46f:1c22:a7c6]) by smtp.gmail.com with ESMTPSA id a5-20020a17090a740500b00262e604724dsm6306451pjg.50.2023.08.05.20.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Aug 2023 20:37:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Matheus Tavares Bernardino , Ilya Leoshkevich Subject: [PULL 04/24] gdbstub: use 0 ("any process") on packets with no PID Date: Sat, 5 Aug 2023 20:36:55 -0700 Message-Id: <20230806033715.244648-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230806033715.244648-1-richard.henderson@linaro.org> References: <20230806033715.244648-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Matheus Tavares Bernardino Previously, qemu-user would always report PID 1 to GDB. This was changed at dc14a7a6e9 (gdbstub: Report the actual qemu-user pid, 2023-06-30), but read_thread_id() still considers GDB packets with "no PID" as "PID 1", which is not the qemu-user PID. Fix that by parsing "no PID" as "0", which the GDB Remote Protocol defines as "any process". Note that this should have no effect for system emulation as, in this case, gdb_create_default_process() will assign PID 1 for the first process and that is what the gdbstub uses for GDB requests with no PID, or PID 0. This issue was found with hexagon-lldb, which sends a "Hg" packet with only the thread-id, but no process-id, leading to the invalid usage of "PID 1" by qemu-hexagon and a subsequent "E22" reply. Signed-off-by: Matheus Tavares Bernardino Acked-by: Ilya Leoshkevich Message-Id: <78a3b06f6ab90a7ff8e73ae14a996eb27ec76c85.1690904195.git.quic_mathbern@quicinc.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- gdbstub/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ce8b42eb15..e74ecc78cc 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -537,7 +537,7 @@ static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, /* Skip '.' */ buf++; } else { - p = 1; + p = 0; } ret = qemu_strtoul(buf, &buf, 16, &t);