diff options
author | mmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2006-10-20 19:50:01 +0000 |
---|---|---|
committer | mmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2006-10-20 19:50:01 +0000 |
commit | 2fc823f5794737391e231c1dce6c2b0793213e53 (patch) | |
tree | c27c65c91a046cfbad62aac309cc68539a20c231 /src/processor/range_map-inl.h | |
parent | Handle frame pointer omission, (#21), part 4 (final part!): FPO stackwalker. (diff) | |
download | breakpad-2fc823f5794737391e231c1dce6c2b0793213e53.tar.xz |
Add PUBLIC support to SourceLineResolver (resolve function names in Windows
system libraries) (#53)
StackFrame::function_base is not populated (#49)
r=bryner
http://groups.google.com/group/airbag-dev/browse_thread/thread/a17d35348e7027bb
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@43 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/processor/range_map-inl.h')
-rw-r--r-- | src/processor/range_map-inl.h | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/processor/range_map-inl.h b/src/processor/range_map-inl.h index 5073a1fc..74ce8513 100644 --- a/src/processor/range_map-inl.h +++ b/src/processor/range_map-inl.h @@ -83,7 +83,8 @@ bool RangeMap<AddressType, EntryType>::StoreRange(const AddressType &base, template<typename AddressType, typename EntryType> bool RangeMap<AddressType, EntryType>::RetrieveRange( - const AddressType &address, EntryType *entry) const { + const AddressType &address, EntryType *entry, + AddressType *entry_base, AddressType *entry_size) const { if (!entry) return false; @@ -100,6 +101,42 @@ bool RangeMap<AddressType, EntryType>::RetrieveRange( return false; *entry = iterator->second.entry(); + if (entry_base) + *entry_base = iterator->second.base(); + if (entry_size) + *entry_size = iterator->first - iterator->second.base() + 1; + + return true; +} + + +template<typename AddressType, typename EntryType> +bool RangeMap<AddressType, EntryType>::RetrieveNearestRange( + const AddressType &address, EntryType *entry, + AddressType *entry_base, AddressType *entry_size) const { + if (!entry) + return false; + + // If address is within a range, RetrieveRange can handle it. + if (RetrieveRange(address, entry, entry_base, entry_size)) + return true; + + // upper_bound gives the first element whose key is greater than address, + // but we want the first element whose key is less than or equal to address. + // Decrement the iterator to get there, but not if the upper_bound already + // points to the beginning of the map - in that case, address is lower than + // the lowest stored key, so return false. + MapConstIterator iterator = map_.upper_bound(address); + if (iterator == map_.begin()) + return false; + --iterator; + + *entry = iterator->second.entry(); + if (entry_base) + *entry_base = iterator->first; + if (entry_size) + *entry_size = iterator->first - iterator->second.base() + 1; + return true; } |