Skip to content

[lldb] Use symbol context module to determine SDK as fallback when creating SwiftASTContext - #13918

Open
kastiglione wants to merge 3 commits into
swift/release/6.4.xfrom
dl/lldb-Use-executable-module-SDK-as-fallback-when-creating-SwiftASTContext
Open

[lldb] Use symbol context module to determine SDK as fallback when creating SwiftASTContext#13918
kastiglione wants to merge 3 commits into
swift/release/6.4.xfrom
dl/lldb-Use-executable-module-SDK-as-fallback-when-creating-SwiftASTContext

Conversation

@kastiglione

@kastiglione kastiglione commented Aug 18, 2026

Copy link
Copy Markdown

When creating a SwiftASTContext, use the SDK of the module from the symbol context, as fallback when there is no compile unit. This can avoid a case where the default SDK is incorrect.

rdar://184747912

@kastiglione
kastiglione requested a review from a team as a code owner August 18, 2026 16:56
@kastiglione

Copy link
Copy Markdown
Author

@swift-ci test

1 similar comment
@kastiglione

Copy link
Copy Markdown
Author

@swift-ci test

// module. This avoids silently defaulting to the public SDK, which can
// cause problems when when debugging a binary that uses an internal SDK.
if (auto sdk_or_err =
platform_sp->GetSDKPathFromDebugInfo(*exe_module_sp)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

instead of picking the executable module, would getting the module from sc and feeding that into GetSDKPathFromDebugInfo() also work? That should be safer in a heterogeneous app (think of an app where the executable is arm64-apple-ios-macabi but the dylib the breakpoint is in is arm64-apple-macos.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

@kastiglione kastiglione changed the title [lldb] Use executable module SDK as fallback when creating SwiftASTContext [lldb] Use symbol context module to determine SDK as fallback when creating SwiftASTContext Aug 18, 2026
@kastiglione

Copy link
Copy Markdown
Author

@swift-ci test

@kastiglione

Copy link
Copy Markdown
Author

@swift-ci test

@adrian-prantl adrian-prantl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That seems to be

LOG_PRINTF(GetLog(LLDBLog::Types), "Using precise SDK: %s",
sdk->GetString().str().c_str());
}
} else if (module_sp) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We might still want to fallback to the executable if module_sp is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants