Implement symbolic demangling for extended existential metadata

Fixes rdar://96268090.
This commit is contained in:
John McCall
2022-06-30 02:35:17 -04:00
parent 396121c231
commit 175f74d38f
27 changed files with 627 additions and 146 deletions

View File

@@ -459,6 +459,20 @@ public:
// execute code in the target process to resolve it from here.
return nullptr;
}
case Demangle::SymbolicReferenceKind::UniqueExtendedExistentialTypeShape: {
// The symbolic reference points at a unique extended
// existential type shape.
return dem.createNode(
Node::Kind::UniqueExtendedExistentialTypeShapeSymbolicReference,
resolved.getResolvedAddress().getAddressData());
}
case Demangle::SymbolicReferenceKind::NonUniqueExtendedExistentialTypeShape: {
// The symbolic reference points at a non-unique extended
// existential type shape.
return dem.createNode(
Node::Kind::NonUniqueExtendedExistentialTypeShapeSymbolicReference,
resolved.getResolvedAddress().getAddressData());
}
}
return nullptr;
@@ -1976,8 +1990,25 @@ protected:
}
case MetadataKind::ExistentialMetatype:
return _readMetadata<TargetExistentialMetatypeMetadata>(address);
case MetadataKind::ExtendedExistential:
return _readMetadata<TargetExtendedExistentialTypeMetadata>(address);
case MetadataKind::ExtendedExistential: {
// We need to read the shape in order to figure out how large
// the generalization arguments are.
StoredPointer shapeAddress = address + sizeof(StoredPointer);
StoredSignedPointer signedShapePtr;
if (!Reader->readInteger(RemoteAddress(shapeAddress), &signedShapePtr))
return nullptr;
auto shapePtr = stripSignedPointer(signedShapePtr);
auto shape = readShape(shapePtr);
if (!shape)
return nullptr;
auto totalSize =
sizeof(TargetExtendedExistentialTypeMetadata<Runtime>)
+ shape->getGeneralizationSignature().getArgumentLayoutSizeInWords()
* sizeof(StoredPointer);
return _readMetadata(address, totalSize);
}
case MetadataKind::ForeignClass:
return _readMetadata<TargetForeignClassMetadata>(address);
case MetadataKind::ForeignReferenceType:
@@ -2000,12 +2031,12 @@ protected:
totalSize += flags.getNumParameters() * sizeof(uint32_t);
if (flags.isDifferentiable())
totalSize = roundUpToAlignment(totalSize, sizeof(void *)) +
totalSize = roundUpToAlignment(totalSize, sizeof(StoredPointer)) +
sizeof(TargetFunctionMetadataDifferentiabilityKind<
typename Runtime::StoredSize>);
return _readMetadata(address,
roundUpToAlignment(totalSize, sizeof(void *)));
roundUpToAlignment(totalSize, sizeof(StoredPointer)));
}
case MetadataKind::HeapGenericLocalVariable:
return _readMetadata<TargetGenericBoxHeapMetadata>(address);