Skip to content

Debugger support for opaque types. #24445

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 8 commits into from
May 3, 2019

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented May 2, 2019

  • Include opaque type descriptors in the type lookup list for reflection discoverability.
  • Represent opaque types in DWARF consistently with other archetypes so that lldb can demangle them.
  • Add RemoteAST and MetadataReader support for getting the underlying types out of opaque type descriptors.

rdar://problem/46138166

We could introduce non-nominal-type context descriptors, such as those for opaque declarations,
which are also interesting to be able to look up for reflection or remote purposes. This should be
a backward compatible change with old runtimes, which always ignore any context descriptor kind
they don't know about.
If -enable-anonymous-context-mangled-names is enabled, meaning that we assign names to
anonymous context descriptors for discovery by RemoteAST, then include opaque type descriptors
in the type metadata record table so that they can also be found at runtime by RemoteAST for
debugger support.
When we formed a mangled name key to look up opaque return type decls during
interface parsing, we were accidentally including the `Global` demangle node
inside the `OpaqueReturnTypeOf` node, which ended up including the `$s` prefix
in the mangling. Other type reconstruction clients like lldb which provided
well-formed mangling trees did not include the Global node, causing the prefix
to get left off and lookups to fail. Fix Sema to remove the Global node before
looking up the opaque type, and have type reconstruction consistently apply the
prefix to the lookup key.
@jckarter
Copy link
Contributor Author

jckarter commented May 2, 2019

@swift-ci Please test

@jckarter jckarter force-pushed the opaque-type-remote branch from 4a0146b to 81e520e Compare May 2, 2019 20:02
@jckarter
Copy link
Contributor Author

jckarter commented May 2, 2019

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented May 2, 2019

Build failed
Swift Test Linux Platform
Git Sha - 4a0146b61f772df2dd08e0a6022f19dfc4f13676

@swift-ci
Copy link
Contributor

swift-ci commented May 2, 2019

Build failed
Swift Test OS X Platform
Git Sha - 4a0146b61f772df2dd08e0a6022f19dfc4f13676

@@ -826,14 +826,16 @@ void IRGenModule::addObjCClass(llvm::Constant *classPtr, bool nonlazy) {
ObjCNonLazyClasses.push_back(classPtr);
}

void IRGenModule::addRuntimeResolvableType(NominalTypeDecl *nominal) {
void IRGenModule::addRuntimeResolvableType(GenericTypeDecl *type) {
// Collect the nominal type records we emit into a special section.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you assert that type is an OpaqueTypeDecl or NominalTypeDecl (and not TypeAliasDecl which is the other subclass of GenericTypeDecl), and fix this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have that assertion deeper in the pipe, when you try to emit a context descriptor.

@@ -879,19 +879,29 @@ void IRGenModule::emitStructDecl(StructDecl *st) {
emitNestedTypeDecls(st->getMembers());
}

void IRGenModule::maybeEmitOpaqueTypeDecl(OpaqueTypeDecl *opaque) {
if (IRGen.Opts.EnableAnonymousContextMangledNames) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps fold this check into hasLazyMetadata()?

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'm not sure that buys much, since there's not much to gain from putting these in RuntimeResolvableTypes if we aren't also putting the name info in anonymous contexts, so the condition would be still be here, and still be worth factoring out of the individual emit methods below.

@jckarter
Copy link
Contributor Author

jckarter commented May 2, 2019

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

swift-ci commented May 3, 2019

Build failed
Swift Test Linux Platform
Git Sha - 81e520efe933a7acb166a25ea0db325b0e7b325d

jckarter added 3 commits May 2, 2019 17:27
When building for debug, the opaque return type context is nested under an anonymous context for
the defining function. Demangle the anonymous context name to reconstruct the mangling for the
opaque type.
…types.

They aren't normally decl contexts, but if one has an opaque type, we want to be able to record
the property as a context so that we can reconstruct it in RemoteAST.
@jckarter jckarter force-pushed the opaque-type-remote branch from 40f5381 to edd3015 Compare May 3, 2019 00:28
@jckarter
Copy link
Contributor Author

jckarter commented May 3, 2019

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented May 3, 2019

Build failed
Swift Test OS X Platform
Git Sha - 81e520efe933a7acb166a25ea0db325b0e7b325d

@swift-ci
Copy link
Contributor

swift-ci commented May 3, 2019

Build failed
Swift Test Linux Platform
Git Sha - 81e520efe933a7acb166a25ea0db325b0e7b325d

@jckarter
Copy link
Contributor Author

jckarter commented May 3, 2019

@swift-ci Please test OS X

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