From patchwork Fri Dec 7 09:01:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Michel X-Patchwork-Id: 10717737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25A3013AF for ; Fri, 7 Dec 2018 09:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1009E2E2F8 for ; Fri, 7 Dec 2018 09:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 003D42E307; Fri, 7 Dec 2018 09:28:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7674F2E2F8 for ; Fri, 7 Dec 2018 09:28:59 +0000 (UTC) Received: from localhost ([::1]:44996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVCRO-0004zT-OV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Dec 2018 04:28:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1g-0008HO-Oe for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVC1g-0005jB-1C for qemu-devel@nongnu.org; Fri, 07 Dec 2018 04:02:24 -0500 Received: from greensocs.com ([193.104.36.180]:52242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVC1V-0005Ri-Ty; Fri, 07 Dec 2018 04:02:14 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9820F480011; Fri, 7 Dec 2018 10:01:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173313; bh=RPkbYyBWNUGrWYZaWMQlv7h8yEdRqMYHulS2VqaUjoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rA56IWwgBHr9j59Zek0LLjpcfD5GLTWuwhG3i876jGpEqfW0heTiLt7PiiIColDDI X4qpNQghpRT/9h1ak8PQ4sIUfN80GusUcGmvOAKRlIxybhrrg2PVXQOAfiBrIeXa37 reYn8eh/fZ+ojqr6lZaRMfSQjw3XS7AwWMlUd2X8= 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=WIXn2w0l; dkim=pass (1024-bit key) header.d=greensocs.com header.b=WIXn2w0l 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 JcsXwgtsNnOg; Fri, 7 Dec 2018 10:01:52 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id 337B248003C; Fri, 7 Dec 2018 10:01:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=RPkbYyBWNUGrWYZaWMQlv7h8yEdRqMYHulS2VqaUjoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WIXn2w0lWY5USmn6nfhFCZ9WYVZQ2DlB03KTTF/9puLw1BXdvMiPpGTycDBznDynu F7Y8EdBOWg7l6btgUcUnL2zz+ZcObfcmZTNf6lLOaBhVCHEa+N2rH0q39QU7m0Uve6 55O+MKNu6m3tIkMCpSkJc3pB3TULuRpjiEfgrH24= 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 B5077480013; Fri, 7 Dec 2018 10:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1544173307; bh=RPkbYyBWNUGrWYZaWMQlv7h8yEdRqMYHulS2VqaUjoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WIXn2w0lWY5USmn6nfhFCZ9WYVZQ2DlB03KTTF/9puLw1BXdvMiPpGTycDBznDynu F7Y8EdBOWg7l6btgUcUnL2zz+ZcObfcmZTNf6lLOaBhVCHEa+N2rH0q39QU7m0Uve6 55O+MKNu6m3tIkMCpSkJc3pB3TULuRpjiEfgrH24= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 10:01:32 +0100 Message-Id: <20181207090135.7651-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207090135.7651-1-luc.michel@greensocs.com> References: <20181207090135.7651-1-luc.michel@greensocs.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v8 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- gdbstub.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 81e7742847..48b49195f7 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1796,10 +1796,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