File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 26
26
#include " llvm/ADT/StringMap.h"
27
27
#include " llvm/ADT/StringRef.h"
28
28
#include " llvm/Support/JSON.h"
29
+ #include " llvm/Support/Threading.h"
29
30
#include " llvm/Support/raw_ostream.h"
30
31
31
32
#include " lldb/API/SBAttachInfo.h"
@@ -169,6 +170,7 @@ struct DAP {
169
170
std::optional<llvm::json::Object> last_launch_or_attach_request;
170
171
lldb::tid_t focus_tid;
171
172
bool disconnecting = false ;
173
+ llvm::once_flag terminated_event_flag;
172
174
bool stop_at_entry;
173
175
bool is_attach;
174
176
bool enable_auto_variable_summaries;
Original file line number Diff line number Diff line change @@ -227,13 +227,12 @@ void SendContinuedEvent() {
227
227
// debugged.
228
228
void SendTerminatedEvent () {
229
229
// 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
+ });
237
236
}
238
237
239
238
// 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