]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
gdbstub: send a termination packet instead of crashing gdb
authorKONRAD Frederic <frederic.konrad@adacore.com>
Tue, 20 Mar 2018 09:39:33 +0000 (10:39 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 27 Mar 2018 20:16:27 +0000 (21:16 +0100)
Since the commit:
commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268
Author: Stefan Hajnoczi <stefanha@redhat.com>
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é <f4bug@amsat.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
Message-id: 1521538773-30802-1-git-send-email-frederic.konrad@adacore.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
gdbstub.c
include/exec/gdbstub.h
vl.c

index f1d51480f79d3604f5089a6684066e21740081f3..a76b2fa481acd318adf338909a6cf7e5a120af81 100644 (file)
--- 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);
index 9aa7756d929f1ef69c02cdc69cd335bf5b29c477..2e8a4b83b95faf88f240831d9f6bf30a5b536d1f 100644 (file)
@@ -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 5fd01bd5f69020f5457dd7bda1fe63d51caee07c..fce1fd12d8b73ad45d072b5dd47aee88b310a88a 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4733,6 +4733,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();