aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-01-27 19:10:06 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-01-27 19:10:06 +0000
commit97f1da43aecf3298541ffee69db4eaa76e104f14 (patch)
treeef7e662ca32eba02b0d215277730bb23619b60fa
parentBreakpad Linux Dumper: Add DWARF support. (diff)
downloadbreakpad-97f1da43aecf3298541ffee69db4eaa76e104f14.tar.xz
Breakpad processor: Have RetrieveNearestRange correctly return range extent.
RangeMaps use the range's upper end as the key in the underlying map, but RetrieveNearestRange was treating the key as the lower end. a=jimblandy, r=mmentovai git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@501 4c0a9323-5329-0410-9bdc-e9ce6186880e
-rw-r--r--src/processor/range_map-inl.h2
-rw-r--r--src/processor/range_map_unittest.cc19
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;
+ }
}
}