Skip to content

Commit e3c67c9

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
1 parent 767c569 commit e3c67c9

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
@@ -2674,6 +2674,18 @@ class MetadataReader {
26742674
return nullptr;
26752675
}
26762676

2677+
// Check if the Reader can provide a symbol for this descriptor, and if it
2678+
// can, use that instead.
2679+
if (auto remoteAbsolutePointer =
2680+
Reader->resolvePointerAsSymbol(descriptor.getRemoteAddress())) {
2681+
auto symbol = remoteAbsolutePointer->getSymbol();
2682+
if (!symbol.empty()) {
2683+
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
2684+
return demangledSymbol;
2685+
}
2686+
}
2687+
}
2688+
26772689
// Read the parent descriptor.
26782690
auto parentDescriptorResult = readParentContextDescriptor(descriptor);
26792691

0 commit comments

Comments
 (0)