mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-28 04:14:21 +01:00
Handle abbrev entities being out of order.
There are cases where the debug_abbrev entities are not sequential, for example, in Xamarin system dlls. This change gracefully handles such a case. Change-Id: Ib270393d3cf9fd18efd99d15d0fba4f96748188a Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3738879 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
parent
f9fcba812c
commit
3e2a341168
@ -129,10 +129,13 @@ void CompilationUnit::ReadAbbrevs() {
|
|||||||
const uint64_t abbrev_length = iter->second.second - header_.abbrev_offset;
|
const uint64_t abbrev_length = iter->second.second - header_.abbrev_offset;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint64_t highest_number = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
CompilationUnit::Abbrev abbrev;
|
CompilationUnit::Abbrev abbrev;
|
||||||
size_t len;
|
size_t len;
|
||||||
const uint64_t number = reader_->ReadUnsignedLEB128(abbrevptr, &len);
|
const uint64_t number = reader_->ReadUnsignedLEB128(abbrevptr, &len);
|
||||||
|
highest_number = std::max(highest_number, number);
|
||||||
|
|
||||||
if (number == 0)
|
if (number == 0)
|
||||||
break;
|
break;
|
||||||
@ -170,9 +173,17 @@ void CompilationUnit::ReadAbbrevs() {
|
|||||||
value);
|
value);
|
||||||
abbrev.attributes.push_back(abbrev_attr);
|
abbrev.attributes.push_back(abbrev_attr);
|
||||||
}
|
}
|
||||||
assert(abbrev.number == abbrevs_->size());
|
|
||||||
abbrevs_->push_back(abbrev);
|
abbrevs_->push_back(abbrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Account of cases where entries are out of order.
|
||||||
|
std::sort(abbrevs_->begin(), abbrevs_->end(),
|
||||||
|
[](const CompilationUnit::Abbrev& lhs, const CompilationUnit::Abbrev& rhs) {
|
||||||
|
return lhs.number < rhs.number;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure that there are no missing sections.
|
||||||
|
assert(abbrevs_->size() == highest_number + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skips a single DIE's attributes.
|
// Skips a single DIE's attributes.
|
||||||
|
Loading…
Reference in New Issue
Block a user