[PATCH 8/8] [gdb/dap] Fix race between dap exit and gdb exit
Tom de Vries
tdevries@suse.de
Wed Feb 21 13:39:31 GMT 2024
On 2/20/24 16:51, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> +@in_gdb_thread
> Tom> +def _on_gdb_exiting(event):
> Tom> + dap_thread_join()
>
> I think it's better not to export dap_thread_join and then import it
> here, but instead just add to the event listener exactly where it's
> needed.
>
Done in a v2.
> Tom> + global _dap_thread_for_gdb_thread
> Tom> + _dap_thread_for_gdb_thread = start_thread("DAP", really_start_dap)
>
> You don't even need a new global if you add the listener here.
>
OK, reverted back to using _dap_thread in a v2.
> Tom> +def dap_thread_join():
> Tom> + global _dap_thread_for_gdb_thread
> Tom> + if _dap_thread_for_gdb_thread != None:
>
> None of this will be necessary with the above, but FYI in Python it's
> idiomatic to do this comparison with "if blah is not None"
When running test-case gdb.dap/type_check.exp, the dap module is
imported, but no server is started and consequently there's no dap
thread. If we don't test for none here, we get a python exception
telling us that None doesn't support join.
In the v2, I've rewritten this into an early exit with a comment to make
it more clear.
Thanks,
- Tom
More information about the Gdb-patches
mailing list