File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 2626#include " llvm/ADT/StringMap.h"
2727#include " llvm/ADT/StringRef.h"
2828#include " llvm/Support/JSON.h"
29+ #include " llvm/Support/Threading.h"
2930#include " llvm/Support/raw_ostream.h"
3031
3132#include " lldb/API/SBAttachInfo.h"
@@ -169,6 +170,7 @@ struct DAP {
169170 std::optional<llvm::json::Object> last_launch_or_attach_request;
170171 lldb::tid_t focus_tid;
171172 bool disconnecting = false ;
173+ llvm::once_flag terminated_event_flag;
172174 bool stop_at_entry;
173175 bool is_attach;
174176 bool enable_auto_variable_summaries;
Original file line number Diff line number Diff line change @@ -227,13 +227,12 @@ void SendContinuedEvent() {
227227// debugged.
228228void SendTerminatedEvent () {
229229 // Prevent races if the process exits while we're being asked to disconnect.
230- static std::mutex mutex;
231- std::lock_guard<std::mutex> locker (mutex);
232-
233- g_dap.RunTerminateCommands ();
234- // Send a "terminated" event
235- llvm::json::Object event (CreateTerminatedEventObject ());
236- g_dap.SendJSON (llvm::json::Value (std::move (event)));
230+ llvm::call_once (g_dap.terminated_event_flag , [&] {
231+ g_dap.RunTerminateCommands ();
232+ // Send a "terminated" event
233+ llvm::json::Object event (CreateTerminatedEventObject ());
234+ g_dap.SendJSON (llvm::json::Value (std::move (event)));
235+ });
237236}
238237
239238// Send a thread stopped event for all threads as long as the process
You can’t perform that action at this time.
0 commit comments