Skip to content

Conversation

@slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Feb 11, 2019

In the service of apple/swift-lldb#1286. Replacing lldb's existing existential projection code path with RemoteAST exposed some limitations in the latter.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov requested review from dcci and rjmccall and removed request for rjmccall February 11, 2019 06:22
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider just making a struct, especially since this type is used multiple places throughout the reader.

Copy link
Contributor

Choose a reason for hiding this comment

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

The pattern was that all of these were Result-ified.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

apple/swift-lldb#1287
@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

apple/swift-lldb#1287
@swift-ci Please smoke test macOS

@slavapestov
Copy link
Contributor Author

Looks like this breaks LLDB without my larger set of LDLB changes. I'm breaking out #22534 to fix the tagged pointer issue.

An Error existential value can directly store a
reference to an NSError instance without wrapping
it in an Error container.

When "projecting" such an existential, the dynamic type
is the NSError's isa pointer, and the payload is the
address of the instance itself.
LLDB calls getDynamicTypeAndAddressForExistential() on an existential
value without knowing if its a class existential or opaque existential.

Class existentials return the address of the instance itself here,
whereas opaque existentials always returned the address of the
payload value.

This meant the caller could not usefully operate on the payload value
if it was of class type, because there was no way of knowing if the
extra dereference had occurred or not.

Now, always load the reference if the wrapped type is a class, even
if the existential is opaque.

Will be tested on the lldb side with another change I'm working on.
The getDynamicTypeAndAddressForExistential() function takes the
address of an existential value; so when looking at an Error,
this is the address of the reference, not the address of the
instance.

lldb needs to look at Error instances too, so add a new entry
point named getDynamicTypeAndAddressForError() which avoids the
extra dereference.

This will be tested on the lldb side.
@slavapestov
Copy link
Contributor Author

apple/swift-lldb#1287
@swift-ci Please smoke test

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.

2 participants