@@ -128,13 +128,31 @@ class MemoryReader {
128
128
// /
129
129
// / Returns false if the operation failed.
130
130
virtual bool readString (RemoteAddress address, std::string &dest) = 0;
131
-
131
+
132
+ // / Attempts to read a remote address from the given address in the remote
133
+ // / process.
134
+ // /
135
+ // / Returns false if the operator failed.
136
+ template <typename IntegerType>
137
+ bool readRemoteAddress (RemoteAddress address, RemoteAddress &out) {
138
+ IntegerType buf;
139
+ if (!readInteger (address, &buf))
140
+ return false ;
141
+
142
+ out = RemoteAddress ((uint64_t )buf, address.getAddressSpace ());
143
+ return true ;
144
+ }
145
+
132
146
// / Attempts to read an integer from the given address in the remote
133
147
// / process.
134
148
// /
135
149
// / Returns false if the operation failed.
136
150
template <typename IntegerType>
137
151
bool readInteger (RemoteAddress address, IntegerType *dest) {
152
+ static_assert (!std::is_same<RemoteAddress, IntegerType>(),
153
+ " RemoteAddress cannot be read in directly, use "
154
+ " readRemoteAddress instead." );
155
+
138
156
return readBytes (address, reinterpret_cast <uint8_t *>(dest),
139
157
sizeof (IntegerType));
140
158
}
@@ -218,7 +236,8 @@ class MemoryReader {
218
236
virtual RemoteAbsolutePointer resolvePointer (RemoteAddress address,
219
237
uint64_t readValue) {
220
238
// Default implementation returns the read value as is.
221
- return RemoteAbsolutePointer (RemoteAddress (readValue));
239
+ return RemoteAbsolutePointer (
240
+ RemoteAddress (readValue, address.getAddressSpace ()));
222
241
}
223
242
224
243
// / Performs the inverse operation of \ref resolvePointer.
@@ -321,7 +340,7 @@ class MemoryReader {
321
340
virtual ~MemoryReader () = default ;
322
341
};
323
342
324
- } // end namespace reflection
343
+ } // end namespace remote
325
344
} // end namespace swift
326
345
327
346
#endif // SWIFT_REFLECTION_READER_H
0 commit comments