[Lldb-commits] [lldb] [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (PR #154607)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 20 13:32:26 PDT 2025
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/154607
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.
>From 1e70adad6b2d62bcb568ad603298a1a91121a87b Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Wed, 20 Aug 2025 13:27:51 -0700
Subject: [PATCH] [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) {
More information about the lldb-commits
mailing list