@@ -79,7 +79,7 @@ class ReflectionContext
79
79
// / All buffers we need to keep around long term. This will automatically free them
80
80
// / when this object is destroyed.
81
81
std::vector<MemoryReader::ReadBytesResult> savedBuffers;
82
- std::vector<std::tuple<RemoteAddress, RemoteAddress>> dataSegments ;
82
+ std::vector<std::tuple<RemoteAddress, RemoteAddress>> imageRanges ;
83
83
84
84
public:
85
85
using super::getBuilder;
@@ -183,8 +183,7 @@ class ReflectionContext
183
183
auto DataSegmentStart = DataSegment - reinterpret_cast <const uint8_t *>(Buf.get ())
184
184
+ ImageStart.getAddressData ();
185
185
auto DataSegmentEnd = DataSegmentStart + DataSize;
186
- dataSegments.push_back (std::make_tuple (RemoteAddress (DataSegmentStart),
187
- RemoteAddress (DataSegmentEnd)));
186
+ imageRanges.push_back (std::make_tuple (ImageStart, RemoteAddress (DataSegmentEnd)));
188
187
}
189
188
190
189
savedBuffers.push_back (std::move (Buf));
@@ -200,17 +199,21 @@ class ReflectionContext
200
199
bool ownsObject (RemoteAddress ObjectAddress) {
201
200
auto MetadataAddress = readMetadataFromInstance (ObjectAddress.getAddressData ());
202
201
if (!MetadataAddress)
203
- return 0 ;
204
-
205
- for (auto Segment : dataSegments) {
206
- auto Start = std::get<0 >(Segment);
207
- auto End = std::get<1 >(Segment);
208
- if (Start.getAddressData () <= *MetadataAddress
209
- && *MetadataAddress < End.getAddressData ())
210
- return 1 ;
202
+ return true ;
203
+ return ownsAddress (RemoteAddress (*MetadataAddress));
204
+ }
205
+
206
+ // / Returns true if the address falls within a registered image.
207
+ bool ownsAddress (RemoteAddress Address) {
208
+ for (auto Range : imageRanges) {
209
+ auto Start = std::get<0 >(Range);
210
+ auto End = std::get<1 >(Range);
211
+ if (Start.getAddressData () <= Address.getAddressData ()
212
+ && Address.getAddressData () < End.getAddressData ())
213
+ return true ;
211
214
}
212
215
213
- return 0 ;
216
+ return false ;
214
217
}
215
218
216
219
// / Return a description of the layout of a class instance with the given
0 commit comments