Skip to content

[RemoteInspection] Add a hook to process addresses before converting #82073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/swift/Remote/MemoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ class MemoryReader {
return RemoteAbsolutePointer("", readValue);
}

/// Performs the inverse operation of \ref resolvePointer.
/// A use-case for this is to turn file addresses into in-process addresses.
virtual std::optional<RemoteAddress>
resolveRemoteAddress(RemoteAddress address) const {
return std::nullopt;
}

virtual std::optional<RemoteAbsolutePointer>
resolvePointerAsSymbol(RemoteAddress address) {
return std::nullopt;
Expand Down
4 changes: 3 additions & 1 deletion include/swift/Remote/MetadataReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2907,8 +2907,10 @@ class MetadataReader {
case ContextDescriptorKind::Anonymous: {
// Use the remote address to identify the anonymous context.
char addressBuf[18];
RemoteAddress address(descriptor.getAddressData());
address = Reader->resolveRemoteAddress(address).value_or(address);
snprintf(addressBuf, sizeof(addressBuf), "$%" PRIx64,
(uint64_t)descriptor.getAddressData());
(uint64_t)address.getAddressData());
auto anonNode = dem.createNode(Node::Kind::AnonymousContext);
CharVector addressStr;
addressStr.append(addressBuf, dem);
Expand Down