Skip to content

Commit 2533b05

Browse files
committed
[RemoteInspection] Read ContextDescriptor from symbol if available
If the MemoryReader can provide a symbol for the context descriptor, use that instead of building the mangle tree from metadata. This shouldn't hurt other clients, and would have a few benefits for LLDB: - Small but numerous memory reads can be expensive for LLDB, building the mangle tree from a string should be much faster. - For types with private discriminators, this allows LLDB to provide the same private discriminator that's in DWARF and in the swiftmodule (as opposed to using the memory address where the context descriptor lives at). This means that these private types would have the same mangled name in every run. LLDB persistently caches field descriptors by name, but since private discriminators aren't guaranteed to have the same mangled name over multiple runs, LLDB would often need to invalidate its entire cache and rebuild it. Using the stable UUID would solve that issue. rdar://165950673 (cherry picked from commit e3c67c9)
1 parent c7847e1 commit 2533b05

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,6 +2690,18 @@ class MetadataReader {
26902690
return nullptr;
26912691
}
26922692

2693+
// Check if the Reader can provide a symbol for this descriptor, and if it
2694+
// can, use that instead.
2695+
if (auto remoteAbsolutePointer =
2696+
Reader->resolvePointerAsSymbol(descriptor.getRemoteAddress())) {
2697+
auto symbol = remoteAbsolutePointer->getSymbol();
2698+
if (!symbol.empty()) {
2699+
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
2700+
return demangledSymbol;
2701+
}
2702+
}
2703+
}
2704+
26932705
// Read the parent descriptor.
26942706
auto parentDescriptorResult = readParentContextDescriptor(descriptor);
26952707

0 commit comments

Comments
 (0)