Author: Dave Lee Date: 2025-08-21T13:23:38-07:00 New Revision: a447fc63f9b7add22eaa693e9ea8925402af04b7
URL: https://github.com/llvm/llvm-project/commit/a447fc63f9b7add22eaa693e9ea8925402af04b7 DIFF: https://github.com/llvm/llvm-project/commit/a447fc63f9b7add22eaa693e9ea8925402af04b7.diff LOG: [lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (#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. Original: https://github.com/llvm/llvm-project/pull/146062 Added: Modified: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 1db7bc78013d7..cd72454fe0287 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) { @@ -1397,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