]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Explicitly quit gdb from DAP server thread
authorTom Tromey <tromey@adacore.com>
Fri, 23 Feb 2024 20:51:58 +0000 (13:51 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 27 Feb 2024 17:30:30 +0000 (10:30 -0700)
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.

gdb/python/lib/gdb/dap/server.py
gdb/testsuite/lib/dap-support.exp

index 6757f2921bf5d2a9a10de80cf337ec46beca969c..19840f4028d3b2a4bc5194a8c9a3118ac9707852 100644 (file)
@@ -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):
index 89a4b0e0f6d7b42ef8d0f90c239de25ce6bc213d..61355b56fee70f43b3e637dc4eed4f2c09e2fac2 100644 (file)
@@ -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
 }