Skip to contentSkip to conversation

gdbstub: send a termination packet instead of crashing gdb

PATCH Applied KONRAD Frederic 2 participants 3 messages Mar 20, 2018 – Mar 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gdbstub: send a termination packet instead of crashing gdb

Since the commit:
commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268

Author: Stefan Hajnoczi <[email protected]>
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]

---

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(+)
gdbstub.c +7 -0
index f1d5148..a76b2fa 100644
@@ -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);
include/exec/gdbstub.h +2 -0
index 9aa7756..2e8a4b8 100644
@@ -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.
vl.c +2 -0
index 19340a3..cd8d5cb 100644
@@ -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();
 
Signature · 1 line
1.8.3.1
#1 lore raw

Peter, can this be cherry-picked in 2.12-rc1?

Thanks,
Fred

Quoted 74 lines · KONRAD Frederic

Since the commit:
commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268

Author: Stefan Hajnoczi <[email protected]>
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]

---

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(+)
gdbstub.c +7 -0
index f1d5148..a76b2fa 100644
@@ -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);
include/exec/gdbstub.h +2 -0
index 9aa7756..2e8a4b8 100644
@@ -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.
vl.c +2 -0
index 19340a3..cd8d5cb 100644
@@ -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();
 
#2 lore raw
Quoted 27 lines · KONRAD Frederic

Peter, can this be cherry-picked in 2.12-rc1?

Thanks,
Fred

Quoted 20 lines · KONRAD Frederic

Since the commit:
commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268

Author: Stefan Hajnoczi <[email protected]>
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]

---

Applied to master, thanks.

-- PMM