On 2/21/24 22:10, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries writes: > > Tom> When DAP shuts down due to an EOF event, there's a race between: > Tom> - gdb's main thread handling a SIGHUP, and > Tom> - the DAP main thread exiting. > > Tom> Fix this by waiting for DAP's main thread exit during the gdb_exiting event. > > Tom> Tested on aarch64-linux. > > Thanks, this is ok. > Approved-By: Tom Tromey > Thanks for the review. > Tom> - start_thread("DAP", really_start_dap) > Tom> + # Note that we set _dap_thread in both the DAP and the GDB main thread. > Tom> + global _dap_thread > Tom> + _dap_thread = start_thread("DAP", really_start_dap) > > Tom> +@in_gdb_thread > Tom> +def _on_gdb_exiting(event): > Tom> + if _dap_thread is None: > Tom> + # This can happen if the DAP module is imported, but the server not > Tom> + # started. > Tom> + thread_log("no dap thread to join") > Tom> + return > Tom> + > Tom> + thread_log("joining dap thread ...") > Tom> + _dap_thread.join() > Tom> + thread_log("joining dap thread done") > Tom> + > Tom> + > Tom> +gdb.events.gdb_exiting.connect(_on_gdb_exiting) > > Originally I'd just pictured something like: > > local = start_thread("DAP", ...) > gdb.events.gdb_exiting.connect(local.join) > Aha, I see. > ... but wanting logging makes sense I suppose. > The global could still be removed if you care by a nested function. Done. I've also make changed the log messages to use DAP upper-case, to be in sync with other uses in the log file. Committed as attached. Thanks, - Tom