From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:46437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXod-00053O-4E for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggXoY-00026T-Ph for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:50 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:52648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggXoY-0001xm-Bq for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:46 -0500 Received: by mail-wm1-x335.google.com with SMTP id m1so1470079wml.2 for ; Mon, 07 Jan 2019 08:31:41 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id j14sm46039759wrv.96.2019.01.07.08.31.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:31:39 -0800 (PST) From: Peter Maydell Date: Mon, 7 Jan 2019 16:30:56 +0000 Message-Id: <20190107163117.16269-17-peter.maydell@linaro.org> In-Reply-To: <20190107163117.16269-1-peter.maydell@linaro.org> References: <20190107163117.16269-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 16/37] gdbstub: gdb_set_stop_cpu: ignore request when process is not attached List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Luc Michel When gdb_set_stop_cpu() is called with a CPU associated to a process currently not attached by the GDB client, return without modifying the stop CPU. Otherwise, GDB gets confused if it receives packets with a thread-id it does not know about. Signed-off-by: Luc Michel Acked-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Message-id: 20181207090135.7651-15-luc.michel@greensocs.com [PMM: fix checkpatch comment style nit] Signed-off-by: Peter Maydell --- gdbstub.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 432e7d2f7da..1517563abe1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1798,6 +1798,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) void gdb_set_stop_cpu(CPUState *cpu) { + GDBProcess *p = gdb_get_cpu_process(gdbserver_state, cpu); + + if (!p->attached) { + /* + * Having a stop CPU corresponding to a process that is not attached + * confuses GDB. So we ignore the request. + */ + return; + } + gdbserver_state->c_cpu = cpu; gdbserver_state->g_cpu = cpu; } -- 2.19.2