public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Explicitly quit gdb from DAP server thread
@ 2024-02-27 17:38 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-02-27 17:38 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b452b96c1e57db42d50a42eb2f09f7c57681d073

commit b452b96c1e57db42d50a42eb2f09f7c57681d073
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Feb 23 13:51:58 2024 -0700

    Explicitly quit gdb from DAP server thread
    
    This changes the DAP code to explicitly request that gdb exit.
    Previously this could cause crashes, but with the previous cleanups,
    this should no longer happen.
    
    This also adds a tests that ensures that gdb exits with status 0.

Diff:
---
 gdb/python/lib/gdb/dap/server.py  | 1 +
 gdb/testsuite/lib/dap-support.exp | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index 6757f2921bf..19840f4028d 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -230,6 +230,7 @@ class Server:
         # responses are flushed to the client before exiting.
         self.write_queue.put(None)
         json_writer.join()
+        send_gdb("quit")
 
     @in_dap_thread
     def send_event_later(self, event, body=None):
diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index 89a4b0e0f6d..61355b56fee 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -403,6 +403,15 @@ proc dap_check_log_file_re { re } {
 proc dap_shutdown {{terminate false}} {
     dap_check_request_and_response "shutdown" disconnect \
 	[format {o terminateDebuggee [l %s]} $terminate]
+
+    # Check gdb's exit status.
+    global gdb_spawn_id
+    set result [wait -i $gdb_spawn_id]
+    gdb_assert {[lindex $result 2] == 0}
+    gdb_assert {[lindex $result 3] == 0}
+
+    clear_gdb_spawn_id
+
     dap_check_log_file
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-27 17:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 17:38 [binutils-gdb] Explicitly quit gdb from DAP server thread Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).