https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/209264

>From 55a842e32bdfc3bef26d32916a85b5a5384711a8 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <[email protected]>
Date: Mon, 13 Jul 2026 19:16:27 +0100
Subject: [PATCH 1/3] [lldb-dap] Simplify DAPSessionManager GetInstance

We don't need the `std::call_once` as this guaranteed to be
thread safe and initialized once.
I also don't see any issue with the destructor chain since the class
doesn't own any data that can be affected.
---
 lldb/tools/lldb-dap/DAPSessionManager.cpp | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAPSessionManager.cpp 
b/lldb/tools/lldb-dap/DAPSessionManager.cpp
index 580d4fa102a89..91c0538e63d5f 100644
--- a/lldb/tools/lldb-dap/DAPSessionManager.cpp
+++ b/lldb/tools/lldb-dap/DAPSessionManager.cpp
@@ -33,14 +33,8 @@ ManagedEventThread::~ManagedEventThread() {
 }
 
 DAPSessionManager &DAPSessionManager::GetInstance() {
-  static std::once_flag initialized;
-  static DAPSessionManager *instance =
-      nullptr; // NOTE: intentional leak to avoid issues with C++ destructor
-               // chain
-
-  std::call_once(initialized, []() { instance = new DAPSessionManager(); });
-
-  return *instance;
+  static DAPSessionManager instance;
+  return instance;
 }
 
 void DAPSessionManager::RegisterSession(lldb_private::MainLoop *loop,

>From b726987fdea74aebde04118fbd6508246932b35f Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <[email protected]>
Date: Tue, 14 Jul 2026 00:54:58 +0100
Subject: [PATCH 2/3] allocate the session manager on the heap

---
 lldb/tools/lldb-dap/DAPSessionManager.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAPSessionManager.cpp 
b/lldb/tools/lldb-dap/DAPSessionManager.cpp
index 91c0538e63d5f..2089aa87c3d04 100644
--- a/lldb/tools/lldb-dap/DAPSessionManager.cpp
+++ b/lldb/tools/lldb-dap/DAPSessionManager.cpp
@@ -33,8 +33,10 @@ ManagedEventThread::~ManagedEventThread() {
 }
 
 DAPSessionManager &DAPSessionManager::GetInstance() {
-  static DAPSessionManager instance;
-  return instance;
+  // NOTE: Intentionally leaked. Detached client threads may still notify
+  // m_sessions_condition at exit, so it has to outlive them.
+  static auto *instance = new DAPSessionManager();
+  return *instance;
 }
 
 void DAPSessionManager::RegisterSession(lldb_private::MainLoop *loop,

>From 2746124bd2bb5642baffef9d0913c7ee9f6e47a2 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <[email protected]>
Date: Tue, 14 Jul 2026 09:57:40 +0100
Subject: [PATCH 3/3] update the message

---
 lldb/tools/lldb-dap/DAPSessionManager.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/DAPSessionManager.cpp 
b/lldb/tools/lldb-dap/DAPSessionManager.cpp
index 2089aa87c3d04..f3a731f87f4b6 100644
--- a/lldb/tools/lldb-dap/DAPSessionManager.cpp
+++ b/lldb/tools/lldb-dap/DAPSessionManager.cpp
@@ -33,7 +33,7 @@ ManagedEventThread::~ManagedEventThread() {
 }
 
 DAPSessionManager &DAPSessionManager::GetInstance() {
-  // NOTE: Intentionally leaked. Detached client threads may still notify
+  // NOTE: Intentional leak. Detached client threads may still notify
   // m_sessions_condition at exit, so it has to outlive them.
   static auto *instance = new DAPSessionManager();
   return *instance;

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to