]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/dap] Join JSON writer thread with DAP thread
authorTom de Vries <tdevries@suse.de>
Wed, 21 Feb 2024 09:46:08 +0000 (10:46 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 21 Feb 2024 09:46:08 +0000 (10:46 +0100)
commit7c34de9efdb13fff482ed0c4de0dffee1e1880f3
tree3e7a7afec26c765ca497614b1fe13058b9d91c45
parentd61933410868ff2dd52a896520a2b620d35f3615
[gdb/dap] Join JSON writer thread with DAP thread

The DAP interpreter runs in its own thread, and starts a few threads:
- the JSON reader thread,
- the JSON writer thread, and
- the inferior output reader thread.

As part of the DAP shutdown, both the JSON reader thread and the JSON writer
thread, as well as the DAP main thread run to exit, but these exits are not
ordered in any way.

Wait in the main DAP thread for the exit of the JSON writer thread.

This makes sure that the responses are flushed to the DAP client before DAP
shutdown.

An earlier version of this patch used Queue.task_done() to accomplish the
same, but that didn't guarantee writing the "<thread name>: terminating"
log entry from thread_wrapper before DAP shutdown.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR dap/31380
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31380
gdb/python/lib/gdb/dap/io.py
gdb/python/lib/gdb/dap/server.py
gdb/python/lib/gdb/dap/startup.py