https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/171820

>From fcbe4c42381cf6b895bfcf484af82f79d9f1d75f Mon Sep 17 00:00:00 2001
From: Michael Buch <[email protected]>
Date: Thu, 11 Dec 2025 12:42:10 +0000
Subject: [PATCH] [lldb][Module] Only log SDK search error once per debugger
 session

---
 lldb/include/lldb/Core/Module.h |  4 ++++
 lldb/source/Core/Module.cpp     | 11 ++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 40ce23e3d2ffb..0c51808ed5073 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -1094,6 +1094,9 @@ class Module : public 
std::enable_shared_from_this<Module>,
       m_shown_diagnostics;
   std::recursive_mutex m_diagnostic_mutex;
 
+  llvm::StringMap<std::unique_ptr<std::once_flag>> m_shown_sdk_errors;
+  std::recursive_mutex m_shown_sdk_errors_mutex;
+
   void SymbolIndicesToSymbolContextList(Symtab *symtab,
                                         std::vector<uint32_t> &symbol_indexes,
                                         SymbolContextList &sc_list);
@@ -1121,6 +1124,7 @@ class Module : public 
std::enable_shared_from_this<Module>,
   void ReportError(const llvm::formatv_object_base &payload);
   void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
   std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
+  std::once_flag *GetSDKErrorOnceFlag(llvm::StringRef msg);
 };
 
 } // namespace lldb_private
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index da2c188899f03..8527001abd678 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1117,6 +1117,13 @@ void Module::ReportErrorIfModifyDetected(
   }
 }
 
+std::once_flag *Module::GetSDKErrorOnceFlag(llvm::StringRef msg) {
+  std::lock_guard<std::recursive_mutex> guard(m_shown_sdk_errors_mutex);
+  auto [it, _] =
+      m_shown_sdk_errors.try_emplace(msg, std::make_unique<std::once_flag>());
+  return it->getValue().get();
+}
+
 std::once_flag *Module::GetDiagnosticOnceFlag(llvm::StringRef msg) {
   std::lock_guard<std::recursive_mutex> guard(m_diagnostic_mutex);
   auto &once_ptr = m_shown_diagnostics[llvm::stable_hash_name(msg)];
@@ -1569,7 +1576,9 @@ void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
 
   if (!sdk_path_or_err) {
     Debugger::ReportError("Error while searching for Xcode SDK: " +
-                          toString(sdk_path_or_err.takeError()));
+                              toString(sdk_path_or_err.takeError()),
+                          /*debugger_id=*/std::nullopt,
+                          /*once=*/GetSDKErrorOnceFlag(sdk_name));
     return;
   }
 

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

Reply via email to