https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/154607

>From 1e70adad6b2d62bcb568ad603298a1a91121a87b Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Wed, 20 Aug 2025 13:27:51 -0700
Subject: [PATCH 1/2] [lldb] Improve error message in
 ResolveSDKPathFromDebugInfo (NFC)

While debugging, I saw a log line of:

>  Failed to resolve SDK path: Error while searching for SDK (XcodeSDK ''): 
> Unrecognized SDK type:

Looking into how this might happen, it seems `ResolveSDKPathFromDebugInfo` 
appears to
(implicitly) assume there's at least one compile unit. This change adds a 
precondition
to return a meaningful error when there are no compile units.
---
 lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 1db7bc78013d7..dc8b9437a64e4 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1039,7 +1039,12 @@ ResolveSDKPathFromDebugInfo(lldb_private::Target 
*target) {
 
   SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
   if (!sym_file)
-    return llvm::createStringError("Failed to get symbol file from module");
+    return llvm::createStringError("Failed to get symbol file from 
executable");
+
+  if (sym_file->GetNumCompileUnits() == 0)
+    return llvm::createStringError(
+        "Failed to resolve SDK for target: executable's symbol file has no "
+        "compile units");
 
   XcodeSDK merged_sdk;
   for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {

>From 61e3ec601407ba39f507e4609935b981454a044e Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Thu, 21 Aug 2025 09:25:30 -0700
Subject: [PATCH 2/2] add matching check to
 PlatformDarwin::GetSDKPathFromDebugInfo

---
 lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index dc8b9437a64e4..cd72454fe0287 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1402,6 +1402,12 @@ PlatformDarwin::GetSDKPathFromDebugInfo(Module &module) {
         llvm::formatv("No symbol file available for module '{0}'",
                       module.GetFileSpec().GetFilename().AsCString("")));
 
+  if (sym_file->GetNumCompileUnits() == 0)
+    return llvm::createStringError(
+        llvm::formatv("Could not resolve SDK for module '{0}'. Symbol file has 
"
+                      "no compile units.",
+                      module.GetFileSpec()));
+
   bool found_public_sdk = false;
   bool found_internal_sdk = false;
   XcodeSDK merged_sdk;

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to