Skip to content

[LLDB] Fix conditional to also support AccessLevel::Open #80691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2025

Conversation

adrian-prantl
Copy link
Contributor

[LLDB] Fix conditional to also support AccessLevel::Open
This fixes crashes in LLDB expression evaluation when calling virtual
Open functions.

rdar://147797657

and

Improve legibility of conditional
Commit bceb817 made the following edits:

   SILDeclRef method = i->getMember().getOverriddenVTableEntry();
   auto methodType = i->getType().castTo<SILFunctionType>();

+  AccessLevel methodAccess = method.getDecl()->getEffectiveAccess();
   auto *classDecl = cast<ClassDecl>(method.getDecl()->getDeclContext());
   bool shouldUseDispatchThunk = false;
-  if (IGM.hasResilientMetadata(classDecl, ResilienceExpansion::Maximal)) {
+  // Because typechecking for the debugger has more lax rules, check the access
+  // level of the getter to decide whether to use a dispatch thunk for the
+  // debugger.
+  bool shouldUseDispatchThunkIfInDebugger =
+      !classDecl->getASTContext().LangOpts.DebuggerSupport ||
+      methodAccess == AccessLevel::Public;
+  if (IGM.hasResilientMetadata(classDecl, ResilienceExpansion::Maximal) &&
+      shouldUseDispatchThunkIfInDebugger) {
     shouldUseDispatchThunk = true;
   } else if (IGM.getOptions().VirtualFunctionElimination) {
     // For VFE, use a thunk if the target class is in another module. This

This commit refactors the conditional that make it more obvious that
only the LLDB code path is meant to be affected.

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

The logic here is getting complex. Do you mind splitting off the entire computation of shouldUseDispatchThunk into a new top-level function?

This fixes crashes in LLDB expression evaluation when calling virtual
Open functions.

rdar://147797657
@adrian-prantl
Copy link
Contributor Author

The logic here is getting complex. Do you mind splitting off the entire computation of shouldUseDispatchThunk into a new top-level function?

Added a 3rd NFC commit on top.

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 9, 2025
@adrian-prantl adrian-prantl merged commit 1914573 into swiftlang:main Apr 10, 2025
5 checks passed
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 10, 2025
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 10, 2025
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 10, 2025
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 10, 2025
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 11, 2025
adrian-prantl added a commit to adrian-prantl/llvm-project that referenced this pull request Apr 12, 2025
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