diff options
author | Tom de Vries <tdevries@suse.de> | 2024-02-22 11:35:26 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-02-22 11:35:26 +0100 |
commit | 706c6624c26b2c954713c872021594bd3a156dd3 (patch) | |
tree | 9abd6faefe6e5936a48031e591c541328c8809c0 /gdb/python | |
parent | 05bf17f03b890424312163463754de63cee73074 (diff) | |
download | binutils-706c6624c26b2c954713c872021594bd3a156dd3.zip binutils-706c6624c26b2c954713c872021594bd3a156dd3.tar.gz binutils-706c6624c26b2c954713c872021594bd3a156dd3.tar.bz2 |
[gdb/dap] Fix race between dap exit and gdb exit
When DAP shuts down due to an EOF event, there's a race between:
- gdb's main thread handling a SIGHUP, and
- the DAP main thread exiting.
Fix this by waiting for DAP's main thread exit during the gdb_exiting event.
Tested on aarch64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR dap/31380
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31380
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/dap/startup.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py index 29fe78e..a2b6899 100644 --- a/gdb/python/lib/gdb/dap/startup.py +++ b/gdb/python/lib/gdb/dap/startup.py @@ -93,7 +93,15 @@ def start_dap(target): _dap_thread = threading.current_thread() target() - start_thread("DAP", really_start_dap) + # Note: unlike _dap_thread, dap_thread is a local variable. + dap_thread = start_thread("DAP", really_start_dap) + + def _on_gdb_exiting(event): + thread_log("joining DAP thread ...") + dap_thread.join() + thread_log("joining DAP thread done") + + gdb.events.gdb_exiting.connect(_on_gdb_exiting) def in_gdb_thread(func): |