From patchwork Fri Mar 16 16:23:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: KONRAD Frederic X-Patchwork-Id: 10289063 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 ADDC2601BE for ; Fri, 16 Mar 2018 16:24:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E81428FCD for ; Fri, 16 Mar 2018 16:24:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92F9728FD0; Fri, 16 Mar 2018 16:24:18 +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 BA78428FCD for ; Fri, 16 Mar 2018 16:24:17 +0000 (UTC) Received: from localhost ([::1]:58417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ews9Q-00036g-Ba for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Mar 2018 12:24:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ews8l-00036J-1J for qemu-devel@nongnu.org; Fri, 16 Mar 2018 12:23:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ews8h-0007b8-QA for qemu-devel@nongnu.org; Fri, 16 Mar 2018 12:23:35 -0400 Received: from mel.act-europe.fr ([2a02:2ab8:224:1::a0a:d2]:50209 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 1ews8h-0007Yc-Jb for qemu-devel@nongnu.org; Fri, 16 Mar 2018 12:23:31 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 10A39818CC; Fri, 16 Mar 2018 17:23:29 +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 yDYel0N2wlZ2; Fri, 16 Mar 2018 17:23:28 +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 C326D80004; Fri, 16 Mar 2018 17:23:28 +0100 (CET) From: KONRAD Frederic To: qemu-devel@nongnu.org Date: Fri, 16 Mar 2018 17:23:13 +0100 Message-Id: <1521217393-8162-1-git-send-email-frederic.konrad@adacore.com> X-Mailer: git-send-email 1.8.3.1 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] gdbstub: send a terminaison 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: frederic.konrad@adacore.com, famz@redhat.com, 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 crash 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 kill GDB before we exit QEMU: [Inferior 1 (Thread 0) exited normally] Signed-off-by: KONRAD Frederic Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- 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 3ef04ce..0427b15 100644 --- a/vl.c +++ b/vl.c @@ -4723,6 +4723,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();