summary refs log tree commit diff stats
path: root/gdbstub.c
diff options
context:
space:
mode:
authorKONRAD Frederic <frederic.konrad@adacore.com>2018-03-20 10:39:33 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-03-27 21:16:27 +0100
commit1bb982b8fc2f98246d47c83833c20bf858d649f4 (patch)
tree6edad159cb1232a1bf371fc1f21dda3b55be5d33 /gdbstub.c
parentf55e88f2ab09e9348b0d1d233acd9518a7570f16 (diff)
downloadfocaccia-qemu-1bb982b8fc2f98246d47c83833c20bf858d649f4.tar.gz
focaccia-qemu-1bb982b8fc2f98246d47c83833c20bf858d649f4.zip
gdbstub: send a termination packet instead of crashing gdb
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>
Diffstat (limited to 'gdbstub.c')
-rw-r--r--gdbstub.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdbstub.c b/gdbstub.c
index f1d51480f7..a76b2fa481 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);