Skip to content

Commit 540df14

Browse files
committed
[RemoteInspection] Add a hook to process addresses before converting
them to hex strings when creating anonymous context descriptors. This aims to solve a problem when LLDB reads reflection metadata directly from local binary files instead of downloading them from in-process memory. LLDB's MemoryReader implements this to convert the file address into an in-process address, so mangled names created from instance metadata can be matched with the field info data read from the local files. rdar://152743797
1 parent 083cb11 commit 540df14

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

include/swift/Remote/MemoryReader.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ class MemoryReader {
150150
return RemoteAbsolutePointer("", readValue);
151151
}
152152

153+
/// Performs the inverse operation of \ref resolvePointer.
154+
/// A use-case for this is to turn file addresses into in-process addresses.
155+
virtual std::optional<RemoteAddress>
156+
resolveRemoteAddress(RemoteAddress address) const {
157+
return std::nullopt;
158+
}
159+
153160
virtual std::optional<RemoteAbsolutePointer>
154161
resolvePointerAsSymbol(RemoteAddress address) {
155162
return std::nullopt;

include/swift/Remote/MetadataReader.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2907,8 +2907,10 @@ class MetadataReader {
29072907
case ContextDescriptorKind::Anonymous: {
29082908
// Use the remote address to identify the anonymous context.
29092909
char addressBuf[18];
2910+
RemoteAddress address(descriptor.getAddressData());
2911+
address = Reader->resolveRemoteAddress(address).value_or(address);
29102912
snprintf(addressBuf, sizeof(addressBuf), "$%" PRIx64,
2911-
(uint64_t)descriptor.getAddressData());
2913+
(uint64_t)address.getAddressData());
29122914
auto anonNode = dem.createNode(Node::Kind::AnonymousContext);
29132915
CharVector addressStr;
29142916
addressStr.append(addressBuf, dem);

0 commit comments

Comments
 (0)