28
28
#include " swift/Remote/MemoryReader.h"
29
29
#include " swift/Remote/MetadataReader.h"
30
30
#include " swift/Reflection/Records.h"
31
+ #include " swift/Reflection/RuntimeInternals.h"
31
32
#include " swift/Reflection/TypeLowering.h"
32
33
#include " swift/Reflection/TypeRef.h"
33
34
#include " swift/Reflection/TypeRefBuilder.h"
@@ -772,16 +773,6 @@ class ReflectionContext
772
773
}
773
774
}
774
775
775
-
776
-
777
- struct ConformanceNode {
778
- StoredPointer Left, Right;
779
- StoredPointer Type;
780
- StoredPointer Proto;
781
- StoredPointer Description;
782
- StoredSize FailureGeneration;
783
- };
784
-
785
776
StoredSignedPointer getTypeContextDescriptor (const TargetMetadata<Runtime> *Metadata) const {
786
777
switch (Metadata->getKind ()) {
787
778
case MetadataKind::Class: {
@@ -803,19 +794,25 @@ class ReflectionContext
803
794
}
804
795
}
805
796
797
+ // / Iterate the protocol conformance cache tree rooted at NodePtr, calling
798
+ // / Call with the type and protocol in each node.
806
799
void iterateConformanceTree (StoredPointer NodePtr,
807
800
std::function<void (StoredPointer Type, StoredPointer Proto)> Call) {
808
801
if (!NodePtr)
809
802
return ;
810
803
auto NodeBytes = getReader ().readBytes (RemoteAddress (NodePtr), sizeof (Node));
811
- auto NodeData = reinterpret_cast <const ConformanceNode *>(NodeBytes.get ());
804
+ auto NodeData =
805
+ reinterpret_cast <const ConformanceNode<Runtime> *>(NodeBytes.get ());
812
806
if (!NodeData)
813
807
return ;
814
808
Call (NodeData->Type , NodeData->Proto );
815
809
iterateConformanceTree (NodeData->Left , Call);
816
810
iterateConformanceTree (NodeData->Right , Call);
817
811
}
818
812
813
+ // / Iterate the protocol conformance cache in the target process, calling Call
814
+ // / with the type and protocol of each conformance. Returns None on success,
815
+ // / and a string describing the error on failure.
819
816
llvm::Optional<std::string> iterateConformances (
820
817
std::function<void (StoredPointer Type, StoredPointer Proto)> Call) {
821
818
std::string ConformancesPointerName =
@@ -836,20 +833,10 @@ class ReflectionContext
836
833
return llvm::None;
837
834
}
838
835
839
- void iterateModules (Demangle::NodePointer Ptr, std::function<void (llvm::StringRef)> Call) {
840
- if (Ptr->getKind () == Node::Kind::Module)
841
- Call (Ptr->getText ());
842
- for (auto Child : *Ptr)
843
- iterateModules (Child, Call);
844
- }
845
-
846
- struct MetadataAllocation {
847
- uint16_t Tag;
848
- StoredPointer Ptr;
849
- unsigned Size;
850
- };
851
-
852
- StoredPointer allocationMetadataPointer (MetadataAllocation Allocation) {
836
+ // / Fetch the metadata pointer from a metadata allocation, or 0 if this
837
+ // / allocation's tag is not handled or an error occurred.
838
+ StoredPointer allocationMetadataPointer (
839
+ MetadataAllocation<Runtime> Allocation) {
853
840
if (Allocation.Tag == GenericMetadataCacheTag) {
854
841
struct GenericMetadataCacheEntry {
855
842
StoredPointer Left, Right;
@@ -872,9 +859,12 @@ class ReflectionContext
872
859
}
873
860
return 0 ;
874
861
}
875
-
876
- llvm::Optional<std::string>
877
- iterateMetadataAllocations (std::function<void (MetadataAllocation)> Call) {
862
+
863
+ // / Iterate the metadata allocations in the target process, calling Call with
864
+ // / each allocation found. Returns None on success, and a string describing
865
+ // / the error on failure.
866
+ llvm::Optional<std::string> iterateMetadataAllocations (
867
+ std::function<void (MetadataAllocation<Runtime>)> Call) {
878
868
std::string IterationEnabledName =
879
869
" __swift_debug_metadataAllocationIterationEnabled" ;
880
870
std::string AllocationPoolPointerName =
@@ -940,7 +930,7 @@ class ReflectionContext
940
930
if (Header->Size == 0 )
941
931
break ;
942
932
auto RemoteAddr = PoolStart + Offset + sizeof (AllocationHeader);
943
- MetadataAllocation Allocation;
933
+ MetadataAllocation<Runtime> Allocation;
944
934
Allocation.Tag = Header->Tag ;
945
935
Allocation.Ptr = RemoteAddr;
946
936
Allocation.Size = Header->Size ;
0 commit comments