diff options
-rw-r--r-- | src/processor/range_map-inl.h | 2 | ||||
-rw-r--r-- | src/processor/range_map_unittest.cc | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/processor/range_map-inl.h b/src/processor/range_map-inl.h index 77bf7d20..a6a97e08 100644 --- a/src/processor/range_map-inl.h +++ b/src/processor/range_map-inl.h @@ -156,7 +156,7 @@ bool RangeMap<AddressType, EntryType>::RetrieveNearestRange( *entry = iterator->second.entry(); if (entry_base) - *entry_base = iterator->first; + *entry_base = iterator->second.base(); if (entry_size) *entry_size = iterator->first - iterator->second.base() + 1; diff --git a/src/processor/range_map_unittest.cc b/src/processor/range_map_unittest.cc index 5b5ce573..499b6d37 100644 --- a/src/processor/range_map_unittest.cc +++ b/src/processor/range_map_unittest.cc @@ -210,10 +210,11 @@ static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { linked_ptr<CountedObject> nearest_object; AddressType nearest_base; + AddressType nearest_size; bool retrieved_nearest = range_map->RetrieveNearestRange(address, &nearest_object, &nearest_base, - NULL); + &nearest_size); // When checking one greater than the high side, RetrieveNearestRange // should usually return the test range. When a different range begins @@ -237,6 +238,22 @@ static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { observed_nearest ? "true" : "false"); return false; } + + // If a range was successfully retrieved, check that the returned + // bounds match the range as stored. + if (expected_nearest && + (nearest_base != range_test->address || + nearest_size != range_test->size)) { + fprintf(stderr, "FAILED: " + "RetrieveNearestRange id %d, side %d, offset %d, " + "expected base/size %d/%d, observed %d/%d\n", + range_test->id, + side, + offset, + range_test->address, range_test->size, + nearest_base, nearest_size); + return false; + } } } |