Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal if not, but any way we can test this? There are some XcodeSDK unittests which might fit the bill

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see an existing place to test this ResolveSDKPathFromDebugInfo. It's a function used specifically by AddClangModuleCompilationOptions, which doesn't have any existing tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other place Charles mentioned does have tests: GetSDKPathFromDebugInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Michael137 I tried to update XcodeSDKModuleTests.cpp but can't figure out how to construct a yaml that represents zero compile units. If you know how to do that, I'll make a follow up test.


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) {
Copy link
Contributor Author

@kastiglione kastiglione Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that merged_sdk will be empty if there are no compile units, but the subsequent code assumes the loop produces a non-empty sdk.

Expand Down Expand Up @@ -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;
Expand Down
Loading