Rewrite DwarfSectionImpl::InsertFde
Simplify and fix the algorithm.
For consecutive functions (eg [10,20] [20,30]) without
padding in between, the old algorithm would drop FDEs.
Bug: http://b/150050915
Test: libunwindstack_test
Change-Id: Ie886922bec262fb64d4b2ecf01c2961d0652dcdb
(cherry picked from commit a6617cb17926a9868a900ce43c9b358bafe88d9b)
diff --git a/libunwindstack/DwarfSection.cpp b/libunwindstack/DwarfSection.cpp
index e6263f8..18bd490 100644
--- a/libunwindstack/DwarfSection.cpp
+++ b/libunwindstack/DwarfSection.cpp
@@ -621,29 +621,9 @@
uint64_t start = fde->pc_start;
uint64_t end = fde->pc_end;
auto it = fdes_.upper_bound(start);
- bool add_element = false;
- while (it != fdes_.end() && start < end) {
- if (add_element) {
- add_element = false;
- if (end < it->second.first) {
- if (it->first == end) {
- return;
- }
- fdes_[end] = std::make_pair(start, fde);
- return;
- }
- if (start != it->second.first) {
- fdes_[it->second.first] = std::make_pair(start, fde);
- }
- }
- if (start < it->first) {
- if (end < it->second.first) {
- if (it->first != end) {
- fdes_[end] = std::make_pair(start, fde);
- }
- return;
- }
- add_element = true;
+ while (it != fdes_.end() && start < end && it->second.first < end) {
+ if (start < it->second.first) {
+ fdes_[it->second.first] = std::make_pair(start, fde);
}
start = it->first;
++it;