From patchwork Tue Mar 20 09:39:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: KONRAD Frederic X-Patchwork-Id: 10296727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5FB4060349 for ; Tue, 20 Mar 2018 09:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50A722905E for ; Tue, 20 Mar 2018 09:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B66729552; Tue, 20 Mar 2018 09:40:52 +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=-6.9 required=2.0 tests=BAYES_00,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 A8AAC2931B for ; Tue, 20 Mar 2018 09:40:51 +0000 (UTC) Received: from localhost ([::1]:47066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyDlD-0005oC-1B for patchwork-qemu-devel@patchwork.kernel.org; Tue, 20 Mar 2018 05:40:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyDkR-0005Lt-7x for qemu-devel@nongnu.org; Tue, 20 Mar 2018 05:40:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyDkO-0006YI-56 for qemu-devel@nongnu.org; Tue, 20 Mar 2018 05:40:03 -0400 Received: from mel.act-europe.fr ([2a02:2ab8:224:1::a0a:d2]:52725 helo=smtp.eu.adacore.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyDkN-0006XG-UL for qemu-devel@nongnu.org; Tue, 20 Mar 2018 05:40:00 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 7344D81380; Tue, 20 Mar 2018 10:39:58 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at eu.adacore.com Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SW83WxTJ2-Rf; Tue, 20 Mar 2018 10:39:58 +0100 (CET) Received: from localhost.localdomain (unknown [46.218.167.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id ED94D81368; Tue, 20 Mar 2018 10:39:57 +0100 (CET) From: KONRAD Frederic To: qemu-devel@nongnu.org Date: Tue, 20 Mar 2018 10:39:33 +0100 Message-Id: <1521538773-30802-1-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2a02:2ab8:224:1::a0a:d2 Subject: [Qemu-devel] [PATCH v2 for-2.12] gdbstub: send a termination packet instead of crashing gdb 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@linaro.org, KONRAD Frederic , f4bug@amsat.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since the commit: commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 Author: Stefan Hajnoczi Date: Wed Mar 7 14:42:05 2018 +0000 vl: introduce vm_shutdown() GDB crashes when qemu exits (at least on sparc-softmmu): Remote communication error. Target disconnected.: Connection reset by peer. Quitting: putpkt: write failed: Broken pipe. So send a packet to exit GDB before we exit QEMU: [Inferior 1 (Thread 0) exited normally] Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi Signed-off-by: KONRAD Frederic --- Notes: V1 -> V2: * fix typos * mark the patch for-2.12 gdbstub.c | 7 +++++++ include/exec/gdbstub.h | 2 ++ vl.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index f1d5148..a76b2fa 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2052,6 +2052,13 @@ int gdbserver_start(const char *device) return 0; } +void gdbserver_cleanup(void) +{ + if (gdbserver_state) { + put_packet(gdbserver_state, "W00"); + } +} + static void register_types(void) { type_register_static(&char_gdb_type_info); diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 9aa7756..2e8a4b8 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -103,6 +103,8 @@ int gdbserver_start(int); int gdbserver_start(const char *port); #endif +void gdbserver_cleanup(void); + /** * gdb_has_xml: * This is an ugly hack to cope with both new and old gdb. diff --git a/vl.c b/vl.c index 19340a3..cd8d5cb 100644 --- a/vl.c +++ b/vl.c @@ -4725,6 +4725,8 @@ int main(int argc, char **argv, char **envp) main_loop(); + gdbserver_cleanup(); + /* No more vcpu or device emulation activity beyond this point */ vm_shutdown();