From patchwork Fri Oct 26 08:16:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 989496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.b="iKZRF2jS"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="fSNzYhn8"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="fSNzYhn8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42hHPH5P9Vz9s3C for ; Fri, 26 Oct 2018 19:35:15 +1100 (AEDT) Received: from localhost ([::1]:58828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxaL-0008As-9O for incoming@patchwork.ozlabs.org; Fri, 26 Oct 2018 04:35:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxUD-0000LS-5R for qemu-devel@nongnu.org; Fri, 26 Oct 2018 04:28:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFxJY-0004yZ-K0 for qemu-devel@nongnu.org; Fri, 26 Oct 2018 04:17:53 -0400 Received: from greensocs.com ([193.104.36.180]:45408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFxJT-0004ll-QZ; Fri, 26 Oct 2018 04:17:48 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 74585441B45; Fri, 26 Oct 2018 10:17:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541841; bh=rD9a4K7ZyB7rSOPQ+3dwrMRt9gvBTShbRNlnFXihPlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iKZRF2jSa8Dvgxj1HmbX0oro1Egggd2a+3KqU2pgP9qmZpcbr4ZqwqblK8/MgC9Nn DhyM81urJ+acT5Kd12uuEgYrAVdpzp83teFemZoH1rqya7uWqeqTDiZPEWQDE98lkt dzggl1vlgjroXkCuvlqy/yNAfenP6xKXMWyLfJ0U= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=fSNzYhn8; dkim=pass (1024-bit key) header.d=greensocs.com header.b=fSNzYhn8 Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LXxh8FMbAaEE; Fri, 26 Oct 2018 10:17:20 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id D2A99441B53; Fri, 26 Oct 2018 10:17:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541838; bh=rD9a4K7ZyB7rSOPQ+3dwrMRt9gvBTShbRNlnFXihPlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fSNzYhn8i4NeRzAk1dRhJMCAMbpVdVUOgxqdxVEp4pxkK+eJjulSV6erlgN8g/C4A sthT7Myv315hH12Znv2FLq6FHKMQc+2ZNetkpFE3B6wrYJ22TuPcgaR2Ydd5xz3hdJ ighLMjOSdFXf/c1jshD/qh11iJxNy9Z5Z5S/6ikQ= Received: from michell-laptop.home.lmichel.fr (lfbn-1-8165-82.w90-112.abo.wanadoo.fr [90.112.74.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 621B2441B44; Fri, 26 Oct 2018 10:17:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1540541838; bh=rD9a4K7ZyB7rSOPQ+3dwrMRt9gvBTShbRNlnFXihPlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fSNzYhn8i4NeRzAk1dRhJMCAMbpVdVUOgxqdxVEp4pxkK+eJjulSV6erlgN8g/C4A sthT7Myv315hH12Znv2FLq6FHKMQc+2ZNetkpFE3B6wrYJ22TuPcgaR2Ydd5xz3hdJ ighLMjOSdFXf/c1jshD/qh11iJxNy9Z5Z5S/6ikQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2018 10:16:51 +0200 Message-Id: <20181026081653.24602-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026081653.24602-1-luc.michel@greensocs.com> References: <20181026081653.24602-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v3 14/16] gdbstub: gdb_set_stop_cpu: ignore request when process is not attached X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , alistair@alistair23.me, mark.burton@greensocs.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Luc Michel Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 get confused if it receives packets with a thread-id it does not know about. Signed-off-by: Luc Michel Acked-by: Alistair Francis --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index b3461eff9e..09480df2bf 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1784,10 +1784,19 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) return RS_IDLE; } 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; } #ifndef CONFIG_USER_ONLY