Skip to content

Commit f30b313

Browse files
committed
Add a new virtual function to MemoryReader: resolvePointerAsSymbol
This new function allows subclasses to attempt to resolve a pointer to a symbol before any memory is read, which can be potentially expensive (for example, in LLDB).
1 parent 685dbad commit f30b313

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

include/swift/Remote/MemoryReader.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,21 @@ class MemoryReader {
134134
// Default implementation returns the read value as is.
135135
return RemoteAbsolutePointer("", readValue);
136136
}
137-
137+
138+
/// Atempt to resolve the pointer to a symbol for the given remote address.
139+
virtual llvm::Optional<RemoteAbsolutePointer>
140+
resolvePointerAsSymbol(RemoteAddress address) {
141+
return llvm::None;
142+
}
143+
138144
/// Attempt to read and resolve a pointer value at the given remote address.
139145
llvm::Optional<RemoteAbsolutePointer> readPointer(RemoteAddress address,
140146
unsigned pointerSize) {
147+
// Try to resolve the pointer as a symbol first, as reading memory
148+
// may potentially be expensive.
149+
if (auto symbolPointer = resolvePointerAsSymbol(address))
150+
return symbolPointer;
151+
141152
auto result = readBytes(address, pointerSize);
142153
if (!result)
143154
return llvm::None;

0 commit comments

Comments
 (0)